Search in sources :

Example 16 with CoreEvent

use of eu.bcvsolutions.idm.core.api.event.CoreEvent in project CzechIdMng by bcvsolutions.

the class DefaultEntityEventManagerIntergationTest method testEventGreenLine.

@Test
public void testEventGreenLine() {
    EntityEvent<TestContent> event = new CoreEvent<>(CoreEventType.CREATE, new TestContent());
    EventContext<TestContent> context = entityEventManager.process(event);
    // 
    assertEquals(4, context.getResults().size());
    assertEquals(4, context.getProcessedOrder().intValue());
    assertEquals("4", context.getLastResult().getEvent().getContent().getText());
}
Also used : CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) TestContent(eu.bcvsolutions.idm.core.event.TestContent) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 17 with CoreEvent

use of eu.bcvsolutions.idm.core.api.event.CoreEvent in project CzechIdMng by bcvsolutions.

the class DefaultEntityEventManagerIntergationTest method testConditionalProcessor.

@Test
public void testConditionalProcessor() {
    EntityEvent<ConditionalContent> event = new CoreEvent<>(CoreEventType.CREATE, new ConditionalContent(false));
    EventContext<ConditionalContent> context = entityEventManager.process(event);
    // 
    assertEquals(0, context.getResults().size());
    // 
    event = new CoreEvent<>(CoreEventType.CREATE, new ConditionalContent(true));
    context = entityEventManager.process(event);
    // 
    assertEquals(1, context.getResults().size());
}
Also used : ConditionalContent(eu.bcvsolutions.idm.core.event.ConditionalContent) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 18 with CoreEvent

use of eu.bcvsolutions.idm.core.api.event.CoreEvent in project CzechIdMng by bcvsolutions.

the class DefaultEntityEventManager method toEvent.

@Override
public EntityEvent<Identifiable> toEvent(IdmEntityEventDto entityEvent) {
    Identifiable content = null;
    // only if type and id is the same as owner can be used
    if (entityEvent.getContent() != null && entityEvent.getContent().getClass().getCanonicalName().equals(entityEvent.getOwnerType()) && entityEvent.getContent().getId().equals(entityEvent.getOwnerId())) {
        content = entityEvent.getContent();
    }
    if (content == null) {
        // content is not persisted - try to find actual entity
        content = findOwner(entityEvent);
    }
    if (content == null) {
        throw new EventContentDeletedException(entityEvent);
    }
    // 
    Map<String, Serializable> eventProperties = entityEvent.getProperties().toMap();
    eventProperties.put(EVENT_PROPERTY_EVENT_ID, entityEvent.getId());
    eventProperties.put(EVENT_PROPERTY_PRIORITY, entityEvent.getPriority());
    eventProperties.put(EVENT_PROPERTY_EXECUTE_DATE, entityEvent.getExecuteDate());
    eventProperties.put(EVENT_PROPERTY_PARENT_EVENT_TYPE, entityEvent.getParentEventType());
    final String type = entityEvent.getEventType();
    DefaultEventContext<Identifiable> initContext = new DefaultEventContext<>();
    initContext.setProcessedOrder(entityEvent.getProcessedOrder());
    EventType eventType = (EventType) () -> type;
    EntityEvent<Identifiable> resurectedEvent = new CoreEvent<>(eventType, content, eventProperties, initContext);
    resurectedEvent.setOriginalSource(entityEvent.getOriginalSource());
    // 
    return resurectedEvent;
}
Also used : Serializable(java.io.Serializable) EventType(eu.bcvsolutions.idm.core.api.event.EventType) EntityEventType(eu.bcvsolutions.idm.core.api.event.EntityEventEvent.EntityEventType) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) DefaultEventContext(eu.bcvsolutions.idm.core.api.event.DefaultEventContext) EventContentDeletedException(eu.bcvsolutions.idm.core.api.exception.EventContentDeletedException) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable)

Aggregations

CoreEvent (eu.bcvsolutions.idm.core.api.event.CoreEvent)18 Test (org.junit.Test)11 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 TestContent (eu.bcvsolutions.idm.core.event.TestContent)5 CoreEventType (eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType)4 IntrospectionException (java.beans.IntrospectionException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)3 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 EventType (eu.bcvsolutions.idm.core.api.event.EventType)3 IdentityEvent (eu.bcvsolutions.idm.core.model.event.IdentityEvent)3 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)3 AbstractVerifiableUnitTest (eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest)3 UUID (java.util.UUID)3 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)2 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)2 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)2 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)2 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)2