use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBean method updateMediatorRegistrationControlEntry.
@Override
public Boolean updateMediatorRegistrationControlEntry(MasterRegistrationControlEntry updatedMediatorRce) {
CreateOrUpdateResult<MasterRegistrationControlEntry> result = masterRegistrationControlEntryManager.createOrUpdate(updatedMediatorRce, ControlEntryType.MEDIATOR);
if (result != null) {
MasterRegistrationControlEntry entry = result.getEntry();
globalDomainAccessControllerBean.doFireMediatorRegistrationControlEntryChanged(result.getChangeType(), entry);
return true;
}
return false;
}
use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testFindEditableMasterAndMediatorRegistrationControlEntryByUserId.
@Test
public void testFindEditableMasterAndMediatorRegistrationControlEntryByUserId() {
Map<ControlEntryType, Function<String, MasterRegistrationControlEntry[]>> getters = new HashMap<>();
getters.put(ControlEntryType.MASTER, (String userId) -> {
return globalDomainAccessControlListEditorSubject.getEditableMasterRegistrationControlEntries(userId);
});
getters.put(ControlEntryType.MEDIATOR, (String userId) -> {
return globalDomainAccessControlListEditorSubject.getEditableMediatorRegistrationControlEntries(userId);
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
when(masterRegistrationControlEntryManagerMock.findByUserIdAndThatAreEditable(USER_ID, type)).thenReturn(new MasterRegistrationControlEntry[0]);
MasterRegistrationControlEntry[] result = getters.get(type).apply(USER_ID);
assertNotNull(result);
assertEquals(0, result.length);
verify(masterRegistrationControlEntryManagerMock).findByUserIdAndThatAreEditable(eq(USER_ID), eq(type));
}
}
use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.
the class MasterRegistrationControlEntryManagerTest method testUpdate.
@Test
public void testUpdate() {
String userId = "user";
String domain = "domain1";
String interfaceName = "interfaceName1";
MasterRegistrationControlEntryEntity entity = create(userId, domain, interfaceName, TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], Permission.YES, new Permission[0], ControlEntryType.MASTER);
flushAndClear();
MasterRegistrationControlEntry updatedData = new MasterRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.HIGH }, TrustLevel.HIGH, new TrustLevel[0], Permission.ASK, new Permission[] { Permission.NO });
CreateOrUpdateResult<MasterRegistrationControlEntry> result = subject.createOrUpdate(updatedData, ControlEntryType.MASTER);
assertNotNull(result);
assertEquals(ChangeType.UPDATE, result.getChangeType());
assertNotNull(result.getEntry());
assertEquals(userId, result.getEntry().getUid());
flushAndClear();
MasterRegistrationControlEntryEntity persisted = entityManager.find(MasterRegistrationControlEntryEntity.class, entity.getId());
assertNotNull(persisted);
assertEquals(TrustLevel.LOW, persisted.getDefaultRequiredTrustLevel());
assertEquals(2, persisted.getPossibleRequiredTrustLevels().size());
assertEquals(TrustLevel.HIGH, persisted.getDefaultRequiredControlEntryChangeTrustLevel());
assertEquals(Permission.ASK, persisted.getDefaultProviderPermission());
}
use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControllerBeanTest method testFindMasterAndMediatorRegistrationControlEntryByUserId.
@Test
public void testFindMasterAndMediatorRegistrationControlEntryByUserId() {
Map<ControlEntryType, Function<String, MasterRegistrationControlEntry[]>> getters = new HashMap<>();
getters.put(ControlEntryType.MASTER, (String userId) -> {
return globalDomainAccessControllerSubject.getMasterRegistrationControlEntries(userId);
});
getters.put(ControlEntryType.MEDIATOR, (String userId) -> {
return globalDomainAccessControllerSubject.getMediatorRegistrationControlEntries(userId);
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
when(masterRegistrationControlEntryManagerMock.findByUserIdAndType(USER_ID, type)).thenReturn(new MasterRegistrationControlEntry[0]);
MasterRegistrationControlEntry[] result = getters.get(type).apply(USER_ID);
assertNotNull(result);
assertEquals(0, result.length);
verify(masterRegistrationControlEntryManagerMock).findByUserIdAndType(eq(USER_ID), eq(type));
}
}
use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testRemoveMasterAndMediatorRegistrationControlEntry.
@Test
public void testRemoveMasterAndMediatorRegistrationControlEntry() {
Map<ControlEntryType, Supplier<Boolean>> globalDomainAccessControllerSubjectCalls = new HashMap<>();
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MASTER, () -> {
return globalDomainAccessControlListEditorSubject.removeMasterRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME);
});
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MEDIATOR, () -> {
return globalDomainAccessControlListEditorSubject.removeMediatorRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME);
});
Map<ControlEntryType, Consumer<MasterRegistrationControlEntry>> multicastVerifiers = new HashMap<>();
multicastVerifiers.put(ControlEntryType.MASTER, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMasterRegistrationControlEntryChanged(eq(ChangeType.REMOVE), eq(mrce));
});
multicastVerifiers.put(ControlEntryType.MEDIATOR, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMediatorRegistrationControlEntryChanged(eq(ChangeType.REMOVE), eq(mrce));
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
MasterRegistrationControlEntry mrce = new MasterRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.LOW, new TrustLevel[0], TrustLevel.HIGH, new TrustLevel[0], Permission.ASK, new Permission[0]);
when(masterRegistrationControlEntryManagerMock.removeByUserIdDomainInterfaceNameAndType(USER_ID, DOMAIN, INTERFACE_NAME, type)).thenReturn(mrce);
assertTrue(globalDomainAccessControllerSubjectCalls.get(type).get());
verify(masterRegistrationControlEntryManagerMock).removeByUserIdDomainInterfaceNameAndType(eq(USER_ID), eq(DOMAIN), eq(INTERFACE_NAME), eq(type));
multicastVerifiers.get(type).accept(mrce);
}
}
Aggregations