public void setVariableLocal(String caseExecutionId, String variableName, Object value) { withCaseExecution(caseExecutionId).setVariableLocal(variableName, value).execute(); }
public void removeVariable(String caseExecutionId, String variableName) { withCaseExecution(caseExecutionId).removeVariable(variableName).execute(); }
protected void removeVariableEntity(String variableKey) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .removeVariable(variableKey) .execute(); }
protected void removeVariableEntity(String variableKey) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .removeVariableLocal(variableKey) .execute(); }
protected void removeVariableEntity(String variableKey) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .removeVariableLocal(variableKey) .execute(); }
protected void setVariableEntity(String variableKey, TypedValue variableValue) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariable(variableKey, variableValue) .execute(); }
protected void removeVariableEntity(String variableKey) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .removeVariable(variableKey) .execute(); }
protected void setVariableEntity(String variableKey, TypedValue variableValue) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariable(variableKey, variableValue) .execute(); }
protected void setVariableEntity(String variableKey, TypedValue variableValue) { CaseService caseService = engine.getCaseService(); caseService.withCaseExecution(resourceId) .setVariableLocal(variableKey, variableValue) .execute(); }
protected void setVariableEntity(String variableKey, TypedValue variableValue) { CaseService caseService = engine.getCaseService(); caseService.withCaseExecution(resourceId) .setVariableLocal(variableKey, variableValue) .execute(); }
protected void updateVariableEntities(VariableMap variables, List<String> deletions) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariablesLocal(variables) .removeVariablesLocal(deletions) .execute(); }
protected void updateVariableEntities(VariableMap variables, List<String> deletions) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariables(variables) .removeVariables(deletions) .execute(); }
protected void updateVariableEntities(VariableMap variables, List<String> deletions) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariables(variables) .removeVariables(deletions) .execute(); }
protected void updateVariableEntities(VariableMap variables, List<String> deletions) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariablesLocal(variables) .removeVariablesLocal(deletions) .execute(); }
@Test public void testDeleteVariableForNonExistingInstance() { String variableKey = "aVariableKey"; doThrow(new ProcessEngineException("expected exception")).when(caseExecutionCommandBuilderMock).execute(); given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).pathParam("varId", variableKey) .then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(RestException.class.getSimpleName())) .body("message", is("Cannot delete case execution variable " + variableKey + ": expected exception")) .when().delete(SINGLE_CASE_INSTANCE_VARIABLE_URL); }
@Test public void testDeleteSingleVariable() { String variableKey = "aVariableKey"; given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).pathParam("varId", variableKey) .then().expect().statusCode(Status.NO_CONTENT.getStatusCode()) .when().delete(SINGLE_CASE_INSTANCE_VARIABLE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).removeVariable(variableKey); verify(caseExecutionCommandBuilderMock).execute(); }
@Test public void testPutVariableForNonExistingInstance() { String variableKey = "aVariableKey"; String variableValue = "aVariableValue"; Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue); doThrow(new ProcessEngineException("expected exception")).when(caseExecutionCommandBuilderMock).execute(); given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).pathParam("varId", variableKey) .contentType(ContentType.JSON).body(variableJson) .then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(RestException.class.getSimpleName())) .body("message", is("Cannot put case execution variable " + variableKey + ": expected exception")) .when().put(SINGLE_CASE_INSTANCE_VARIABLE_URL); }
@Test public void testPutSingleVariableWithNoValue() { String variableKey = "aVariableKey"; given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).pathParam("varId", variableKey) .contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT) .then().expect().statusCode(Status.NO_CONTENT.getStatusCode()) .when().put(SINGLE_CASE_INSTANCE_VARIABLE_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).setVariable(eq(variableKey), argThat(EqualsNullValue.matcher())); verify(caseExecutionCommandBuilderMock).execute(); }
@Deployment public void testChildListenersNotInvoked() { CaseInstance caseInstance = caseService .withCaseDefinitionByKey("case") .create(); // when i set a variable on the parent scope caseService.withCaseExecution(caseInstance.getId()).setVariableLocal("aTaskVariable", "aTaskValue").execute(); // then the listener is not invoked assertEquals(0, LogVariableListener.getInvocations().size()); LogVariableListener.reset(); }
@Deployment public void testDelegateInstanceIsProcessEngineAware() { CaseInstance caseInstance = caseService .withCaseDefinitionByKey("case") .create(); assertFalse(ProcessEngineAwareListener.hasFoundValidRuntimeService()); // when i set a variable that causes the listener to be notified caseService.withCaseExecution(caseInstance.getId()).setVariableLocal("aTaskVariable", "aTaskValue").execute(); // then the listener is invoked and has found process engine services assertTrue(ProcessEngineAwareListener.hasFoundValidRuntimeService()); ProcessEngineAwareListener.reset(); }