Search in sources :

Example 1 with Comment

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

the class UserTaskInstanceEntityMapperIT method setup.

@BeforeEach
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 = singleton("testAdminGroups");
    Set<String> adminUsers = singleton("testAdminUsers");
    ZonedDateTime time = ZonedDateTime.now();
    Set<String> excludedUsers = singleton("testExcludedUsers");
    Set<String> potentialGroups = singleton("testPotentialGroups");
    Set<String> potentialUsers = singleton("testPotentialUsers");
    String referenceName = "testReferenceName";
    String processId = "testProcessId";
    String rootProcessId = "testRootProcessId";
    String rootProcessInstanceId = "testRootProcessInstanceId";
    Map<String, String> object = new HashMap<>();
    object.put("test", "testValue");
    ObjectNode inputs = jsonMapper.createObjectNode().put("testInput", "testValue");
    ObjectNode outputs = jsonMapper.createObjectNode().put("testOutput", "testValue");
    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();
    CommentEntity commentEntity = new CommentEntity();
    commentEntity.setId(commentId);
    commentEntity.setContent(comment_content);
    commentEntity.setUpdatedAt(time);
    commentEntity.setUpdatedBy(comment_updatedBy);
    commentEntity.setUserTask(userTaskInstanceEntity);
    String attachmentId = "testAttachmentId";
    String attachment_name = "testAttachmentName";
    String attachment_content = "testAttachmentContent";
    String attachment_updatedBy = "testAttachmentUpdatedBy";
    Attachment attachment = Attachment.builder().id(attachmentId).updatedAt(time).updatedBy(attachment_updatedBy).content(attachment_content).name(attachment_name).build();
    AttachmentEntity attachmentEntity = new AttachmentEntity();
    attachmentEntity.setId(attachmentId);
    attachmentEntity.setContent(attachment_content);
    attachmentEntity.setName(attachment_name);
    attachmentEntity.setUpdatedAt(time);
    attachmentEntity.setUpdatedBy(attachment_updatedBy);
    attachmentEntity.setUserTask(userTaskInstanceEntity);
    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(singletonList(comment));
    userTaskInstance.setAttachments(singletonList(attachment));
    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(time);
    userTaskInstanceEntity.setStarted(time);
    userTaskInstanceEntity.setExcludedUsers(excludedUsers);
    userTaskInstanceEntity.setPotentialGroups(potentialGroups);
    userTaskInstanceEntity.setPotentialUsers(potentialUsers);
    userTaskInstanceEntity.setReferenceName(referenceName);
    userTaskInstanceEntity.setLastUpdate(time);
    userTaskInstanceEntity.setProcessId(processId);
    userTaskInstanceEntity.setRootProcessId(rootProcessId);
    userTaskInstanceEntity.setRootProcessInstanceId(rootProcessInstanceId);
    userTaskInstanceEntity.setInputs(inputs);
    userTaskInstanceEntity.setOutputs(outputs);
    userTaskInstanceEntity.setComments(singletonList(commentEntity));
    userTaskInstanceEntity.setAttachments(singletonList(attachmentEntity));
}
Also used : Comment(org.kie.kogito.index.model.Comment) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ZonedDateTime(java.time.ZonedDateTime) HashMap(java.util.HashMap) AttachmentEntity(org.kie.kogito.index.postgresql.model.AttachmentEntity) Attachment(org.kie.kogito.index.model.Attachment) CommentEntity(org.kie.kogito.index.postgresql.model.CommentEntity) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with Comment

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

Example 3 with Comment

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

the class UserTaskInstanceEntityMapper method toComment.

Comment toComment(UserTaskInstanceEntity.CommentEntity entity) {
    if (entity == null) {
        return null;
    }
    Comment comment = new Comment();
    comment.setId(entity.getId());
    comment.setContent(entity.getContent());
    comment.setUpdatedBy(entity.getUpdatedBy());
    comment.setUpdatedAt(instantToZonedDateTime(entity.getUpdatedAt()));
    return comment;
}
Also used : Comment(org.kie.kogito.index.model.Comment)

Example 4 with Comment

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

the class CommentMarshallerTest method testReadFrom.

@Test
void testReadFrom() throws IOException {
    MessageMarshaller.ProtoStreamReader reader = mock(MessageMarshaller.ProtoStreamReader.class);
    when(reader.readString(ID)).thenReturn(id);
    when(reader.readString(CONTENT)).thenReturn(content);
    when(reader.readString(UPDATED_BY)).thenReturn(updatedBy);
    when(reader.readDate(UPDATED_AT)).thenReturn(now);
    CommentMarshaller commentMarshaller = new CommentMarshaller(null);
    Comment comment = commentMarshaller.readFrom(reader);
    assertThat(comment).isNotNull().hasFieldOrPropertyWithValue(ID, id).hasFieldOrPropertyWithValue(CONTENT, content).hasFieldOrPropertyWithValue(UPDATED_BY, updatedBy).hasFieldOrPropertyWithValue(UPDATED_AT, commentMarshaller.dateToZonedDateTime(now));
    InOrder inOrder = inOrder(reader);
    inOrder.verify(reader).readString(ID);
    inOrder.verify(reader).readString(CONTENT);
    inOrder.verify(reader).readString(UPDATED_BY);
    inOrder.verify(reader).readDate(UPDATED_AT);
}
Also used : Comment(org.kie.kogito.index.model.Comment) InOrder(org.mockito.InOrder) MessageMarshaller(org.infinispan.protostream.MessageMarshaller) Test(org.junit.jupiter.api.Test)

Example 5 with Comment

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

the class CommentMarshallerTest method testWriteTo.

@Test
void testWriteTo() throws IOException {
    MessageMarshaller.ProtoStreamWriter writer = mock(MessageMarshaller.ProtoStreamWriter.class);
    CommentMarshaller marshaller = new CommentMarshaller(null);
    Comment comment = Comment.builder().id(id).content(content).updatedBy(updatedBy).updatedAt(marshaller.dateToZonedDateTime(now)).build();
    marshaller.writeTo(writer, comment);
    InOrder inOrder = inOrder(writer);
    inOrder.verify(writer).writeString(ID, id);
    inOrder.verify(writer).writeString(CONTENT, content);
    inOrder.verify(writer).writeString(UPDATED_BY, updatedBy);
    inOrder.verify(writer).writeDate(UPDATED_AT, now);
}
Also used : Comment(org.kie.kogito.index.model.Comment) InOrder(org.mockito.InOrder) MessageMarshaller(org.infinispan.protostream.MessageMarshaller) Test(org.junit.jupiter.api.Test)

Aggregations

Comment (org.kie.kogito.index.model.Comment)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ZonedDateTime (java.time.ZonedDateTime)3 Attachment (org.kie.kogito.index.model.Attachment)3 HashMap (java.util.HashMap)2 MessageMarshaller (org.infinispan.protostream.MessageMarshaller)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 InOrder (org.mockito.InOrder)2 BeforeAll (org.junit.jupiter.api.BeforeAll)1 UserTaskInstance (org.kie.kogito.index.model.UserTaskInstance)1 AttachmentEntity (org.kie.kogito.index.oracle.model.AttachmentEntity)1 CommentEntity (org.kie.kogito.index.oracle.model.CommentEntity)1 AttachmentEntity (org.kie.kogito.index.postgresql.model.AttachmentEntity)1 CommentEntity (org.kie.kogito.index.postgresql.model.CommentEntity)1