use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class StartAfterInstructionDto method applyTo.
@Override
public void applyTo(ProcessInstanceModificationBuilder builder, ProcessEngine engine, ObjectMapper mapper) {
checkValidity();
ProcessInstanceModificationInstantiationBuilder activityBuilder = null;
if (ancestorActivityInstanceId != null) {
activityBuilder = builder.startAfterActivity(activityId, ancestorActivityInstanceId);
} else {
activityBuilder = builder.startAfterActivity(activityId);
}
applyVariables(activityBuilder, engine, mapper);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class StartBeforeInstructionDto method applyTo.
@Override
public void applyTo(ProcessInstanceModificationBuilder builder, ProcessEngine engine, ObjectMapper mapper) {
checkValidity();
ProcessInstanceModificationInstantiationBuilder activityBuilder = null;
if (ancestorActivityInstanceId != null) {
activityBuilder = builder.startBeforeActivity(activityId, ancestorActivityInstanceId);
} else {
activityBuilder = builder.startBeforeActivity(activityId);
}
applyVariables(activityBuilder, engine, mapper);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testProcessInstanceModification.
@Test
public void testProcessInstanceModification() {
ProcessInstanceModificationInstantiationBuilder mockModificationBuilder = setUpMockModificationBuilder();
when(runtimeServiceMock.createProcessInstanceModification(anyString())).thenReturn(mockModificationBuilder);
Map<String, Object> json = new HashMap<String, Object>();
json.put("skipCustomListeners", true);
json.put("skipIoMappings", true);
List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
instructions.add(ModificationInstructionBuilder.cancellation().activityId("activityId").getJson());
instructions.add(ModificationInstructionBuilder.cancellation().activityInstanceId("activityInstanceId").getJson());
instructions.add(ModificationInstructionBuilder.cancellation().transitionInstanceId("transitionInstanceId").getJson());
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").getJson());
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").ancestorActivityInstanceId("ancestorActivityInstanceId").getJson());
instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").getJson());
instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").ancestorActivityInstanceId("ancestorActivityInstanceId").getJson());
instructions.add(ModificationInstructionBuilder.startTransition().transitionId("transitionId").getJson());
instructions.add(ModificationInstructionBuilder.startTransition().transitionId("transitionId").ancestorActivityInstanceId("ancestorActivityInstanceId").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).cancelAllForActivity("activityId");
inOrder.verify(mockModificationBuilder).cancelActivityInstance("activityInstanceId");
inOrder.verify(mockModificationBuilder).cancelTransitionInstance("transitionInstanceId");
inOrder.verify(mockModificationBuilder).startBeforeActivity("activityId");
inOrder.verify(mockModificationBuilder).startBeforeActivity("activityId", "ancestorActivityInstanceId");
inOrder.verify(mockModificationBuilder).startAfterActivity("activityId");
inOrder.verify(mockModificationBuilder).startAfterActivity("activityId", "ancestorActivityInstanceId");
inOrder.verify(mockModificationBuilder).startTransition("transitionId");
inOrder.verify(mockModificationBuilder).startTransition("transitionId", "ancestorActivityInstanceId");
inOrder.verify(mockModificationBuilder).execute(true, true);
inOrder.verifyNoMoreInteractions();
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method setUpMockModificationBuilder.
@SuppressWarnings("unchecked")
protected ProcessInstanceModificationInstantiationBuilder setUpMockModificationBuilder() {
ProcessInstanceModificationInstantiationBuilder mockModificationBuilder = mock(ProcessInstanceModificationInstantiationBuilder.class);
when(mockModificationBuilder.cancelActivityInstance(anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.cancelAllForActivity(anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.startAfterActivity(anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.startAfterActivity(anyString(), anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.startBeforeActivity(anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.startBeforeActivity(anyString(), anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.startTransition(anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.startTransition(anyString(), anyString())).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.setVariables(any(Map.class))).thenReturn(mockModificationBuilder);
when(mockModificationBuilder.setVariablesLocal(any(Map.class))).thenReturn(mockModificationBuilder);
return mockModificationBuilder;
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testModifyProcessInstanceThrowsAuthorizationException.
@Test
public void testModifyProcessInstanceThrowsAuthorizationException() {
ProcessInstanceModificationInstantiationBuilder mockModificationBuilder = setUpMockModificationBuilder();
when(runtimeServiceMock.createProcessInstanceModification(anyString())).thenReturn(mockModificationBuilder);
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(mockModificationBuilder).execute(anyBoolean(), anyBoolean());
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.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(PROCESS_INSTANCE_MODIFICATION_URL);
}
Aggregations