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());
}
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());
}
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;
}
Aggregations