Search in sources :

Example 1 with UserTaskInstance

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

the class UserTaskInstanceEntityMapperIT method testMapToModel.

@Test
void testMapToModel() {
    UserTaskInstance result = mapper.mapToModel(userTaskInstanceEntity);
    assertThat(result).isEqualToComparingFieldByField(userTaskInstance);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with UserTaskInstance

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

the class UserTaskInstanceMarshallerTest method testReadFrom.

@Test
void testReadFrom() throws IOException {
    MessageMarshaller.ProtoStreamReader reader = mock(MessageMarshaller.ProtoStreamReader.class);
    UserTaskInstanceMarshaller marshaller = new UserTaskInstanceMarshaller(MAPPER);
    when(reader.readString(ID)).thenReturn(TASK.getId());
    when(reader.readString(DESCRIPTION)).thenReturn(TASK.getDescription());
    when(reader.readString(NAME)).thenReturn(TASK.getName());
    when(reader.readString(PRIORITY)).thenReturn(TASK.getPriority());
    when(reader.readString(PROCESS_INSTANCE_ID)).thenReturn(TASK.getProcessInstanceId());
    when(reader.readString(PROCESS_ID)).thenReturn(TASK.getProcessId());
    when(reader.readString(ROOT_PROCESS_INSTANCE_ID)).thenReturn(TASK.getRootProcessInstanceId());
    when(reader.readString(ROOT_PROCESS_ID)).thenReturn(TASK.getRootProcessId());
    when(reader.readString(STATE)).thenReturn(TASK.getState());
    when(reader.readString(ACTUAL_OWNER)).thenReturn(TASK.getActualOwner());
    when(reader.readCollection(eq(ADMIN_USERS), any(), eq(String.class))).thenReturn(TASK.getAdminUsers());
    when(reader.readCollection(eq(ADMIN_GROUPS), any(), eq(String.class))).thenReturn(TASK.getAdminGroups());
    when(reader.readDate(COMPLETED)).thenReturn(marshaller.zonedDateTimeToDate(TASK.getCompleted()));
    when(reader.readDate(STARTED)).thenReturn(marshaller.zonedDateTimeToDate(TASK.getStarted()));
    when(reader.readCollection(eq(EXCLUDED_USERS), any(), eq(String.class))).thenReturn(TASK.getExcludedUsers());
    when(reader.readCollection(eq(POTENTIAL_GROUPS), any(), eq(String.class))).thenReturn(TASK.getPotentialGroups());
    when(reader.readCollection(eq(POTENTIAL_USERS), any(), eq(String.class))).thenReturn(TASK.getPotentialUsers());
    when(reader.readString(INPUTS)).thenReturn(TASK.getInputs().toString());
    when(reader.readString(OUTPUTS)).thenReturn(TASK.getOutputs().toString());
    when(reader.readString(REFERENCE_NAME)).thenReturn(TASK.getReferenceName());
    when(reader.readDate(LAST_UPDATE)).thenReturn(marshaller.zonedDateTimeToDate(TASK.getLastUpdate()));
    when(reader.readString(ENDPOINT)).thenReturn(TASK.getEndpoint());
    when(reader.readCollection(eq(COMMENTS), any(), eq(Comment.class))).thenReturn(TASK.getComments());
    when(reader.readCollection(eq(ATTACHMENTS), any(), eq(Attachment.class))).thenReturn(TASK.getAttachments());
    UserTaskInstance task = marshaller.readFrom(reader);
    assertThat(task).isNotNull().isEqualToIgnoringGivenFields(TASK);
    InOrder inOrder = inOrder(reader);
    inOrder.verify(reader).readString(ID);
    inOrder.verify(reader).readString(DESCRIPTION);
    inOrder.verify(reader).readString(NAME);
    inOrder.verify(reader).readString(PRIORITY);
    inOrder.verify(reader).readString(PROCESS_INSTANCE_ID);
    inOrder.verify(reader).readString(PROCESS_ID);
    inOrder.verify(reader).readString(ROOT_PROCESS_INSTANCE_ID);
    inOrder.verify(reader).readString(ROOT_PROCESS_ID);
    inOrder.verify(reader).readString(STATE);
    inOrder.verify(reader).readString(ACTUAL_OWNER);
    inOrder.verify(reader).readCollection(ADMIN_GROUPS, new HashSet<>(), String.class);
    inOrder.verify(reader).readCollection(ADMIN_USERS, new HashSet<>(), String.class);
    inOrder.verify(reader).readDate(COMPLETED);
    inOrder.verify(reader).readDate(STARTED);
    inOrder.verify(reader).readCollection(EXCLUDED_USERS, new HashSet<>(), String.class);
    inOrder.verify(reader).readCollection(POTENTIAL_GROUPS, new HashSet<>(), String.class);
    inOrder.verify(reader).readCollection(POTENTIAL_USERS, new HashSet<>(), String.class);
    inOrder.verify(reader).readString(INPUTS);
    inOrder.verify(reader).readString(OUTPUTS);
    inOrder.verify(reader).readString(REFERENCE_NAME);
    inOrder.verify(reader).readDate(LAST_UPDATE);
    inOrder.verify(reader).readString(ENDPOINT);
    inOrder.verify(reader).readCollection(COMMENTS, new ArrayList<>(), Comment.class);
    inOrder.verify(reader).readCollection(ATTACHMENTS, new ArrayList<>(), Attachment.class);
    verifyNoMoreInteractions(reader);
}
Also used : Comment(org.kie.kogito.index.model.Comment) UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) InOrder(org.mockito.InOrder) Attachment(org.kie.kogito.index.model.Attachment) MessageMarshaller(org.infinispan.protostream.MessageMarshaller) Test(org.junit.jupiter.api.Test)

