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