Search in sources :

Example 1 with InspectedProcessInstance

use of io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance in project zeebe-process-test by camunda.

the class AbstractProcessEventInspectionsTest method testFindLastProcessInstance.

@Test
void testFindLastProcessInstance() throws InterruptedException {
    // given
    final DeploymentEvent deploymentEvent = Utilities.deployProcess(getClient(), ProcessPackTimerStartEvent.RESOURCE_NAME);
    // when
    Utilities.increaseTime(getEngine(), Duration.ofDays(1));
    final Optional<InspectedProcessInstance> lastProcessInstance = InspectionUtility.findProcessEvents().triggeredByTimer(ProcessPackTimerStartEvent.TIMER_ID).withProcessDefinitionKey(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey()).findLastProcessInstance();
    // then
    Assertions.assertThat(lastProcessInstance).isNotEmpty();
    BpmnAssert.assertThat(lastProcessInstance.get()).isCompleted();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 2 with InspectedProcessInstance

use of io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance in project zeebe-process-test by camunda.

the class AbstractProcessInstanceInspectionsTest method testStartedByProcessInstanceWithProcessId_wrongId.

@Test
void testStartedByProcessInstanceWithProcessId_wrongId() throws InterruptedException, TimeoutException {
    // given
    Utilities.deployProcesses(getClient(), ProcessPackCallActivity.RESOURCE_NAME, ProcessPackCallActivity.CALLED_RESOURCE_NAME);
    final ProcessInstanceEvent instanceEvent = Utilities.startProcessInstance(getEngine(), getClient(), ProcessPackCallActivity.PROCESS_ID);
    // when
    final Optional<InspectedProcessInstance> firstProcessInstance = InspectionUtility.findProcessInstances().withParentProcessInstanceKey(instanceEvent.getProcessInstanceKey()).withBpmnProcessId("wrongId").findFirstProcessInstance();
    // then
    Assertions.assertThat(firstProcessInstance).isEmpty();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) Test(org.junit.jupiter.api.Test)

Example 3 with InspectedProcessInstance

use of io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance in project zeebe-process-test by camunda.

the class AbstractProcessInstanceInspectionsTest method testStartedByProcessInstanceWithProcessId.

@Test
void testStartedByProcessInstanceWithProcessId() throws InterruptedException, TimeoutException {
    // given
    Utilities.deployProcesses(getClient(), ProcessPackCallActivity.RESOURCE_NAME, ProcessPackCallActivity.CALLED_RESOURCE_NAME);
    final ProcessInstanceEvent instanceEvent = Utilities.startProcessInstance(getEngine(), getClient(), ProcessPackCallActivity.PROCESS_ID);
    // when
    final Optional<InspectedProcessInstance> firstProcessInstance = InspectionUtility.findProcessInstances().withParentProcessInstanceKey(instanceEvent.getProcessInstanceKey()).withBpmnProcessId(ProcessPackCallActivity.CALLED_PROCESS_ID).findFirstProcessInstance();
    // then
    Assertions.assertThat(firstProcessInstance).isNotEmpty();
    BpmnAssert.assertThat(firstProcessInstance.get()).isCompleted();
    BpmnAssert.assertThat(instanceEvent).hasPassedElement(ProcessPackCallActivity.CALL_ACTIVITY_ID).isCompleted();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) Test(org.junit.jupiter.api.Test)

Example 4 with InspectedProcessInstance

use of io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance in project zeebe-process-test by camunda.

the class BpmnAssertTest method testAssertThatInspectedProcessInstanceReturnsProcessInstanceAssert.

@Test
@DisplayName("Should return ProcessInstanceAssert for InspectedProcessInstance")
void testAssertThatInspectedProcessInstanceReturnsProcessInstanceAssert() {
    // given
    InspectedProcessInstance inspected = mock(InspectedProcessInstance.class);
    // when
    ProcessInstanceAssert assertions = BpmnAssert.assertThat(inspected);
    // then
    assertThat(assertions).isInstanceOf(ProcessInstanceAssert.class);
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with InspectedProcessInstance

use of io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance in project customer-onboarding-camunda-8-springboot by berndruecker.

the class TestCustomerOnboardingProcess method testAutomaticOnboarding.

@Test
public void testAutomaticOnboarding() throws Exception {
    // Define expectations on the REST calls
    // 1. http://localhost:8080/crm/customer
    mockRestServer.expect(// 
    requestTo("http://localhost:8080/crm/customer")).andExpect(method(HttpMethod.PUT)).andRespond(withSuccess("{\"customerId\": \"12345\"}", MediaType.APPLICATION_JSON));
    // given a REST call
    customerOnboardingRestController.onboardCustomer();
    // Retrieve process instances started because of the above call
    InspectedProcessInstance processInstance = InspectionUtility.findProcessInstances().findLastProcessInstance().get();
    // We expect to have a user task
    waitForUserTaskAndComplete("TaskApproveCustomerOrder", Collections.singletonMap("approved", true));
    // Now the process should run to the end
    waitForProcessInstanceCompleted(processInstance, Duration.ofSeconds(10));
    // Let's assert that it passed certain BPMN elements (more to show off features here)
    assertThat(processInstance).hasPassedElement("EndEventProcessed").isCompleted();
    // And verify it caused the right side effects on the REST endpoints
    mockRestServer.verify();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) RestClientTest(org.springframework.boot.test.autoconfigure.web.client.RestClientTest) ZeebeSpringTest(io.camunda.zeebe.spring.test.ZeebeSpringTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

InspectedProcessInstance (io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance)19 Test (org.junit.jupiter.api.Test)19 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)8 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)8 ZeebeProcessTest (io.camunda.zeebe.process.test.extension.ZeebeProcessTest)4 ZeebeProcessTest (io.camunda.zeebe.process.test.extension.testcontainer.ZeebeProcessTest)4 DisplayName (org.junit.jupiter.api.DisplayName)2 ZeebeSpringTest (io.camunda.zeebe.spring.test.ZeebeSpringTest)1 RestClientTest (org.springframework.boot.test.autoconfigure.web.client.RestClientTest)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1