Search in sources :

Example 21 with UserTaskInstance

use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.

the class KogitoRuntimeClientTest method testUpdateUserTaskInstance.

@Test
public void testUpdateUserTaskInstance() {
    setupIdentityMock();
    when(webClientMock.patch(any())).thenReturn(httpRequestMock);
    UserTaskInstance taskInstance = createUserTaskInstance(PROCESS_INSTANCE_ID, TASK_ID, "InProgress");
    Map taskInfo = new HashMap();
    taskInfo.put("description", "NewDescription");
    client.updateUserTaskInstance(SERVICE_URL, taskInstance, "jdoe", Collections.singletonList("managers"), taskInfo);
    ArgumentCaptor<JsonObject> jsonCaptor = ArgumentCaptor.forClass(JsonObject.class);
    verify(client).sendPatchClientRequest(eq(webClientMock), eq("/management/processes/travels/instances/" + PROCESS_INSTANCE_ID + "/tasks/" + TASK_ID + "?user=jdoe&group=managers"), eq("Update user task instance:" + taskInstance.getName() + " with id: " + taskInstance.getId()), jsonCaptor.capture());
    assertThat(jsonCaptor.getValue().getString("description")).isEqualTo("NewDescription");
    ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
    JsonObject jsonOject = new JsonObject(taskInfo);
    verify(httpRequestMock).sendJson(eq(jsonOject), handlerCaptor.capture());
    verify(httpRequestMock).putHeader(eq("Authorization"), eq("Bearer " + AUTHORIZED_TOKEN));
    checkResponseHandling(handlerCaptor.getValue());
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) HashMap(java.util.HashMap) JsonObject(io.vertx.core.json.JsonObject) Handler(io.vertx.core.Handler) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 22 with UserTaskInstance

use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.

the class AbstractGraphQLRuntimesQueriesIT method testUpdateUserTaskInstance.

@Test
void testUpdateUserTaskInstance() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    String newDescription = "NewDescription";
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"mutation { UserTaskInstanceUpdate ( " + "taskId: \\\"" + taskId + "\\\"," + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "description:  \\\"" + newDescription + "\\\"" + ")}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    ArgumentCaptor<Map> taskInfoCaptor = ArgumentCaptor.forClass(Map.class);
    verify(dataIndexApiClient).updateUserTaskInstance(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), taskInfoCaptor.capture());
    assertThat(taskInfoCaptor.getValue().get("description")).isEqualTo(newDescription);
    assertUserTaskInstance(userTaskInstanceCaptor.getValue(), taskId, processId, processInstanceId, user);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 23 with UserTaskInstance

use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.

the class AbstractGraphQLRuntimesQueriesIT method testCreateTaskComment.

@Test
void testCreateTaskComment() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    String comment = "Comment to add";
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"mutation{ UserTaskInstanceCommentCreate(" + "taskId: \\\"" + taskId + "\\\", " + "user: \\\"" + user + "\\\", " + "groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"]," + "comment: \\\"" + comment + "\\\" " + ")}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    verify(dataIndexApiClient).createUserTaskInstanceComment(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups), eq(comment));
    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 24 with UserTaskInstance

use of org.kie.kogito.index.model.UserTaskInstance 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 25 with UserTaskInstance

use of org.kie.kogito.index.model.UserTaskInstance 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)

Aggregations

UserTaskInstance (org.kie.kogito.index.model.UserTaskInstance)35 Test (org.junit.jupiter.api.Test)24 Handler (io.vertx.core.Handler)8 UserTaskInstanceDataEvent (org.kie.kogito.event.process.UserTaskInstanceDataEvent)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 QuarkusTest (io.quarkus.test.junit.QuarkusTest)5 UserTaskInstanceEventBody (org.kie.kogito.event.process.UserTaskInstanceEventBody)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 JsonObject (io.vertx.core.json.JsonObject)3 Map (java.util.Map)3 Attachment (org.kie.kogito.index.model.Attachment)3 Comment (org.kie.kogito.index.model.Comment)3 Transactional (javax.transaction.Transactional)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DataFetcher (graphql.schema.DataFetcher)1 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)1 GraphQLInputObjectType (graphql.schema.GraphQLInputObjectType)1 GraphQLNamedType (graphql.schema.GraphQLNamedType)1 GraphQLScalarType (graphql.schema.GraphQLScalarType)1