@Test public void testQueryByTwoStatesAsPost() { String message = "expected exception"; doThrow(new BadUserRequestException(message)).when(mockedQuery).completed(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("active", true); parameters.put("completed", true); given() .contentType(POST_JSON_CONTENT_TYPE) .body(parameters) .then() .statusCode(Status.BAD_REQUEST.getStatusCode()) .contentType(ContentType.JSON) .body("type", equalTo(BadUserRequestException.class.getSimpleName())) .body("message", equalTo(message)) .when() .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); verify(mockedQuery).active(); }
@Test public void testQueryByActiveAsPost() { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("active", true); given() .contentType(POST_JSON_CONTENT_TYPE) .body(parameters) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); verify(mockedQuery).active(); }
@Test public void testQueryByActive() { given() .queryParam("active", true) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); verify(mockedQuery).active(); }
@Test public void testQueryByTwoStates() { String message = "expected exception"; doThrow(new BadUserRequestException(message)).when(mockedQuery).completed(); given() .queryParam("active", true) .queryParam("completed", true) .then() .statusCode(Status.BAD_REQUEST.getStatusCode()) .contentType(ContentType.JSON) .body("type", equalTo(BadUserRequestException.class.getSimpleName())) .body("message", equalTo(message)) .when() .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); verify(mockedQuery).active(); }
@Test public void testSateOfScriptTaskProcessWithTransactionCommitAndException() { BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() //add wait state .camundaAsyncAfter() .scriptTask() .scriptText("throw new RuntimeException()") .scriptFormat("groovy") .endEvent() .done(); ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance); try { ProcessInstance pi = processEngineRule.getRuntimeService() .startProcessInstanceById(processDefinition.getId()); processEngineRule.getManagementService().executeJob( processEngineRule.getManagementService().createJobQuery().executable().singleResult().getId()); fail("exception expected"); } catch (Exception e) { //expected } assertThat(processEngineRule.getRuntimeService().createProcessInstanceQuery().active().list().size(), is(1)); HistoricProcessInstance entity = getHistoricProcessInstanceWithAssertion(processDefinition); assertThat(entity.getState(), is(HistoricProcessInstance.STATE_ACTIVE)); assertEquals(1, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().active().count()); }
assertEquals(2, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().active().count());
@Test public void testSateOfScriptTaskProcessWithTransactionCommitAndException() { BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() //add wait state .camundaAsyncAfter() .scriptTask() .scriptText("throw new RuntimeException()") .scriptFormat("groovy") .endEvent() .done(); ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance); try { ProcessInstance pi = processEngineRule.getRuntimeService() .startProcessInstanceById(processDefinition.getId()); processEngineRule.getManagementService().executeJob( processEngineRule.getManagementService().createJobQuery().executable().singleResult().getId()); fail("exception expected"); } catch (Exception e) { //expected } assertThat(processEngineRule.getRuntimeService().createProcessInstanceQuery().active().list().size(), is(1)); HistoricProcessInstance entity = getHistoricProcessInstanceWithAssertion(processDefinition); assertThat(entity.getState(), is(HistoricProcessInstance.STATE_ACTIVE)); assertEquals(1, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().active().count()); }
assertEquals(2, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().active().count());