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();
}
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();
}
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();
}
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);
}
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();
}
Aggregations