public void removeVariables(String caseExecutionId, Collection<String> variableNames) { withCaseExecution(caseExecutionId).removeVariables(variableNames).execute(); }
@Before public void setUpRuntime() { CaseExecution mockCaseExecution = MockProvider.createMockCaseExecution(); caseServiceMock = mock(CaseService.class); when(processEngine.getCaseService()).thenReturn(caseServiceMock); caseExecutionQueryMock = mock(CaseExecutionQuery.class); when(caseServiceMock.createCaseExecutionQuery()).thenReturn(caseExecutionQueryMock); when(caseExecutionQueryMock.caseExecutionId(MockProvider.EXAMPLE_CASE_EXECUTION_ID)).thenReturn(caseExecutionQueryMock); when(caseExecutionQueryMock.singleResult()).thenReturn(mockCaseExecution); when(caseServiceMock.getVariableTyped(anyString(), anyString(), eq(true))).thenReturn(EXAMPLE_VARIABLE_VALUE); when(caseServiceMock.getVariablesTyped(anyString(), eq(true))).thenReturn(EXAMPLE_VARIABLES); when(caseServiceMock.getVariableLocalTyped(anyString(), eq(EXAMPLE_VARIABLE_KEY), anyBoolean())).thenReturn(EXAMPLE_VARIABLE_VALUE); when(caseServiceMock.getVariableLocalTyped(anyString(), eq(EXAMPLE_BYTES_VARIABLE_KEY), eq(false))).thenReturn(EXAMPLE_VARIABLE_VALUE_BYTES); when(caseServiceMock.getVariablesLocalTyped(anyString(), eq(true))).thenReturn(EXAMPLE_VARIABLES); when(caseServiceMock.getVariablesTyped(anyString(), Matchers.<Collection<String>>any(), eq(true))).thenReturn(EXAMPLE_VARIABLES); when(caseServiceMock.getVariablesLocalTyped(anyString(), Matchers.<Collection<String>>any(), eq(true))).thenReturn(EXAMPLE_VARIABLES); caseExecutionCommandBuilderMock = mock(CaseExecutionCommandBuilder.class); when(caseServiceMock.withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID)).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.setVariable(anyString(), any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.setVariableLocal(anyString(), any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.setVariables(Matchers.<Map<String, Object>>any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.setVariablesLocal(Matchers.<Map<String, Object>>any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.removeVariable(anyString())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.removeVariableLocal(anyString())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.removeVariables(Matchers.<Collection<String>>any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.removeVariablesLocal(Matchers.<Collection<String>>any())).thenReturn(caseExecutionCommandBuilderMock); }
public void removeVariables(String caseExecutionId, Collection<String> variableNames) { withCaseExecution(caseExecutionId).removeVariables(variableNames).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(); }
@Before public void setUpRuntime() { CaseInstance mockCaseInstance = MockProvider.createMockCaseInstance(); caseServiceMock = mock(CaseService.class); when(processEngine.getCaseService()).thenReturn(caseServiceMock); caseInstanceQueryMock = mock(CaseInstanceQuery.class); when(caseServiceMock.createCaseInstanceQuery()).thenReturn(caseInstanceQueryMock); when(caseInstanceQueryMock.caseInstanceId(MockProvider.EXAMPLE_CASE_INSTANCE_ID)).thenReturn(caseInstanceQueryMock); when(caseInstanceQueryMock.singleResult()).thenReturn(mockCaseInstance); when(caseServiceMock.getVariableTyped(anyString(), eq(EXAMPLE_VARIABLE_KEY), anyBoolean())).thenReturn(EXAMPLE_VARIABLE_VALUE); when(caseServiceMock.getVariableTyped(anyString(), eq(EXAMPLE_BYTES_VARIABLE_KEY), eq(false))).thenReturn(EXAMPLE_VARIABLE_VALUE_BYTES); when(caseServiceMock.getVariablesTyped(anyString(), eq(true))).thenReturn(EXAMPLE_VARIABLES); when(caseServiceMock.getVariablesTyped(anyString(), Matchers.<Collection<String>>any(), eq(true))).thenReturn(EXAMPLE_VARIABLES); caseExecutionCommandBuilderMock = mock(CaseExecutionCommandBuilder.class); when(caseServiceMock.withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID)).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.setVariable(anyString(), any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.setVariables(Matchers.<Map<String, Object>>any())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.removeVariable(anyString())).thenReturn(caseExecutionCommandBuilderMock); when(caseExecutionCommandBuilderMock.removeVariables(Matchers.<Collection<String>>any())).thenReturn(caseExecutionCommandBuilderMock); }
@Test public void testVariableModification() { Map<String, Object> messageBodyJson = new HashMap<String, Object>(); String variableKey = "aKey"; int variableValue = 123; Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables(); messageBodyJson.put("modifications", modifications); List<String> deletions = new ArrayList<String>(); deletions.add("deleteKey"); messageBodyJson.put("deletions", deletions); given() .pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID) .contentType(ContentType.JSON) .body(messageBodyJson) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(CASE_EXECUTION_VARIABLES_URL); Map<String, Object> expectedMap = new HashMap<String, Object>(); expectedMap.put(variableKey, variableValue); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID); verify(caseExecutionCommandBuilderMock).removeVariables(eq(deletions)); verify(caseExecutionCommandBuilderMock).setVariables(eq(expectedMap)); verify(caseExecutionCommandBuilderMock).execute(); }
@Test public void testVariableModification() { String variableKey = "aKey"; int variableValue = 123; Map<String, Object> messageBodyJson = new HashMap<String, Object>(); Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables(); messageBodyJson.put("modifications", modifications); List<String> deletions = new ArrayList<String>(); deletions.add("deleteKey"); messageBodyJson.put("deletions", deletions); given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).contentType(ContentType.JSON).body(messageBodyJson) .then().expect().statusCode(Status.NO_CONTENT.getStatusCode()) .when().post(CASE_INSTANCE_VARIABLES_URL); Map<String, Object> expectedModifications = new HashMap<String, Object>(); expectedModifications.put(variableKey, variableValue); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID); verify(caseExecutionCommandBuilderMock).setVariables(eq(expectedModifications)); verify(caseExecutionCommandBuilderMock).removeVariables(eq(deletions)); verify(caseExecutionCommandBuilderMock).execute(); }
@Test public void testEmptyVariableModification() { 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_VARIABLES_URL); verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID); verify(caseExecutionCommandBuilderMock).removeVariables(null); verify(caseExecutionCommandBuilderMock).setVariables(null); verify(caseExecutionCommandBuilderMock).execute(); }
verify(caseExecutionCommandBuilderMock).removeVariables(null); verify(caseExecutionCommandBuilderMock).setVariables(eq(expectedMap)); verify(caseExecutionCommandBuilderMock).execute();
.removeVariables(variableNames) .execute();
.removeVariables(variableNames) .removeVariable("aThirdVariable") .execute();
.removeVariables(variableNames) .removeVariableLocal("aThirdVariable") .execute();
public void removeVariables(String caseExecutionId, Collection<String> variableNames) { withCaseExecution(caseExecutionId).removeVariables(variableNames).execute(); }
protected void updateVariableEntities(VariableMap variables, List<String> deletions) { CaseService caseService = engine.getCaseService(); caseService .withCaseExecution(resourceId) .setVariables(variables) .removeVariables(deletions) .execute(); }
.removeVariables(variableNames) .execute();
.removeVariables(variableNames) .removeVariable("aThirdVariable") .execute();
.removeVariables(variableNames) .removeVariableLocal("aThirdVariable") .execute();