Search in sources :

Example 1 with ChangeType

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);
        }
    }
}
Also used : Function(java.util.function.Function) ControlEntryType(io.joynr.accesscontrol.global.jee.persistence.ControlEntryType) Consumer(java.util.function.Consumer) ChangeType(joynr.infrastructure.DacTypes.ChangeType) HashMap(java.util.HashMap) MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry) Test(org.junit.Test)

Example 2 with ChangeType

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));
    }
}
Also used : ChangeType(joynr.infrastructure.DacTypes.ChangeType) OwnerRegistrationControlEntry(joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry) Test(org.junit.Test)

Aggregations

ChangeType (joynr.infrastructure.DacTypes.ChangeType)2 Test (org.junit.Test)2 ControlEntryType (io.joynr.accesscontrol.global.jee.persistence.ControlEntryType)1 HashMap (java.util.HashMap)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 MasterRegistrationControlEntry (joynr.infrastructure.DacTypes.MasterRegistrationControlEntry)1 OwnerRegistrationControlEntry (joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry)1