Search in sources :

Example 1 with UserTaskInstanceDataEvent

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);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 2 with UserTaskInstanceDataEvent

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()));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 3 with UserTaskInstanceDataEvent

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());
}
Also used : UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 4 with UserTaskInstanceDataEvent

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());
}
Also used : UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 5 with UserTaskInstanceDataEvent

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);
}
Also used : UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Aggregations

UserTaskInstanceDataEvent (org.kie.kogito.event.process.UserTaskInstanceDataEvent)26 Test (org.junit.jupiter.api.Test)22 UserTaskInstance (org.kie.kogito.index.model.UserTaskInstance)8 Collection (java.util.Collection)7 UserTaskInstanceEventBody (org.kie.kogito.event.process.UserTaskInstanceEventBody)7 ProcessInstanceDataEvent (org.kie.kogito.event.process.ProcessInstanceDataEvent)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Matchers.emptyOrNullString (org.hamcrest.Matchers.emptyOrNullString)2 DataEvent (org.kie.kogito.event.DataEvent)2 AttachmentEventBody (org.kie.kogito.event.process.AttachmentEventBody)2 CommentEventBody (org.kie.kogito.event.process.CommentEventBody)2 VariableInstanceDataEvent (org.kie.kogito.event.process.VariableInstanceDataEvent)2 ClientSession (com.mongodb.client.ClientSession)1 JsonObject (io.vertx.core.json.JsonObject)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1