Search in sources :

Example 6 with ProcessInstanceModificationInstantiationBuilder

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"));
}
Also used : ProcessInstanceModificationInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest) Test(org.junit.Test)

Example 7 with ProcessInstanceModificationInstantiationBuilder

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

Example 8 with ProcessInstanceModificationInstantiationBuilder

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();
}
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)

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