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