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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations