Search in sources :

Example 1 with UserTaskInstanceEventBody

use of org.kie.kogito.event.process.UserTaskInstanceEventBody 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;
}
Also used : UserTaskInstanceEventBody(org.kie.kogito.event.process.UserTaskInstanceEventBody) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent)

Example 2 with UserTaskInstanceEventBody

use of org.kie.kogito.event.process.UserTaskInstanceEventBody in project kogito-apps by kiegroup.

the class AbstractGraphQLRuntimesQueriesIT method testDeleteUserTaskInstanceAttachment.

@Test
void testDeleteUserTaskInstanceAttachment() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    String attachmentId = UUID.randomUUID().toString();
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    UserTaskInstanceEventBody userTaskInstance = event.getData();
    userTaskInstance.setAttachments(List.of(getTaskAttachment(attachmentId, null, null, null)));
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"mutation { UserTaskInstanceAttachmentDelete ( " + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "attachmentId:  \\\"" + attachmentId + "\\\"" + ")}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    verify(dataIndexApiClient).deleteUserTaskInstanceAttachment(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), eq(attachmentId));
    assertUserTaskInstance(userTaskInstanceCaptor.getValue(), taskId, processId, processInstanceId, user);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) UserTaskInstanceEventBody(org.kie.kogito.event.process.UserTaskInstanceEventBody) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 3 with UserTaskInstanceEventBody

use of org.kie.kogito.event.process.UserTaskInstanceEventBody in project kogito-apps by kiegroup.

the class AbstractGraphQLRuntimesQueriesIT method testDeleteUserTaskInstanceComment.

@Test
void testDeleteUserTaskInstanceComment() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    String commentId = UUID.randomUUID().toString();
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    UserTaskInstanceEventBody userTaskInstance = event.getData();
    userTaskInstance.setComments(List.of(getTaskComment(commentId, null, null)));
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"mutation { UserTaskInstanceCommentDelete ( " + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "commentId:  \\\"" + commentId + "\\\"" + ")}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    verify(dataIndexApiClient).deleteUserTaskInstanceComment(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), eq(commentId));
    assertUserTaskInstance(userTaskInstanceCaptor.getValue(), taskId, processId, processInstanceId, user);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) UserTaskInstanceEventBody(org.kie.kogito.event.process.UserTaskInstanceEventBody) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 4 with UserTaskInstanceEventBody

use of org.kie.kogito.event.process.UserTaskInstanceEventBody in project kogito-apps by kiegroup.

the class AbstractGraphQLRuntimesQueriesIT method testUpdateUserTaskInstanceAttachment.

@Test
void testUpdateUserTaskInstanceAttachment() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    String attachmentId = UUID.randomUUID().toString();
    String attachmentName = "attachmentName";
    String attachmentUri = "attachmentUri";
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    UserTaskInstanceEventBody userTaskInstance = event.getData();
    userTaskInstance.setAttachments(List.of(getTaskAttachment(attachmentId, null, null, null)));
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"mutation { UserTaskInstanceAttachmentUpdate ( " + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "attachmentId:  \\\"" + attachmentId + "\\\"" + "name:  \\\"" + attachmentName + "\\\"" + "uri:  \\\"" + attachmentUri + "\\\"" + ")}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    verify(dataIndexApiClient).updateUserTaskInstanceAttachment(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), eq(attachmentId), eq(attachmentName), eq(attachmentUri));
    assertUserTaskInstance(userTaskInstanceCaptor.getValue(), taskId, processId, processInstanceId, user);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) UserTaskInstanceEventBody(org.kie.kogito.event.process.UserTaskInstanceEventBody) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Example 5 with UserTaskInstanceEventBody

use of org.kie.kogito.event.process.UserTaskInstanceEventBody in project kogito-apps by kiegroup.

the class AbstractGraphQLRuntimesQueriesIT method testUpdateUserTaskInstanceComment.

@Test
void testUpdateUserTaskInstanceComment() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    String commentId = UUID.randomUUID().toString();
    String commentContent = "commentContent";
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    UserTaskInstanceEventBody userTaskInstance = event.getData();
    userTaskInstance.setComments(List.of(getTaskComment(commentId, null, null)));
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"mutation { UserTaskInstanceCommentUpdate ( " + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "commentId:  \\\"" + commentId + "\\\"" + "comment:  \\\"" + commentContent + "\\\"" + ")}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    verify(dataIndexApiClient).updateUserTaskInstanceComment(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), eq(commentId), eq(commentContent));
    assertUserTaskInstance(userTaskInstanceCaptor.getValue(), taskId, processId, processInstanceId, user);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) UserTaskInstanceEventBody(org.kie.kogito.event.process.UserTaskInstanceEventBody) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Test(org.junit.jupiter.api.Test)

Aggregations

UserTaskInstanceDataEvent (org.kie.kogito.event.process.UserTaskInstanceDataEvent)7 UserTaskInstanceEventBody (org.kie.kogito.event.process.UserTaskInstanceEventBody)7 Test (org.junit.jupiter.api.Test)4 UserTaskInstance (org.kie.kogito.index.model.UserTaskInstance)4 AttachmentEventBody (org.kie.kogito.event.process.AttachmentEventBody)2 CommentEventBody (org.kie.kogito.event.process.CommentEventBody)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 BsonString (org.bson.BsonString)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1