Search in sources :

Example 6 with UserTaskInstance

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

the class UserTaskInstanceEntityMapperTest method testMapToModel.

@Test
void testMapToModel() {
    UserTaskInstance result = userTaskInstanceEntityMapper.mapToModel(userTaskInstanceEntity);
    assertEquals(userTaskInstance, result);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) Test(org.junit.jupiter.api.Test)

Example 7 with UserTaskInstance

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

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

the class KogitoRuntimeClientTest method testCreateUserTaskInstanceComment.

@Test
public void testCreateUserTaskInstanceComment() {
    String commentInfo = "newComment";
    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.createUserTaskInstanceComment(SERVICE_URL, taskInstance, "jdoe", Collections.singletonList("managers"), commentInfo);
    verify(client).sendPostWithBodyClientRequest(eq(webClientMock), eq("/travels/" + PROCESS_INSTANCE_ID + "/" + taskInstance.getName() + "/" + TASK_ID + "/comments?user=jdoe&group=managers"), eq("Adding comment to  UserTask:" + taskInstance.getName() + " with id: " + taskInstance.getId()), eq(commentInfo), eq("text/plain"));
    ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
    verify(httpRequestMock).sendBuffer(any(), handlerCaptor.capture());
    checkResponseHandling(handlerCaptor.getValue());
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) Handler(io.vertx.core.Handler) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 9 with UserTaskInstance

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

the class KogitoRuntimeClientTest method testDeleteTaskInstanceAttachment.

@Test
public void testDeleteTaskInstanceAttachment() {
    String attachmentId = "attachmentId";
    setupIdentityMock();
    when(webClientMock.delete(any())).thenReturn(httpRequestMock);
    UserTaskInstance taskInstance = createUserTaskInstance(PROCESS_INSTANCE_ID, TASK_ID, "InProgress");
    client.deleteUserTaskInstanceAttachment(SERVICE_URL, taskInstance, "jdoe", Collections.singletonList("managers"), attachmentId);
    verify(client).sendDeleteClientRequest(eq(webClientMock), eq("/travels/" + PROCESS_INSTANCE_ID + "/" + taskInstance.getName() + "/" + TASK_ID + "/attachments/" + attachmentId + "?user=jdoe&group=managers"), eq("Delete attachment : " + attachmentId + "of Task: " + taskInstance.getName() + "  with taskid: " + taskInstance.getId()));
    ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
    verify(httpRequestMock).send(handlerCaptor.capture());
    checkResponseHandling(handlerCaptor.getValue());
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) Handler(io.vertx.core.Handler) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 10 with UserTaskInstance

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

the class KogitoRuntimeClientTest method testUpdateUserTaskInstanceComment.

@Test
public void testUpdateUserTaskInstanceComment() {
    String commentInfo = "NewCommentContent";
    String commentId = "commentId";
    setupIdentityMock();
    when(webClientMock.put(any())).thenReturn(httpRequestMock);
    when(httpRequestMock.putHeader(eq("Content-Type"), anyString())).thenReturn(httpRequestMock);
    UserTaskInstance taskInstance = createUserTaskInstance(PROCESS_INSTANCE_ID, TASK_ID, "InProgress");
    client.updateUserTaskInstanceComment(SERVICE_URL, taskInstance, "jdoe", Collections.singletonList("managers"), commentId, commentInfo);
    verify(client).sendPutClientRequest(eq(webClientMock), eq("/travels/" + PROCESS_INSTANCE_ID + "/" + taskInstance.getName() + "/" + TASK_ID + "/comments/" + commentId + "?user=jdoe&group=managers"), eq("Update UserTask: " + taskInstance.getName() + " comment:" + commentId + "  with taskid: " + taskInstance.getId()), eq(commentInfo), eq("text/plain"));
    ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
    verify(httpRequestMock).sendBuffer(any(), handlerCaptor.capture());
    checkResponseHandling(handlerCaptor.getValue());
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) Handler(io.vertx.core.Handler) 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