Search in sources :

Example 36 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class XmlSerializationTest method testSetSerializedVariableValueNullNoTypeName.

@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueNullNoTypeName() {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    SerializedObjectValueBuilder serializedValue = serializedObjectValue().serializationDataFormat(XML_FORMAT_NAME);
    // no objectTypeName specified
    runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
    // null can be retrieved
    XmlSerializable returnedBean = (XmlSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
    assertNull(returnedBean);
    // validate typed value metadata
    ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
    assertNull(typedValue.getValue());
    assertNull(typedValue.getValueSerialized());
    assertEquals(XML_FORMAT_NAME, typedValue.getSerializationDataFormat());
    assertNull(typedValue.getObjectTypeName());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) Variables.serializedObjectValue(org.camunda.bpm.engine.variable.Variables.serializedObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) SerializedObjectValueBuilder(org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 37 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class SpinScriptTaskSupportTest method testSpinAvailableInJavascript.

public void testSpinAvailableInJavascript() {
    deployProcess("javascript", "execution.setVariable('name',  S('<test />').name() )\n");
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");
    String var = (String) runtimeService.getVariable(pi.getId(), "name");
    assertEquals("test", var);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Example 38 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class DmnBusinessRuleTaskResultMappingTest method testCustomOutputMapping.

@Deployment(resources = { CUSTOM_MAPPING_BPMN, TEST_DECISION })
public void testCustomOutputMapping() {
    ProcessInstance processInstance = startTestProcess("multiple entries");
    assertEquals("foo", runtimeService.getVariable(processInstance.getId(), "result1"));
    assertEquals(Variables.stringValue("foo"), runtimeService.getVariableTyped(processInstance.getId(), "result1"));
    assertEquals("bar", runtimeService.getVariable(processInstance.getId(), "result2"));
    assertEquals(Variables.stringValue("bar"), runtimeService.getVariableTyped(processInstance.getId(), "result2"));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 39 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class FallbackSerializationTest method testSerializationOfUnknownFormat.

@Deployment(resources = ONE_TASK_PROCESS)
public void testSerializationOfUnknownFormat() {
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    // when
    ObjectValue objectValue = Variables.serializedObjectValue("foo").serializationDataFormat("application/foo").objectTypeName("org.camunda.Foo").create();
    runtimeService.setVariable(instance.getId(), "var", objectValue);
    // then
    try {
        runtimeService.getVariable(instance.getId(), "var");
        fail();
    } catch (ProcessEngineException e) {
        assertTextPresent("Fallback serializer cannot handle deserialized objects", e.getMessage());
    }
    ObjectValue returnedValue = runtimeService.getVariableTyped(instance.getId(), "var", false);
    assertFalse(returnedValue.isDeserialized());
    assertEquals("application/foo", returnedValue.getSerializationDataFormat());
    assertEquals("foo", returnedValue.getValueSerialized());
    assertEquals("org.camunda.Foo", returnedValue.getObjectTypeName());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 40 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class ProcessDefinitionResourceImpl method submitForm.

@Override
public ProcessInstanceDto submitForm(UriInfo context, StartProcessInstanceDto parameters) {
    FormService formService = engine.getFormService();
    ProcessInstance instance = null;
    try {
        Map<String, Object> variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
        String businessKey = parameters.getBusinessKey();
        if (businessKey != null) {
            instance = formService.submitStartForm(processDefinitionId, businessKey, variables);
        } else {
            instance = formService.submitStartForm(processDefinitionId, variables);
        }
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
    } catch (RestException e) {
        String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
        throw new InvalidRequestException(e.getStatus(), e, errorMessage);
    }
    ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance);
    URI uri = context.getBaseUriBuilder().path(rootResourcePath).path(ProcessInstanceRestService.PATH).path(instance.getId()).build();
    result.addReflexiveLink(uri, HttpMethod.GET, "self");
    return result;
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) RestartProcessInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.RestartProcessInstanceDto) ProcessInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto) StartProcessInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.StartProcessInstanceDto) FormService(org.camunda.bpm.engine.FormService) RestException(org.camunda.bpm.engine.rest.exception.RestException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) URI(java.net.URI) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2392 Deployment (org.camunda.bpm.engine.test.Deployment)1325 Test (org.junit.Test)1168 Task (org.camunda.bpm.engine.task.Task)660 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)415 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)372 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)258 HashMap (java.util.HashMap)235 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)203 Job (org.camunda.bpm.engine.runtime.Job)189 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)184 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)149 Execution (org.camunda.bpm.engine.runtime.Execution)144 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)130 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)129 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)122 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)86 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)84