use of org.kie.kogito.services.event.UserTaskInstanceDataEvent in project kogito-runtimes by kiegroup.
the class PublishEventIT method assertUserTaskInstanceEvent.
protected UserTaskInstanceEventBody assertUserTaskInstanceEvent(DataEvent<?> event, String taskName, String taskDescription, String taskPriority, String taskState, String processId, String nodeName) {
assertThat(event).isInstanceOf(UserTaskInstanceDataEvent.class);
UserTaskInstanceEventBody body = ((UserTaskInstanceDataEvent) event).getData();
assertThat(body).isNotNull();
assertThat(body.getId()).isNotNull();
assertThat(body.getTaskName()).isEqualTo(taskName);
assertThat(body.getTaskDescription()).isEqualTo(taskDescription);
assertThat(body.getReferenceName()).isEqualTo(nodeName);
assertThat(body.getTaskPriority()).isEqualTo(taskPriority);
assertThat(body.getStartDate()).isNotNull();
assertThat(body.getState()).isEqualTo(taskState);
if (taskState.equals("Completed") || taskState.equals("Aborted")) {
assertThat(body.getCompleteDate()).isNotNull();
} else {
assertThat(body.getCompleteDate()).isNull();
}
assertThat(event.getSource().toString()).isEqualTo("http://myhost/" + processId);
assertThat(event.getTime()).isBeforeOrEqualTo(ZonedDateTime.now().toOffsetDateTime());
assertThat(((UserTaskInstanceDataEvent) event).getKogitoAddons()).isEqualTo("test");
return body;
}
use of org.kie.kogito.services.event.UserTaskInstanceDataEvent in project kogito-runtimes by kiegroup.
the class MongoDBEventPublisherTest method testPublishEvents_withTransaction.
@Test
void testPublishEvents_withTransaction() {
ClientSession clientSession = mock(ClientSession.class);
when(transactionManager.getClientSession()).thenReturn(clientSession);
when(transactionManager.enabled()).thenReturn(true);
publisher.configure();
List<DataEvent<?>> events = new ArrayList<>();
events.add(processInstanceDataEvent);
events.add(userTaskInstanceDataEvent);
events.add(variableInstanceDataEvent);
events.add(event);
publisher.publish(events);
verify(mongoCollection, times(3)).insertOne(eq(clientSession), any(AbstractDataEvent.class));
verify(mongoCollection, times(3)).deleteOne(eq(clientSession), any());
verify(mongoCollection).insertOne(eq(clientSession), eq(processInstanceDataEvent));
verify(mongoCollection).deleteOne(eq(clientSession), eq(Filters.eq(ID, "testProcessInstanceEvent")));
verify(mongoCollection).insertOne(eq(clientSession), eq(userTaskInstanceDataEvent));
verify(mongoCollection).deleteOne(eq(clientSession), eq(Filters.eq(ID, "testUserTaskInstanceEvent")));
verify(mongoCollection).insertOne(eq(clientSession), eq(variableInstanceDataEvent));
verify(mongoCollection).deleteOne(eq(clientSession), eq(Filters.eq(ID, "testVariableInstanceEvent")));
}
use of org.kie.kogito.services.event.UserTaskInstanceDataEvent in project kogito-runtimes by kiegroup.
the class UserTaskInstanceDataEventCodecTest method setUp.
@BeforeEach
void setUp() {
codec = new UserTaskInstanceDataEventCodec();
String source = "testSource";
String kogitoAddons = "testKogitoAddons";
Comment comment = new Comment("testCommentId", "testCommentUpdatedBy");
comment.setContent("testCommentContent");
comment.setUpdatedAt(new Date());
Set<Comment> comments = Collections.singleton(comment);
Attachment attachment = new Attachment("testAttachmentId", "testAttachmentUpdatedBy");
attachment.setContent(URI.create("test.attachment.test"));
attachment.setName("testAttachmentName");
attachment.setUpdatedAt(new Date());
Set<Attachment> attachments = Collections.singleton(attachment);
Map<String, String> metaData = new HashMap<>();
metaData.put(ProcessInstanceEventBody.ID_META_DATA, "testKogitoProcessinstanceId");
metaData.put(ProcessInstanceEventBody.ROOT_ID_META_DATA, "testKogitoRootProcessinstanceId");
metaData.put(ProcessInstanceEventBody.PROCESS_ID_META_DATA, "testKogitoProcessId");
metaData.put(ProcessInstanceEventBody.ROOT_PROCESS_ID_META_DATA, "testKogitoRootProcessId");
metaData.put(UserTaskInstanceEventBody.UT_STATE_META_DATA, "testKogitoUserTaskinstanceState");
metaData.put(UserTaskInstanceEventBody.UT_ID_META_DATA, "testKogitoUserTaskinstanceId");
UserTaskInstanceEventBody body = UserTaskInstanceEventBody.create().id("testId").taskName("testTaskName").taskDescription("testTaskDescription").taskPriority("testTaskPriority").referenceName("testReferenceName").startDate(new Date()).completeDate(new Date()).state("testState").actualOwner("testActualOwner").potentialUsers(Collections.singleton("testPotentialUsers")).potentialGroups(Collections.singleton("testPotentialGroups")).excludedUsers(Collections.singleton("testExcludedUsers")).adminUsers(Collections.singleton("testAdminUsers")).adminGroups(Collections.singleton("testAdminGroups")).inputs(Collections.singletonMap("testInputsKey", "testInputsValue")).outputs(Collections.singletonMap("testOutputsKey", "testOutputsValue")).processInstanceId("testKogitoProcessinstanceId").rootProcessInstanceId("testKogitoRootProcessinstanceId").processId("testKogitoProcessId").rootProcessId("testKogitoRootProcessId").comments(comments).attachments(attachments).build();
event = new UserTaskInstanceDataEvent(source, kogitoAddons, metaData, body);
}
use of org.kie.kogito.services.event.UserTaskInstanceDataEvent in project kogito-runtimes by kiegroup.
the class ProcessInstanceEventBatch method events.
@Override
public Collection<DataEvent<?>> events() {
Map<String, ProcessInstanceEventBody> processInstances = new LinkedHashMap<>();
Map<String, UserTaskInstanceEventBody> userTaskInstances = new LinkedHashMap<>();
Set<VariableInstanceEventBody> variables = new LinkedHashSet<>();
Collection<DataEvent<?>> processedEvents = new ArrayList<>();
for (ProcessEvent event : rawEvents) {
ProcessInstanceEventBody body = processInstances.computeIfAbsent(((KogitoProcessInstance) event.getProcessInstance()).getStringId(), key -> create(event));
if (event instanceof ProcessNodeTriggeredEvent) {
handleProcessNodeTriggeredEvent((ProcessNodeTriggeredEvent) event, body);
} else if (event instanceof ProcessNodeLeftEvent) {
handleProcessNodeLeftEvent((ProcessNodeLeftEvent) event, body);
} else if (event instanceof ProcessCompletedEvent) {
handleProcessCompletedEvent((ProcessCompletedEvent) event, body);
} else if (event instanceof ProcessWorkItemTransitionEvent) {
handleProcessWorkItemTransitionEvent((ProcessWorkItemTransitionEvent) event, userTaskInstances);
} else if (event instanceof ProcessVariableChangedEvent) {
handleProcessVariableChangedEvent((KogitoProcessVariableChangedEvent) event, variables);
} else if (event instanceof HumanTaskDeadlineEvent) {
processedEvents.add(buildUserTaskDeadlineEvent((HumanTaskDeadlineEvent) event));
}
}
processInstances.values().stream().map(pi -> new ProcessInstanceDataEvent(extractRuntimeSource(pi.metaData()), addons.toString(), pi.metaData(), pi)).forEach(processedEvents::add);
userTaskInstances.values().stream().map(pi -> new UserTaskInstanceDataEvent(extractRuntimeSource(pi.metaData()), addons.toString(), pi.metaData(), pi)).forEach(processedEvents::add);
variables.stream().map(pi -> new VariableInstanceDataEvent(extractRuntimeSource(pi.metaData()), addons.toString(), pi.metaData(), pi)).forEach(processedEvents::add);
return processedEvents;
}
Aggregations