Search in sources :

Example 1 with ProcessInstance

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

the class ProcessInstanceEntityMapperIT method testMapToModel.

@Test
void testMapToModel() {
    ProcessInstance result = mapper.mapToModel(processInstanceEntity);
    assertThat(result).usingRecursiveComparison().isEqualTo(processInstance);
}
Also used : ProcessInstance(org.kie.kogito.index.model.ProcessInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessInstance

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

the class ProcessInstanceMarshallerTest method testWriteTo.

@Test
void testWriteTo() throws IOException {
    ProcessInstance pi = new ProcessInstance();
    pi.setId("id");
    pi.setEndpoint("endpoint");
    pi.setProcessId("processId");
    pi.setProcessName("processName");
    pi.setRootProcessInstanceId("rootProcessInstanceId");
    pi.setParentProcessInstanceId("rootProcessInstanceId");
    pi.setRootProcessId("rootProcessId");
    pi.setRoles(singleton("admin"));
    pi.setVariables(null);
    pi.setNodes(emptyList());
    pi.setState(ProcessInstanceState.ERROR.ordinal());
    pi.setStart(ZonedDateTime.now());
    pi.setError(new ProcessInstanceError("StartEvent_1", "Something went wrong"));
    pi.setMilestones(emptyList());
    MessageMarshaller.ProtoStreamWriter writer = mock(MessageMarshaller.ProtoStreamWriter.class);
    ProcessInstanceMarshaller marshaller = new ProcessInstanceMarshaller(null);
    marshaller.writeTo(writer, pi);
    InOrder inOrder = inOrder(writer);
    inOrder.verify(writer).writeString(ID, pi.getId());
    inOrder.verify(writer).writeString(PROCESS_ID, pi.getProcessId());
    inOrder.verify(writer).writeCollection(ROLES, pi.getRoles(), String.class);
    inOrder.verify(writer).writeString(VARIABLES, null);
    inOrder.verify(writer).writeString(ENDPOINT, pi.getEndpoint());
    inOrder.verify(writer).writeCollection(NODES, pi.getNodes(), NodeInstance.class);
    inOrder.verify(writer).writeInt(STATE, pi.getState());
    inOrder.verify(writer).writeDate(START, marshaller.zonedDateTimeToDate(pi.getStart()));
    inOrder.verify(writer).writeDate(END, marshaller.zonedDateTimeToDate(pi.getEnd()));
    inOrder.verify(writer).writeString(ROOT_PROCESS_INSTANCE_ID, pi.getRootProcessInstanceId());
    inOrder.verify(writer).writeString(ROOT_PROCESS_ID, pi.getRootProcessId());
    inOrder.verify(writer).writeString(PARENT_PROCESS_INSTANCE_ID, pi.getParentProcessInstanceId());
    inOrder.verify(writer).writeString(PROCESS_NAME, pi.getProcessName());
    inOrder.verify(writer).writeObject(ERROR, pi.getError(), ProcessInstanceError.class);
    inOrder.verify(writer).writeCollection(ADDONS, pi.getAddons(), String.class);
    inOrder.verify(writer).writeDate(LAST_UPDATE, marshaller.zonedDateTimeToDate(pi.getLastUpdate()));
    inOrder.verify(writer).writeString(BUSINESS_KEY, pi.getBusinessKey());
    inOrder.verify(writer).writeCollection(MILESTONES, pi.getMilestones(), Milestone.class);
}
Also used : InOrder(org.mockito.InOrder) ProcessInstanceError(org.kie.kogito.index.model.ProcessInstanceError) ProcessInstance(org.kie.kogito.index.model.ProcessInstance) MessageMarshaller(org.infinispan.protostream.MessageMarshaller) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessInstance

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

the class ProcessInstanceStorageIT method testProcessInstanceEntity.

@Test
@Transactional
public void testProcessInstanceEntity() {
    String processInstanceId = UUID.randomUUID().toString();
    ProcessInstance processInstance1 = TestUtils.createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.ACTIVE.ordinal(), 0L);
    ProcessInstance processInstance2 = TestUtils.createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.COMPLETED.ordinal(), 1000L);
    testStorage(processInstanceId, processInstance1, processInstance2);
}
Also used : ProcessInstance(org.kie.kogito.index.model.ProcessInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Example 4 with ProcessInstance

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

the class ProcessInstanceEntityMapperTest method testMapToModel.

@Test
void testMapToModel() {
    ProcessInstance result = processInstanceEntityMapper.mapToModel(processInstanceEntity);
    assertEquals(processInstance, result);
}
Also used : ProcessInstance(org.kie.kogito.index.model.ProcessInstance) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessInstance

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

the class ProcessInstanceStorageIT method testProcessInstanceEntity.

@Test
@Transactional
public void testProcessInstanceEntity() {
    String processInstanceId = UUID.randomUUID().toString();
    ProcessInstance processInstance1 = TestUtils.createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.ACTIVE.ordinal(), 0L);
    ProcessInstance processInstance2 = TestUtils.createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.COMPLETED.ordinal(), 1000L);
    testStorage(processInstanceId, processInstance1, processInstance2);
}
Also used : ProcessInstance(org.kie.kogito.index.model.ProcessInstance) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Aggregations

ProcessInstance (org.kie.kogito.index.model.ProcessInstance)34 Test (org.junit.jupiter.api.Test)23 Handler (io.vertx.core.Handler)9 QuarkusTest (io.quarkus.test.junit.QuarkusTest)7 ProcessInstanceError (org.kie.kogito.index.model.ProcessInstanceError)6 NodeInstance (org.kie.kogito.index.model.NodeInstance)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 Transactional (javax.transaction.Transactional)3 TestUtils.getProcessInstance (org.kie.kogito.index.TestUtils.getProcessInstance)3 Milestone (org.kie.kogito.index.model.Milestone)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Date (java.util.Date)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Inject (javax.inject.Inject)2 DataIndexStorageService (org.kie.kogito.index.DataIndexStorageService)2 JsonUtils.getObjectMapper (org.kie.kogito.index.json.JsonUtils.getObjectMapper)2 Job (org.kie.kogito.index.model.Job)2