Search in sources :

Example 1 with ProcessInstanceModificationInstantiationBuilder

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);
}
Also used : ProcessInstanceModificationInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder)

Example 2 with ProcessInstanceModificationInstantiationBuilder

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);
}
Also used : ProcessInstanceModificationInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder)

Example 3 with ProcessInstanceModificationInstantiationBuilder

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();
}
Also used : InOrder(org.mockito.InOrder) ProcessInstanceModificationInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) Map(java.util.Map) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap) EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) Test(org.junit.Test)

Example 4 with ProcessInstanceModificationInstantiationBuilder

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;
}
Also used : ProcessInstanceModificationInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder) Map(java.util.Map) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap) EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap)

Example 5 with ProcessInstanceModificationInstantiationBuilder

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);
}
Also used : ProcessInstanceModificationInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) Map(java.util.Map) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap) EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) Test(org.junit.Test)

Aggregations

ProcessInstanceModificationInstantiationBuilder (org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder)8 HashMap (java.util.HashMap)4 Map (java.util.Map)4 EqualsMap (org.camunda.bpm.engine.rest.helper.EqualsMap)4 VariableMap (org.camunda.bpm.engine.variable.VariableMap)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)3 InOrder (org.mockito.InOrder)2 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)1