Search in sources :

Example 31 with UserTaskInstance

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

the class TestUtils method createUserTaskInstance.

public static UserTaskInstance createUserTaskInstance(String taskId, String processInstanceId, String processId, String rootProcessInstanceId, String rootProcessId, String state, long timeInterval) {
    UserTaskInstance task = new UserTaskInstance();
    task.setId(taskId);
    task.setProcessInstanceId(processInstanceId);
    task.setProcessId(processId);
    task.setRootProcessId(rootProcessId);
    task.setRootProcessInstanceId(rootProcessInstanceId);
    task.setName("TaskName");
    task.setDescription("TaskDescription");
    task.setState(state);
    task.setPriority("High");
    task.setStarted(Instant.ofEpochMilli(ZonedDateTime.now().toInstant().toEpochMilli() + timeInterval).atZone(ZoneOffset.UTC));
    task.setCompleted("Completed".equals(state) ? Instant.ofEpochMilli(ZonedDateTime.now().toInstant().toEpochMilli() + timeInterval).atZone(ZoneOffset.UTC).plus(1, ChronoUnit.HOURS) : null);
    task.setActualOwner("kogito");
    task.setAdminUsers(singleton("kogito"));
    task.setAdminGroups(singleton("admin"));
    task.setExcludedUsers(singleton("excluded"));
    task.setPotentialUsers(singleton("potentialUser"));
    task.setPotentialGroups(singleton("potentialGroup"));
    task.setComments(List.of(Comment.builder().id("commentId" + taskId).content("Comment 1").updatedBy("kogito").build()));
    task.setAttachments(List.of(Attachment.builder().id("attachmentId" + taskId).content("http://linltodoc.com/1").name("doc1").updatedBy("kogito").build()));
    return task;
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance)

Example 32 with UserTaskInstance

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

the class UserTaskInstanceEventMapper method apply.

@Override
public UserTaskInstance apply(UserTaskInstanceDataEvent event) {
    if (event == null || event.getData() == null) {
        return null;
    }
    UserTaskInstance task = new UserTaskInstance();
    task.setId(event.getData().getId());
    task.setProcessInstanceId(event.getData().getProcessInstanceId());
    task.setProcessId(event.getData().getProcessId());
    task.setRootProcessId(event.getData().getRootProcessId());
    task.setRootProcessInstanceId(event.getData().getRootProcessInstanceId());
    task.setName(event.getData().getTaskName());
    task.setDescription(event.getData().getTaskDescription());
    task.setState(event.getData().getState());
    task.setPriority(event.getData().getTaskPriority());
    task.setStarted(toZonedDateTime(event.getData().getStartDate()));
    task.setCompleted(toZonedDateTime(event.getData().getCompleteDate()));
    task.setActualOwner(event.getData().getActualOwner());
    task.setAdminUsers(event.getData().getAdminUsers());
    task.setAdminGroups(event.getData().getAdminGroups());
    task.setExcludedUsers(event.getData().getExcludedUsers());
    task.setPotentialUsers(event.getData().getPotentialUsers());
    task.setPotentialGroups(event.getData().getPotentialGroups());
    task.setComments(event.getData().getComments().stream().map(comment()).collect(toList()));
    task.setAttachments(event.getData().getAttachments().stream().map(attachment()).collect(toList()));
    task.setInputs(getObjectMapper().valueToTree(event.getData().getInputs()));
    task.setOutputs(getObjectMapper().valueToTree(event.getData().getOutputs()));
    task.setEndpoint(getEndpoint(event.getSource(), event.getData().getProcessInstanceId(), event.getData().getTaskName(), event.getData().getId()));
    task.setLastUpdate(toZonedDateTime(event.getTime()));
    task.setReferenceName(event.getData().getReferenceName());
    return task;
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance)

Example 33 with UserTaskInstance

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

the class UserTaskInstanceEntityMapper method mapToModel.

@Override
public UserTaskInstance mapToModel(UserTaskInstanceEntity entity) {
    if (entity == null) {
        return null;
    }
    UserTaskInstance instance = new UserTaskInstance();
    instance.setId(entity.getId());
    instance.setDescription(entity.getDescription());
    instance.setName(entity.getName());
    instance.setPriority(entity.getPriority());
    instance.setProcessInstanceId(entity.getProcessInstanceId());
    instance.setState(entity.getState());
    instance.setActualOwner(entity.getActualOwner());
    instance.setAdminGroups(entity.getAdminGroups());
    instance.setAdminUsers(entity.getAdminUsers());
    instance.setCompleted(instantToZonedDateTime(entity.getCompleted()));
    instance.setStarted(instantToZonedDateTime(entity.getStarted()));
    instance.setExcludedUsers(entity.getExcludedUsers());
    instance.setPotentialGroups(entity.getPotentialGroups());
    instance.setPotentialUsers(entity.getPotentialUsers());
    instance.setReferenceName(entity.getReferenceName());
    instance.setLastUpdate(instantToZonedDateTime(entity.getLastUpdate()));
    instance.setProcessId(entity.getProcessId());
    instance.setRootProcessId(entity.getRootProcessId());
    instance.setRootProcessInstanceId(entity.getRootProcessInstanceId());
    instance.setInputs(documentToJsonNode(entity.getInputs()));
    instance.setOutputs(documentToJsonNode(entity.getOutputs()));
    instance.setEndpoint(entity.getEndpoint());
    instance.setComments(Optional.ofNullable(entity.getComments()).map(comments -> comments.stream().map(this::toComment).collect(toList())).orElse(null));
    instance.setAttachments(Optional.ofNullable(entity.getAttachments()).map(attachments -> attachments.stream().map(this::toAttachment).collect(toList())).orElse(null));
    return instance;
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance)

Example 34 with UserTaskInstance

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

the class UserTaskInstanceStorageIT method testCache.

@Test
void testCache() {
    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);
    testStorage(storage, taskId, userTaskInstance1, userTaskInstance2);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 35 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);
    testStorage(taskId, userTaskInstance1, userTaskInstance2);
}
Also used : UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

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