public void terminateCaseExecution(String caseExecutionId) { withCaseExecution(caseExecutionId).terminate(); }
public void terminateCaseExecution(String caseExecutionId) { withCaseExecution(caseExecutionId).terminate(); }
public void terminateCaseExecution(String caseExecutionId, Map<String, Object> variables) { withCaseExecution(caseExecutionId).setVariables(variables).terminate(); } }
public void terminateCaseExecution(String caseExecutionId, Map<String, Object> variables) { withCaseExecution(caseExecutionId).setVariables(variables).terminate(); } }
public void testTerminateInvalidCaseExeuction() { try { caseService .withCaseExecution("invalid") .terminate(); fail("The case execution should not be found."); } catch (NotFoundException e) { } try { caseService .withCaseExecution(null) .terminate(); fail("The case execution should not be found."); } catch (NotValidException e) { } }
public void terminate(CaseExecutionTriggerDto triggerDto) { try { CaseService caseService = engine.getCaseService(); CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId); initializeCommand(commandBuilder, triggerDto, "terminate"); commandBuilder.terminate(); } catch (NotFoundException e) { throw createInvalidRequestException("terminate", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e); } catch (NotAllowedException e) { throw createInvalidRequestException("terminate", Status.FORBIDDEN, e); } catch (ProcessEngineException e) { throw createRestException("terminate", Status.INTERNAL_SERVER_ERROR, e); } }
@Test public void testUnsuccessfulTerminate() { doThrow(new NotValidException("expected exception")).when(caseExecutionCommandBuilderMock).terminate(); given() .pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_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 terminate case execution " + MockProvider.EXAMPLE_CASE_EXECUTION_ID + ": expected exception")) .when() .post(CASE_EXECUTION_TERMINATE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID); verify(caseExecutionCommandBuilderMock).terminate(); }
public void terminate(CaseExecutionTriggerDto triggerDto) { try { CaseService caseService = engine.getCaseService(); CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId); initializeCommand(commandBuilder, triggerDto, "terminate"); commandBuilder.terminate(); } catch (NotFoundException e) { throw createInvalidRequestException("terminate", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e); } catch (NotAllowedException e) { throw createInvalidRequestException("terminate", Status.FORBIDDEN, e); } catch (ProcessEngineException e) { throw createRestException("terminate", Status.INTERNAL_SERVER_ERROR, e); } }
public void terminate(CaseExecutionTriggerDto triggerDto) { try { CaseService caseService = engine.getCaseService(); CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseExecutionId); initializeCommand(commandBuilder, triggerDto, "terminate"); commandBuilder.terminate(); } catch (NotFoundException e) { throw createInvalidRequestException("terminate", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e); } catch (NotAllowedException e) { throw createInvalidRequestException("terminate", Status.FORBIDDEN, e); } catch (ProcessEngineException e) { throw createRestException("terminate", Status.INTERNAL_SERVER_ERROR, e); } }
public void terminate(CaseExecutionTriggerDto triggerDto) { try { CaseService caseService = engine.getCaseService(); CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseExecutionId); initializeCommand(commandBuilder, triggerDto, "terminate"); commandBuilder.terminate(); } catch (NotFoundException e) { throw createInvalidRequestException("terminate", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e); } catch (NotAllowedException e) { throw createInvalidRequestException("terminate", Status.FORBIDDEN, e); } catch (ProcessEngineException e) { throw createRestException("terminate", Status.INTERNAL_SERVER_ERROR, e); } }
@Test public void testUnsuccessfulTerminate() { doThrow(new NotValidException("expected exception")).when(caseExecutionCommandBuilderMock).terminate(); 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 terminate case instance " + MockProvider.EXAMPLE_CASE_INSTANCE_ID + ": expected exception")) .when() .post(CASE_INSTANCE_TERMINATE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).terminate(); }
@Test public void testTerminateWithRemoveVariable() { 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_TERMINATE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).removeVariable(aVariableKey); verify(caseExecutionCommandBuilderMock).removeVariable(anotherVariableKey); verify(caseExecutionCommandBuilderMock).terminate(); }
@Test public void testTerminateWithRemoveVariableAndVariableLocal() { 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_EXECUTION_ID) .contentType(ContentType.JSON) .body(variablesJson) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(CASE_EXECUTION_TERMINATE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID); verify(caseExecutionCommandBuilderMock).removeVariableLocal(aVariableKey); verify(caseExecutionCommandBuilderMock).removeVariable(anotherVariableKey); verify(caseExecutionCommandBuilderMock).terminate(); }
@Test public void testTerminate() { given() .pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID) .contentType(ContentType.JSON) .body(EMPTY_JSON_OBJECT) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(CASE_EXECUTION_TERMINATE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID); verify(caseExecutionCommandBuilderMock).terminate(); }
@Test public void testTerminate() { 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_TERMINATE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).terminate(); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testTerminate() { // given createCaseInstance(DEFINITION_KEY); CaseExecution caseTaskExecution = queryCaseExecutionByActivityId(CASE_TASK_KEY); // when caseService .withCaseExecution(caseTaskExecution.getId()) .terminate(); caseTaskExecution = queryCaseExecutionByActivityId(CASE_TASK_KEY); assertNull(caseTaskExecution); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneMilestoneCase.cmmn" }) public void testTerminate() { // given createCaseInstance(DEFINITION_KEY).getId(); String caseTaskId = queryCaseExecutionByActivityId(MILESTONE_KEY).getId(); caseService .withCaseExecution(caseTaskId) .terminate(); CaseExecution caseMilestone = queryCaseExecutionByActivityId(MILESTONE_KEY); assertNull(caseMilestone); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testTerminate() { // given createCaseInstance(DEFINITION_KEY); CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertTrue(processTask.isActive()); // when caseService .withCaseExecution(processTask.getId()) .terminate(); processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertNull(processTask); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testTerminate() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); // when caseService.withCaseExecution(taskExecution.getId()) .terminate(); // then taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); assertNull(taskExecution); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testTerminateActiveCaseInstance() { // given: String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); assertNotNull(queryCaseExecutionByActivityId("CasePlanModel_1")); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); assertTrue(taskExecution.isActive()); caseService.withCaseExecution(caseInstanceId) .terminate(); CaseExecution caseInstance = queryCaseExecutionByActivityId("CasePlanModel_1"); assertTrue(caseInstance.isTerminated()); assertNull(queryCaseExecutionByActivityId("PI_HumanTask_1")); }