use of joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBean method updateOwnerRegistrationControlEntry.
@Override
public Boolean updateOwnerRegistrationControlEntry(OwnerRegistrationControlEntry updatedOwnerRce) {
CreateOrUpdateResult<OwnerRegistrationControlEntry> result = ownerRegistrationControlEntryManager.createOrUpdate(updatedOwnerRce);
if (result != null) {
OwnerRegistrationControlEntry entry = result.getEntry();
globalDomainAccessControllerBean.doFireOwnerRegistrationControlEntryChanged(result.getChangeType(), entry);
return true;
}
return false;
}
use of joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry in project joynr by bmwcarit.
the class OwnerRegistrationControlEntryManagerTest method testRemove.
@Test
public void testRemove() {
String userId = "user";
String domain = "domain";
String interfaceName = "interfaceName";
OwnerRegistrationControlEntryEntity entity = create(userId, domain, interfaceName, TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
flushAndClear();
OwnerRegistrationControlEntry removedEntry = subject.removeByUserIdDomainAndInterfaceName(userId, domain, interfaceName);
assertNotNull(removedEntry);
assertEquals(userId, removedEntry.getUid());
flushAndClear();
OwnerRegistrationControlEntryEntity persisted = entityManager.find(OwnerRegistrationControlEntryEntity.class, entity.getId());
assertNull(persisted);
}
use of joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry in project joynr by bmwcarit.
the class OwnerRegistrationControlEntryManagerTest method testCreateNotAllowedWithoutOwnerRole.
@Test
public void testCreateNotAllowedWithoutOwnerRole() {
String userId = "user";
String domain = "domain";
String interfaceName = "interfaceName";
OwnerRegistrationControlEntry data = new OwnerRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.MASTER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
CreateOrUpdateResult<OwnerRegistrationControlEntry> result = null;
JoynrJeeMessageContext.getInstance().activate();
try {
joynrCallingPrincipal.setUsername(userId);
result = subject.createOrUpdate(data);
} finally {
JoynrJeeMessageContext.getInstance().deactivate();
}
assertNull(result);
flushAndClear();
OwnerRegistrationControlEntry[] persisted = subject.findByUserId(userId);
assertNotNull(persisted);
assertEquals(0, persisted.length);
}
use of joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry in project joynr by bmwcarit.
the class OwnerRegistrationControlEntryManagerTest method testUpdate.
@Test
public void testUpdate() {
String userId = "user";
String domain = "domain";
String interfaceName = "interfaceName";
OwnerRegistrationControlEntryEntity entity = create(userId, domain, interfaceName, TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
flushAndClear();
OwnerRegistrationControlEntry updatedData = new OwnerRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.LOW, Permission.NO);
CreateOrUpdateResult<OwnerRegistrationControlEntry> result = subject.createOrUpdate(updatedData);
assertNotNull(result);
assertEquals(ChangeType.UPDATE, result.getChangeType());
assertNotNull(result.getEntry());
assertEquals(userId, result.getEntry().getUid());
flushAndClear();
OwnerRegistrationControlEntryEntity persisted = entityManager.find(OwnerRegistrationControlEntryEntity.class, entity.getId());
assertNotNull(persisted);
assertEquals(TrustLevel.HIGH, persisted.getRequiredTrustLevel());
assertEquals(TrustLevel.LOW, persisted.getRequiredAceChangeTrustLevel());
assertEquals(Permission.NO, persisted.getProviderPermission());
}
use of joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testCreateAndUpdateOwnerRegistrationControlEntry.
@Test
public void testCreateAndUpdateOwnerRegistrationControlEntry() {
for (ChangeType changeType : new ChangeType[] { ChangeType.ADD, ChangeType.UPDATE }) {
reset(ownerRegistrationControlEntryManagerMock);
OwnerRegistrationControlEntry orce = new OwnerRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.HIGH, TrustLevel.LOW, Permission.ASK);
when(ownerRegistrationControlEntryManagerMock.createOrUpdate(orce)).thenReturn(new CreateOrUpdateResult<OwnerRegistrationControlEntry>(orce, changeType));
assertTrue(globalDomainAccessControlListEditorSubject.updateOwnerRegistrationControlEntry(orce));
verify(ownerRegistrationControlEntryManagerMock).createOrUpdate(eq(orce));
verify(globalDomainAccessControllerBeanMock).doFireOwnerRegistrationControlEntryChanged(eq(changeType), eq(orce));
}
}
Aggregations