use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class ModificationContextSwitchTest method testModificationClassloading.
@Test
@OperateOnDeployment("clientDeployment")
public void testModificationClassloading() {
// given
// process instance is in state "waitState"
String pi = runtimeService.startProcessInstanceByKey("testProcess").getId();
Assert.assertNull(runtimeService.getVariable(pi, "executed"));
// if
// we modify the process instance to start the next task:
ProcessInstanceModificationInstantiationBuilder modification = runtimeService.createProcessInstanceModification(pi).startBeforeActivity("ServiceTask_1");
// then
// the modification does not fail
modification.execute();
Assert.assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class StartTransitionInstructionDto method applyTo.
@Override
public void applyTo(ProcessInstanceModificationBuilder builder, ProcessEngine engine, ObjectMapper mapper) {
checkValidity();
ProcessInstanceModificationInstantiationBuilder activityBuilder = null;
if (ancestorActivityInstanceId != null) {
activityBuilder = builder.startTransition(transitionId, ancestorActivityInstanceId);
} else {
activityBuilder = builder.startTransition(transitionId);
}
applyVariables(activityBuilder, engine, mapper);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testProcessInstanceModificationWithVariables.
@Test
public void testProcessInstanceModificationWithVariables() {
ProcessInstanceModificationInstantiationBuilder mockModificationBuilder = setUpMockModificationBuilder();
when(runtimeServiceMock.createProcessInstanceModification(anyString())).thenReturn(mockModificationBuilder);
Map<String, Object> json = new HashMap<String, Object>();
List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").variables(VariablesBuilder.create().variable("var", "value", "String", false).variable("varLocal", "valueLocal", "String", true).getVariables()).getJson());
instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").variables(VariablesBuilder.create().variable("var", 52, "Integer", false).variable("varLocal", 74, "Integer", true).getVariables()).getJson());
json.put("instructions", instructions);
given().pathParam("id", EXAMPLE_PROCESS_INSTANCE_ID).contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(PROCESS_INSTANCE_MODIFICATION_URL);
verify(runtimeServiceMock).createProcessInstanceModification(eq(EXAMPLE_PROCESS_INSTANCE_ID));
InOrder inOrder = inOrder(mockModificationBuilder);
inOrder.verify(mockModificationBuilder).startBeforeActivity("activityId");
verify(mockModificationBuilder).setVariableLocal(eq("varLocal"), argThat(EqualsPrimitiveValue.stringValue("valueLocal")));
verify(mockModificationBuilder).setVariable(eq("var"), argThat(EqualsPrimitiveValue.stringValue("value")));
inOrder.verify(mockModificationBuilder).startAfterActivity("activityId");
verify(mockModificationBuilder).setVariable(eq("var"), argThat(EqualsPrimitiveValue.integerValue(52)));
verify(mockModificationBuilder).setVariableLocal(eq("varLocal"), argThat(EqualsPrimitiveValue.integerValue(74)));
inOrder.verify(mockModificationBuilder).execute(false, false);
inOrder.verifyNoMoreInteractions();
}
Aggregations