protected void close(final String caseExecutionId) { caseService .withCaseExecution(caseExecutionId) .close(); }
protected void close(final String caseExecutionId) { caseService .withCaseExecution(caseExecutionId) .close(); }
public void closeCaseInstance(String caseInstanceId) { withCaseExecution(caseInstanceId).close(); }
public void closeCaseInstance(String caseInstanceId) { withCaseExecution(caseInstanceId).close(); }
public void testCloseInvalidCaseExeuction() { try { caseService .withCaseExecution("invalid") .close(); fail("The case execution should not be found."); } catch (NotFoundException e) { } try { caseService .withCaseExecution(null) .close(); fail("The case execution should not be found."); } catch (NotValidException e) { } }
public void close(CaseExecutionTriggerDto triggerDto) { try { CaseService caseService = engine.getCaseService(); CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId); initializeCommand(commandBuilder, triggerDto, "close"); commandBuilder.close(); } catch (NotFoundException e) { throw createInvalidRequestException("close", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("close", Status.BAD_REQUEST, e); } catch (NotAllowedException e) { throw createInvalidRequestException("close", Status.FORBIDDEN, e); } catch (ProcessEngineException e) { throw createRestException("close", Status.INTERNAL_SERVER_ERROR, e); } }
public void close(CaseExecutionTriggerDto triggerDto) { try { CaseService caseService = engine.getCaseService(); CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId); initializeCommand(commandBuilder, triggerDto, "close"); commandBuilder.close(); } catch (NotFoundException e) { throw createInvalidRequestException("close", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("close", Status.BAD_REQUEST, e); } catch (NotAllowedException e) { throw createInvalidRequestException("close", Status.FORBIDDEN, e); } catch (ProcessEngineException e) { throw createRestException("close", Status.INTERNAL_SERVER_ERROR, e); } }
@Test public void testUnsuccessfulClose() { doThrow(new NotValidException("expected exception")).when(caseExecutionCommandBuilderMock).close(); given() .pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID) .contentType(ContentType.JSON) .body(EMPTY_JSON_OBJECT) .then() .expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .body("type", equalTo(InvalidRequestException.class.getSimpleName())) .body("message", containsString("Cannot close case instance " + MockProvider.EXAMPLE_CASE_INSTANCE_ID + ": expected exception")) .when() .post(CASE_INSTANCE_CLOSE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).close(); }
@Test public void testCloseWithRemoveVariableAndVariableLocal() { String aVariableKey = "aKey"; String anotherVariableKey = "anotherKey"; List<VariableNameDto> variableNames = new ArrayList<VariableNameDto>(); VariableNameDto firstVariableName = new VariableNameDto(aVariableKey, true); variableNames.add(firstVariableName); VariableNameDto secondVariableName = new VariableNameDto(anotherVariableKey); variableNames.add(secondVariableName); Map<String, Object> variablesJson = new HashMap<String, Object>(); variablesJson.put("deletions", variableNames); given() .pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID) .contentType(ContentType.JSON) .body(variablesJson) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(CASE_INSTANCE_CLOSE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).removeVariableLocal(aVariableKey); verify(caseExecutionCommandBuilderMock).removeVariable(anotherVariableKey); verify(caseExecutionCommandBuilderMock).close(); }
@Test public void testCloseWithRemoveVariable() { String aVariableKey = "aKey"; String anotherVariableKey = "anotherKey"; List<VariableNameDto> variableNames = new ArrayList<VariableNameDto>(); VariableNameDto firstVariableName = new VariableNameDto(aVariableKey); variableNames.add(firstVariableName); VariableNameDto secondVariableName = new VariableNameDto(anotherVariableKey); variableNames.add(secondVariableName); Map<String, Object> variablesJson = new HashMap<String, Object>(); variablesJson.put("deletions", variableNames); given() .pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID) .contentType(ContentType.JSON) .body(variablesJson) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(CASE_INSTANCE_CLOSE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).removeVariable(aVariableKey); verify(caseExecutionCommandBuilderMock).removeVariable(anotherVariableKey); verify(caseExecutionCommandBuilderMock).close(); }
@Test public void testClose() { given() .pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID) .contentType(ContentType.JSON) .body(EMPTY_JSON_OBJECT) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(CASE_INSTANCE_CLOSE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).close(); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn"}) public void testClose() { // given createCaseInstance(DEFINITION_KEY); String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK_KEY).getId(); try { // when caseService .withCaseExecution(processTaskId) .close(); fail("It should not be possible to close a process task."); } catch (NotAllowedException e) { } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn"}) public void testClose() { // given createCaseInstance(DEFINITION_KEY); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK_KEY).getId(); try { // when caseService .withCaseExecution(caseTaskId) .close(); fail("It should not be possible to close a case task."); } catch (NotAllowedException e) { } }
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseInstanceListenerTest.testCloseListenerByScript.cmmn"}) public void testCloseListenerByScript() { // given String caseInstanceId = caseService .withCaseDefinitionByKey("case") .create() .getId(); caseService .withCaseExecution(caseInstanceId) .complete(); // when caseService .withCaseExecution(caseInstanceId) .close(); // then // TODO: if history is provided, the historic variables have to be checked! }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testClose() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); caseService .withCaseDefinition(caseDefinitionId) .create(); String caseExecutionId = caseService .createCaseExecutionQuery() .activityId("PI_HumanTask_1") .singleResult() .getId(); try { // when caseService .withCaseExecution(caseExecutionId) .close(); fail("It should not be possible to close a task."); } catch (NotAllowedException e) { } }
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseInstanceListenerTest.testCloseListenerByClass.cmmn"}) public void testCloseListenerByClass() { CloseCaseExecutionListener.clear(); assertNull(CloseCaseExecutionListener.EVENT); assertEquals(0, CloseCaseExecutionListener.COUNTER); assertNull(CloseCaseExecutionListener.ON_CASE_EXECUTION_ID); // given String caseInstanceId = caseService .withCaseDefinitionByKey("case") .create() .getId(); caseService .withCaseExecution(caseInstanceId) .complete(); // when caseService .withCaseExecution(caseInstanceId) .close(); // then assertEquals("close", CloseCaseExecutionListener.EVENT); assertEquals(1, CloseCaseExecutionListener.COUNTER); assertEquals(caseInstanceId, CloseCaseExecutionListener.ON_CASE_EXECUTION_ID); }
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseInstanceListenerTest.testCloseListenerByDelegateExpression.cmmn"}) public void testCloseListenerByDelegateExpression() { CloseCaseExecutionListener.clear(); assertNull(CloseCaseExecutionListener.EVENT); assertEquals(0, CloseCaseExecutionListener.COUNTER); assertNull(CloseCaseExecutionListener.ON_CASE_EXECUTION_ID); // given String caseInstanceId = caseService .withCaseDefinitionByKey("case") .setVariable("myListener", new CloseCaseExecutionListener()) .create() .getId(); terminate(caseInstanceId); // when caseService .withCaseExecution(caseInstanceId) .close(); // then assertEquals("close", CloseCaseExecutionListener.EVENT); assertEquals(1, CloseCaseExecutionListener.COUNTER); assertEquals(caseInstanceId, CloseCaseExecutionListener.ON_CASE_EXECUTION_ID); }
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseInstanceListenerTest.testCloseListenerByExpression.cmmn"}) public void testCloseListenerByExpression() { CloseCaseExecutionListener.clear(); assertNull(CloseCaseExecutionListener.EVENT); assertEquals(0, CloseCaseExecutionListener.COUNTER); assertNull(CloseCaseExecutionListener.ON_CASE_EXECUTION_ID); // given String caseInstanceId = caseService .withCaseDefinitionByKey("case") .setVariable("myListener", new CloseCaseExecutionListener()) .create() .getId(); suspend(caseInstanceId); // when caseService .withCaseExecution(caseInstanceId) .close(); // then assertEquals("close", CloseCaseExecutionListener.EVENT); assertEquals(1, CloseCaseExecutionListener.COUNTER); assertEquals(caseInstanceId, CloseCaseExecutionListener.ON_CASE_EXECUTION_ID); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testCloseCaseInstanceShouldCompleteCaseTask() { // given createCaseInstance(DEFINITION_KEY); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK_KEY).getId(); String humanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId(); caseService .withCaseExecution(humanTaskId) .complete(); CaseInstance subCaseInstance = queryCaseInstanceByKey(DEFINITION_KEY_2); assertTrue(subCaseInstance.isCompleted()); // when caseService .withCaseExecution(subCaseInstance.getId()) .close(); // then CaseExecution caseTask = queryCaseExecutionByActivityId(CASE_TASK_KEY); assertNull(caseTask); CaseInstance superCaseInstance = queryCaseInstanceByKey(DEFINITION_KEY); assertNotNull(superCaseInstance); assertTrue(superCaseInstance.isCompleted()); }
@Test @OperateOnDeployment("clientDeployment") public void testResolveBeanInCmmnCase() { CaseInstance caseInstance = caseService.withCaseDefinitionByKey("callingCase") .create(); CaseExecution caseTaskInstance = caseService.createCaseExecutionQuery().activityId("PI_CaseTask_1") .singleResult(); CaseExecution calledCaseHumanTaskInstance = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1") .singleResult(); Task calledCaseTask = taskService.createTaskQuery().singleResult(); taskService.complete(calledCaseTask.getId(), Variables.createVariables().putValue("var", "value")); CaseInstance calledInstance = caseService.createCaseInstanceQuery() .caseDefinitionKey("calledCase").singleResult(); caseService.withCaseExecution(calledInstance.getId()).close(); // then String variable = (String) caseService.getVariable(caseInstance.getId(), "var"); Assert.assertEquals("valuevalue", variable); } }