Search in sources :

Example 1 with UserTaskInstanceEventBody

use of org.kie.kogito.services.event.impl.UserTaskInstanceEventBody in project kogito-runtimes by kiegroup.

the class PublishEventIT method assertUserTaskInstanceEvent.

protected UserTaskInstanceEventBody assertUserTaskInstanceEvent(DataEvent<?> event, String taskName, String taskDescription, String taskPriority, String taskState, String processId, String nodeName) {
    assertThat(event).isInstanceOf(UserTaskInstanceDataEvent.class);
    UserTaskInstanceEventBody body = ((UserTaskInstanceDataEvent) event).getData();
    assertThat(body).isNotNull();
    assertThat(body.getId()).isNotNull();
    assertThat(body.getTaskName()).isEqualTo(taskName);
    assertThat(body.getTaskDescription()).isEqualTo(taskDescription);
    assertThat(body.getReferenceName()).isEqualTo(nodeName);
    assertThat(body.getTaskPriority()).isEqualTo(taskPriority);
    assertThat(body.getStartDate()).isNotNull();
    assertThat(body.getState()).isEqualTo(taskState);
    if (taskState.equals("Completed") || taskState.equals("Aborted")) {
        assertThat(body.getCompleteDate()).isNotNull();
    } else {
        assertThat(body.getCompleteDate()).isNull();
    }
    assertThat(event.getSource().toString()).isEqualTo("http://myhost/" + processId);
    assertThat(event.getTime()).isBeforeOrEqualTo(ZonedDateTime.now().toOffsetDateTime());
    assertThat(((UserTaskInstanceDataEvent) event).getKogitoAddons()).isEqualTo("test");
    return body;
}
Also used : UserTaskInstanceEventBody(org.kie.kogito.services.event.impl.UserTaskInstanceEventBody) UserTaskInstanceDataEvent(org.kie.kogito.services.event.UserTaskInstanceDataEvent)

Example 2 with UserTaskInstanceEventBody

use of org.kie.kogito.services.event.impl.UserTaskInstanceEventBody in project kogito-runtimes by kiegroup.

the class UserTaskInstanceDataEventCodecTest method setUp.

@BeforeEach
void setUp() {
    codec = new UserTaskInstanceDataEventCodec();
    String source = "testSource";
    String kogitoAddons = "testKogitoAddons";
    Comment comment = new Comment("testCommentId", "testCommentUpdatedBy");
    comment.setContent("testCommentContent");
    comment.setUpdatedAt(new Date());
    Set<Comment> comments = Collections.singleton(comment);
    Attachment attachment = new Attachment("testAttachmentId", "testAttachmentUpdatedBy");
    attachment.setContent(URI.create("test.attachment.test"));
    attachment.setName("testAttachmentName");
    attachment.setUpdatedAt(new Date());
    Set<Attachment> attachments = Collections.singleton(attachment);
    Map<String, String> metaData = new HashMap<>();
    metaData.put(ProcessInstanceEventBody.ID_META_DATA, "testKogitoProcessinstanceId");
    metaData.put(ProcessInstanceEventBody.ROOT_ID_META_DATA, "testKogitoRootProcessinstanceId");
    metaData.put(ProcessInstanceEventBody.PROCESS_ID_META_DATA, "testKogitoProcessId");
    metaData.put(ProcessInstanceEventBody.ROOT_PROCESS_ID_META_DATA, "testKogitoRootProcessId");
    metaData.put(UserTaskInstanceEventBody.UT_STATE_META_DATA, "testKogitoUserTaskinstanceState");
    metaData.put(UserTaskInstanceEventBody.UT_ID_META_DATA, "testKogitoUserTaskinstanceId");
    UserTaskInstanceEventBody body = UserTaskInstanceEventBody.create().id("testId").taskName("testTaskName").taskDescription("testTaskDescription").taskPriority("testTaskPriority").referenceName("testReferenceName").startDate(new Date()).completeDate(new Date()).state("testState").actualOwner("testActualOwner").potentialUsers(Collections.singleton("testPotentialUsers")).potentialGroups(Collections.singleton("testPotentialGroups")).excludedUsers(Collections.singleton("testExcludedUsers")).adminUsers(Collections.singleton("testAdminUsers")).adminGroups(Collections.singleton("testAdminGroups")).inputs(Collections.singletonMap("testInputsKey", "testInputsValue")).outputs(Collections.singletonMap("testOutputsKey", "testOutputsValue")).processInstanceId("testKogitoProcessinstanceId").rootProcessInstanceId("testKogitoRootProcessinstanceId").processId("testKogitoProcessId").rootProcessId("testKogitoRootProcessId").comments(comments).attachments(attachments).build();
    event = new UserTaskInstanceDataEvent(source, kogitoAddons, metaData, body);
}
Also used : Comment(org.kie.kogito.process.workitem.Comment) HashMap(java.util.HashMap) Attachment(org.kie.kogito.process.workitem.Attachment) UserTaskInstanceEventBody(org.kie.kogito.services.event.impl.UserTaskInstanceEventBody) BsonString(org.bson.BsonString) UserTaskInstanceDataEvent(org.kie.kogito.services.event.UserTaskInstanceDataEvent) Date(java.util.Date) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

UserTaskInstanceDataEvent (org.kie.kogito.services.event.UserTaskInstanceDataEvent)2 UserTaskInstanceEventBody (org.kie.kogito.services.event.impl.UserTaskInstanceEventBody)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 BsonString (org.bson.BsonString)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Attachment (org.kie.kogito.process.workitem.Attachment)1 Comment (org.kie.kogito.process.workitem.Comment)1