use of joynr.infrastructure.DacTypes.ChangeType in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testCreateAndUpdateMasterAndMediatorRegistrationControlEntry.
@Test
public void testCreateAndUpdateMasterAndMediatorRegistrationControlEntry() {
for (ChangeType changeType : new ChangeType[] { ChangeType.ADD, ChangeType.UPDATE }) {
Map<ControlEntryType, Function<MasterRegistrationControlEntry, Boolean>> globalDomainAccessControllerSubjectCalls = new HashMap<>();
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MASTER, (updatedEntry) -> {
return globalDomainAccessControlListEditorSubject.updateMasterRegistrationControlEntry(updatedEntry);
});
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MEDIATOR, (updatedEntry) -> {
return globalDomainAccessControlListEditorSubject.updateMediatorRegistrationControlEntry(updatedEntry);
});
Map<ControlEntryType, Consumer<MasterRegistrationControlEntry>> multicastVerifiers = new HashMap<>();
multicastVerifiers.put(ControlEntryType.MASTER, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMasterRegistrationControlEntryChanged(eq(changeType), eq(mrce));
});
multicastVerifiers.put(ControlEntryType.MEDIATOR, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMediatorRegistrationControlEntryChanged(eq(changeType), eq(mrce));
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
reset(masterRegistrationControlEntryManagerMock);
// reset(globalDomainAccessControllerSubscriptionPublisherMock);
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.createOrUpdate(mrce, type)).thenReturn(new CreateOrUpdateResult<MasterRegistrationControlEntry>(mrce, changeType));
assertTrue(globalDomainAccessControllerSubjectCalls.get(type).apply(mrce));
verify(masterRegistrationControlEntryManagerMock).createOrUpdate(mrce, type);
multicastVerifiers.get(type).accept(mrce);
}
}
}
use of joynr.infrastructure.DacTypes.ChangeType 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