Search in sources :

Example 26 with UserTaskInstance

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

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

the class AbstractGraphQLRuntimesQueriesIT method testGetTaskSchema.

@Test
void testGetTaskSchema() {
    String processInstanceId = UUID.randomUUID().toString();
    String taskId = UUID.randomUUID().toString();
    UserTaskInstanceDataEvent event = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "InProgress", user);
    indexUserTaskCloudEvent(event);
    checkOkResponse("{ \"query\" : \"{UserTaskInstances (where: {id: {equal:\\\"" + taskId + "\\\" }}){ " + "schema ( user: \\\"" + user + "\\\", groups: [\\\"managers\\\", \\\"users\\\", \\\"IT\\\"] )" + "}}\"}");
    ArgumentCaptor<UserTaskInstance> userTaskInstanceCaptor = ArgumentCaptor.forClass(UserTaskInstance.class);
    verify(dataIndexApiClient).getUserTaskSchema(eq("http://localhost:8080"), userTaskInstanceCaptor.capture(), eq(user), eq(groups));
    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 28 with UserTaskInstance

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

Example 29 with UserTaskInstance

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

the class KogitoRuntimeClientTest method testGetUserTaskSchema.

@Test
public void testGetUserTaskSchema() {
    setupIdentityMock();
    when(webClientMock.get(any())).thenReturn(httpRequestMock);
    UserTaskInstance taskInstance = createUserTaskInstance(PROCESS_INSTANCE_ID, TASK_ID, "InProgress");
    client.getUserTaskSchema(SERVICE_URL, taskInstance, "jdoe", Collections.singletonList("managers"));
    verify(client).sendGetClientRequest(webClientMock, "/travels/" + PROCESS_INSTANCE_ID + "/TaskName/" + TASK_ID + "/schema?user=jdoe&group=managers", "Get User Task schema for task:TaskName with id: " + taskInstance.getId(), null);
    ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
    verify(httpRequestMock).send(handlerCaptor.capture());
    verify(httpRequestMock).putHeader(eq("Authorization"), eq("Bearer " + AUTHORIZED_TOKEN));
    checkResponseHandling(handlerCaptor.getValue());
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) Handler(io.vertx.core.Handler) Test(org.junit.jupiter.api.Test)

Example 30 with UserTaskInstance

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

the class KogitoRuntimeClientTest method testCreateUserTaskInstanceAttachment.

@Test
public void testCreateUserTaskInstanceAttachment() {
    String attachmentUri = "nhttps://drive.google.com/file/d/AttachmentUri";
    String attachmentName = "newAttachmentName";
    setupIdentityMock();
    when(webClientMock.post(any())).thenReturn(httpRequestMock);
    when(httpRequestMock.putHeader(eq("Content-Type"), anyString())).thenReturn(httpRequestMock);
    UserTaskInstance taskInstance = createUserTaskInstance(PROCESS_INSTANCE_ID, TASK_ID, "InProgress");
    client.createUserTaskInstanceAttachment(SERVICE_URL, taskInstance, "jdoe", Collections.singletonList("managers"), attachmentName, attachmentUri);
    verify(client).sendPostWithBodyClientRequest(eq(webClientMock), eq("/travels/" + PROCESS_INSTANCE_ID + "/" + taskInstance.getName() + "/" + TASK_ID + "/attachments?user=jdoe&group=managers"), eq("Adding attachment to  UserTask:" + taskInstance.getName() + " with id: " + taskInstance.getId()), eq("{ \"name\": \"" + attachmentName + "\", \"uri\": \"" + attachmentUri + "\" }"), eq("application/json"));
    ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
    JsonObject jsonObject = new JsonObject("{ \"name\": \"" + attachmentName + "\", \"uri\": \"" + attachmentUri + "\" }");
    verify(httpRequestMock).sendJson(eq(jsonObject), handlerCaptor.capture());
    checkResponseHandling(handlerCaptor.getValue());
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) Handler(io.vertx.core.Handler) JsonObject(io.vertx.core.json.JsonObject) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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