Example 3 with UserTaskInstance

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

the class UserTaskInstanceEntityMapperIT method testMapToModel.

@Test
void testMapToModel() {
    UserTaskInstance result = mapper.mapToModel(userTaskInstanceEntity);
    assertThat(result).isEqualToComparingFieldByField(userTaskInstance);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 4 with UserTaskInstance

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

the class UserTaskInstanceStorageIT method testUserTaskInstanceEntity.

@Test
@Transactional
public void testUserTaskInstanceEntity() {
    String taskId = UUID.randomUUID().toString();
    String processInstanceId = UUID.randomUUID().toString();
    UserTaskInstance userTaskInstance1 = TestUtils.createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "InProgress", 0L);
    UserTaskInstance userTaskInstance2 = TestUtils.createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "Completed", 1000L);
    ObjectMapper objectMapper = new ObjectMapper();
    ObjectNode node = objectMapper.createObjectNode();
    node.put("test", "test");
    userTaskInstance1.setInputs(node);
    testStorage(taskId, userTaskInstance1, userTaskInstance2);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Example 5 with UserTaskInstance

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

the class UserTaskInstanceEntityMapperTest method setup.

@BeforeAll
static void setup() {
    String testId = "testId";
    String description = "testDescription";
    String name = "testName";
    String priority = "10";
    String processInstanceId = "testProcessInstanceId";
    String state = "testState";
    String actualOwner = "testActualOwner";
    Set<String> adminGroups = Set.of("testAdminGroups");
    Set<String> adminUsers = Set.of("testAdminUsers");
    ZonedDateTime time = ZonedDateTime.now();
    Set<String> excludedUsers = Set.of("testExcludedUsers");
    Set<String> potentialGroups = Set.of("testPotentialGroups");
    Set<String> potentialUsers = Set.of("testPotentialUsers");
    String referenceName = "testReferenceName";
    String processId = "testProcessId";
    String rootProcessId = "testRootProcessId";
    String rootProcessInstanceId = "testRootProcessInstanceId";
    ObjectNode object = MAPPER.createObjectNode();
    object.put("test", "testValue");
    ObjectNode inputs = object;
    ObjectNode outputs = object;
    String commentId = "testCommentId";
    String comment_content = "testCommentContent";
    String comment_updatedBy = "testCommentUpdatedBy";
    Comment comment = Comment.builder().id(commentId).updatedAt(time).updatedBy(comment_updatedBy).content(comment_content).build();
    UserTaskInstanceEntity.CommentEntity commentEntity = new UserTaskInstanceEntity.CommentEntity();
    commentEntity.setId(commentId);
    commentEntity.setContent(comment_content);
    commentEntity.setUpdatedAt(zonedDateTimeToInstant(time));
    commentEntity.setUpdatedBy(comment_updatedBy);
    String attachmentId = "testAttachmentId";
    String attachment_name = "testCommentName";
    String attachment_content = "testCommentContent";
    String attachment_updatedBy = "testCommentUpdatedBy";
    Attachment attachment = Attachment.builder().id(attachmentId).updatedAt(time).updatedBy(attachment_updatedBy).content(attachment_content).name(attachment_name).build();
    UserTaskInstanceEntity.AttachmentEntity attachmentEntity = new UserTaskInstanceEntity.AttachmentEntity();
    attachmentEntity.setId(commentId);
    attachmentEntity.setContent(comment_content);
    attachmentEntity.setUpdatedAt(zonedDateTimeToInstant(time));
    attachmentEntity.setUpdatedBy(comment_updatedBy);
    userTaskInstance = new UserTaskInstance();
    userTaskInstance.setId(testId);
    userTaskInstance.setDescription(description);
    userTaskInstance.setName(name);
    userTaskInstance.setPriority(priority);
    userTaskInstance.setProcessInstanceId(processInstanceId);
    userTaskInstance.setState(state);
    userTaskInstance.setActualOwner(actualOwner);
    userTaskInstance.setAdminGroups(adminGroups);
    userTaskInstance.setAdminUsers(adminUsers);
    userTaskInstance.setCompleted(time);
    userTaskInstance.setStarted(time);
    userTaskInstance.setExcludedUsers(excludedUsers);
    userTaskInstance.setPotentialGroups(potentialGroups);
    userTaskInstance.setPotentialUsers(potentialUsers);
    userTaskInstance.setReferenceName(referenceName);
    userTaskInstance.setLastUpdate(time);
    userTaskInstance.setProcessId(processId);
    userTaskInstance.setRootProcessId(rootProcessId);
    userTaskInstance.setRootProcessInstanceId(rootProcessInstanceId);
    userTaskInstance.setInputs(inputs);
    userTaskInstance.setOutputs(outputs);
    userTaskInstance.setComments(List.of(comment));
    userTaskInstance.setAttachments(List.of(attachment));
    userTaskInstanceEntity = new UserTaskInstanceEntity();
    userTaskInstanceEntity.setId(testId);
    userTaskInstanceEntity.setDescription(description);
    userTaskInstanceEntity.setName(name);
    userTaskInstanceEntity.setPriority(priority);
    userTaskInstanceEntity.setProcessInstanceId(processInstanceId);
    userTaskInstanceEntity.setState(state);
    userTaskInstanceEntity.setActualOwner(actualOwner);
    userTaskInstanceEntity.setAdminGroups(adminGroups);
    userTaskInstanceEntity.setAdminUsers(adminUsers);
    userTaskInstanceEntity.setCompleted(zonedDateTimeToInstant(time));
    userTaskInstanceEntity.setStarted(zonedDateTimeToInstant(time));
    userTaskInstanceEntity.setExcludedUsers(excludedUsers);
    userTaskInstanceEntity.setPotentialGroups(potentialGroups);
    userTaskInstanceEntity.setPotentialUsers(potentialUsers);
    userTaskInstanceEntity.setReferenceName(referenceName);
    userTaskInstanceEntity.setLastUpdate(zonedDateTimeToInstant(time));
    userTaskInstanceEntity.setProcessId(processId);
    userTaskInstanceEntity.setRootProcessId(rootProcessId);
    userTaskInstanceEntity.setRootProcessInstanceId(rootProcessInstanceId);
    userTaskInstanceEntity.setInputs(jsonNodeToDocument(inputs));
    userTaskInstanceEntity.setOutputs(jsonNodeToDocument(outputs));
    userTaskInstanceEntity.setComments(List.of(commentEntity));
    userTaskInstanceEntity.setAttachments(List.of(attachmentEntity));
}
Also used : Comment(org.kie.kogito.index.model.Comment) UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ZonedDateTime(java.time.ZonedDateTime) Attachment(org.kie.kogito.index.model.Attachment) BeforeAll(org.junit.jupiter.api.BeforeAll)

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