use of org.kie.kogito.event.process.UserTaskInstanceDataEvent in project kogito-apps by kiegroup.
the class AbstractGraphQLRuntimesQueriesIT method testCreateTaskAttachment.
@Test
void testCreateTaskAttachment() {
String processInstanceId = UUID.randomUUID().toString();
String taskId = UUID.randomUUID().toString();
String attachmentName = "attachment name";
String attachmentUri = "https://drive.google.com/file/d/1Z_Lipg2jzY9TNewTaskAttachmentUri";
UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
indexUserTaskCloudEvent(event);
checkOkResponse("{ \"query\" : \"mutation{ UserTaskInstanceAttachmentCreate(" + "taskId: \\\"" + taskId + "\\\", " + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "name: \\\"" + attachmentName + "\\\", " + "uri: \\\"" + attachmentUri + "\\\" " + ")}\"}");
ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
verify(dataIndexApiClient).createUserTaskInstanceAttachment(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), eq(attachmentName), eq(attachmentUri));
assertUserTaskInstance(userTaskInstanceCaptor.getValue(), taskId, processId, processInstanceId, user);
}
use of org.kie.kogito.event.process.UserTaskInstanceDataEvent in project kogito-apps by kiegroup.
the class UserTaskInstanceMetaMapperTest method testUserTaskInstanceMapper.
@Test
public void testUserTaskInstanceMapper() {
String taskId = UUID.randomUUID().toString();
String processId = "travels";
String rootProcessId = "root_travels";
String processInstanceId = UUID.randomUUID().toString();
String rootProcessInstanceId = UUID.randomUUID().toString();
String utPrefix = KOGITO_DOMAIN_ATTRIBUTE + "." + USER_TASK_INSTANCES_DOMAIN_ATTRIBUTE;
UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, rootProcessInstanceId, rootProcessId, "InProgress");
ObjectNode json = new UserTaskInstanceMetaMapper().apply(event);
assertThat(json).isNotNull();
assertThatJson(json.toString()).and(a -> a.node("id").isEqualTo(rootProcessInstanceId), a -> a.node("processId").isEqualTo(rootProcessId), a -> a.node(KOGITO_DOMAIN_ATTRIBUTE).isNotNull(), a -> a.node(KOGITO_DOMAIN_ATTRIBUTE + ".lastUpdate").isEqualTo(event.getTime().toInstant().toEpochMilli()), a -> a.node(utPrefix).isArray().hasSize(1), a -> a.node(utPrefix + "[0].id").isEqualTo(taskId), a -> a.node(utPrefix + "[0].processInstanceId").isEqualTo(processInstanceId), a -> a.node(utPrefix + "[0].state").isEqualTo(event.getData().getState()), a -> a.node(utPrefix + "[0].description").isEqualTo(event.getData().getTaskDescription()), a -> a.node(utPrefix + "[0].name").isEqualTo(event.getData().getTaskName()), a -> a.node(utPrefix + "[0].priority").isEqualTo(event.getData().getTaskPriority()), a -> a.node(utPrefix + "[0].actualOwner").isEqualTo(event.getData().getActualOwner()), a -> a.node(utPrefix + "[0].adminUsers[0]").isEqualTo(event.getData().getAdminUsers().stream().findFirst().get()), a -> a.node(utPrefix + "[0].adminGroups[0]").isEqualTo(event.getData().getAdminGroups().stream().findFirst().get()), a -> a.node(utPrefix + "[0].excludedUsers[0]").isEqualTo(event.getData().getExcludedUsers().stream().findFirst().get()), a -> a.node(utPrefix + "[0].potentialGroups[0]").isEqualTo(event.getData().getPotentialGroups().stream().findFirst().get()), a -> a.node(utPrefix + "[0].potentialUsers[0]").isEqualTo(event.getData().getPotentialUsers().stream().findFirst().get()), a -> a.node(utPrefix + "[0].started").isEqualTo(event.getData().getStartDate().toInstant().toEpochMilli()), a -> a.node(utPrefix + "[0].completed").isEqualTo(event.getData().getCompleteDate().toInstant().toEpochMilli()), a -> a.node(utPrefix + "[0].lastUpdate").isEqualTo(event.getTime().toInstant().toEpochMilli()));
}
use of org.kie.kogito.event.process.UserTaskInstanceDataEvent in project kogito-apps by kiegroup.
the class DomainEventConsumerTest method testOnUserTaskInstanceDomainEventIndexingException.
@Test
public void testOnUserTaskInstanceDomainEventIndexingException() {
doThrow(new RuntimeException("")).when(service).indexModel(any());
String taskId = UUID.randomUUID().toString();
String processId = "travels";
String processInstanceId = UUID.randomUUID().toString();
UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress");
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> consumer.onDomainEvent(event));
verify(service).indexModel(any());
}
use of org.kie.kogito.event.process.UserTaskInstanceDataEvent in project kogito-apps by kiegroup.
the class DomainEventConsumerTest method testOnUserTaskInstanceDomainEventMappingException.
@Test
public void testOnUserTaskInstanceDomainEventMappingException() {
UserTaskInstanceDataEvent event = mock(UserTaskInstanceDataEvent.class);
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> consumer.onDomainEvent(event));
verify(service, never()).indexModel(any());
}
use of org.kie.kogito.event.process.UserTaskInstanceDataEvent in project kogito-apps by kiegroup.
the class ReactiveMessagingEventConsumerTest method testOnUserTaskInstanceEvent.
@Test
public void testOnUserTaskInstanceEvent() {
String taskId = UUID.randomUUID().toString();
String processId = "travels";
String processInstanceId = UUID.randomUUID().toString();
UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress");
UniAssertSubscriber<Void> future = consumer.onUserTaskInstanceEvent(event).subscribe().withSubscriber(UniAssertSubscriber.create());
future.awaitItem().assertCompleted();
verify(service).indexUserTaskInstance(any());
verify(eventPublisher).fire(event);
}
Aggregations