use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.
the class GlobalDomainRoleControllerBeanTest method testRemove.
@Test
public void testRemove() {
DomainRoleEntry domainRoleEntry = new DomainRoleEntry(USER_ID, DOMAINS, ROLE);
when(domainRoleEntryManagerMock.removeByUserIdAndRole(USER_ID, ROLE)).thenReturn(domainRoleEntry);
assertTrue(globalDomainRoleControllerSubject.removeDomainRole(USER_ID, ROLE));
verify(domainRoleEntryManagerMock).removeByUserIdAndRole(eq(USER_ID), eq(ROLE));
verify(globalDomainRoleControllerSubscriptionPublisherMock).fireDomainRoleEntryChanged(eq(ChangeType.REMOVE), eq(domainRoleEntry), eq(USER_PARTITION));
}
use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.
the class DomainRoleEntryManagerTest method testUpdateExistingEntry.
@Test
public void testUpdateExistingEntry() {
String userId = "user";
DomainRoleEntryEntity entity = create(userId, Sets.newHashSet("domain1", "domain2"), Role.OWNER);
flushAndClear();
DomainRoleEntry updatedEntry = new DomainRoleEntry(userId, new String[] { "domain3" }, Role.OWNER);
CreateOrUpdateResult<DomainRoleEntry> result = subject.createOrUpdate(updatedEntry);
flushAndClear();
assertNotNull(result);
assertEquals(ChangeType.UPDATE, result.getChangeType());
assertEquals(userId, result.getEntry().getUid());
assertEquals(Role.OWNER, result.getEntry().getRole());
assertNotNull(result.getEntry().getRole());
assertEquals(1, result.getEntry().getDomains().length);
assertEquals("domain3", result.getEntry().getDomains()[0]);
}
use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.
the class DomainRoleEntryManagerTest method testRemoveExistingEntry.
@Test
public void testRemoveExistingEntry() {
String userId = "user";
create(userId, Sets.newHashSet(), Role.OWNER);
flushAndClear();
DomainRoleEntry result = subject.removeByUserIdAndRole(userId, Role.OWNER);
flushAndClear();
assertNotNull(result);
DomainRoleEntry[] byUserId = subject.findByUserId(userId);
assertNotNull(byUserId);
assertEquals(0, byUserId.length);
}
use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.
the class GlobalDomainAccessStoreAdminEhCache method getAllDomainRoleEntries.
@Override
public List<DomainRoleEntry> getAllDomainRoleEntries() {
List<DomainRoleEntry> result = Lists.newArrayList();
Cache roleCache = getCache(CacheId.DOMAIN_ROLES);
Map<Object, Element> roleMap = roleCache.getAll(roleCache.getKeys());
Iterator<Map.Entry<Object, Element>> iterator = roleMap.entrySet().iterator();
while (iterator.hasNext()) {
Element thisElement = iterator.next().getValue();
DomainRoleEntry objectValue = getElementValue(thisElement);
result.add(objectValue);
}
return result;
}
use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.
the class GlobalDomainRoleControllerProviderImpl method removeDomainRole.
@Override
public Promise<RemoveDomainRoleDeferred> removeDomainRole(String uid, Role role) {
RemoveDomainRoleDeferred deferred = new RemoveDomainRoleDeferred();
boolean removeSuccess = domainAccessStore.removeDomainRole(uid, role);
if (removeSuccess) {
// To notify DRE removal only primary keys (user ID and role) must
// be set. All other fields are undefined.
DomainRoleEntry removedEntry = new DomainRoleEntry(uid, null, role);
fireDomainRoleEntryChanged(ChangeType.REMOVE, removedEntry);
}
deferred.resolve(removeSuccess);
return new Promise<RemoveDomainRoleDeferred>(deferred);
}
Aggregations