Search in sources :

Example 1 with Attachment

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

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

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

the class UserTaskInstanceEntityMapper method toAttachment.

Attachment toAttachment(UserTaskInstanceEntity.AttachmentEntity entity) {
    if (entity == null) {
        return null;
    }
    Attachment attachment = new Attachment();
    attachment.setId(entity.getId());
    attachment.setContent(entity.getContent());
    attachment.setName(entity.getName());
    attachment.setUpdatedBy(entity.getUpdatedBy());
    attachment.setUpdatedAt(instantToZonedDateTime(entity.getUpdatedAt()));
    return attachment;
}
Also used : Attachment(org.kie.kogito.index.model.Attachment)

Example 4 with Attachment

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

the class AttachmentMarshallerTest method testReadFrom.

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

Example 5 with Attachment

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

the class AttachmentMarshaller method readFrom.

@Override
public Attachment readFrom(ProtoStreamReader reader) throws IOException {
    Attachment attachment = new Attachment();
    attachment.setId(reader.readString(ID));
    attachment.setName(reader.readString(NAME));
    attachment.setContent(reader.readString(CONTENT));
    attachment.setUpdatedBy(reader.readString(UPDATED_BY));
    attachment.setUpdatedAt(dateToZonedDateTime(reader.readDate(UPDATED_AT)));
    return attachment;
}
Also used : Attachment(org.kie.kogito.index.model.Attachment)

Aggregations

Attachment (org.kie.kogito.index.model.Attachment)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ZonedDateTime (java.time.ZonedDateTime)3 Comment (org.kie.kogito.index.model.Comment)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