use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class XmlValueTest method testFailingDeserialization.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailingDeserialization() {
// given
XmlValue value = xmlValue(brokenXmlString).create();
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
runtimeService.setVariable(processInstanceId, variableName, value);
try {
// when
runtimeService.getVariable(processInstanceId, variableName);
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
try {
runtimeService.getVariableTyped(processInstanceId, variableName);
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
// However, I can access the serialized value
XmlValue xmlValue = runtimeService.getVariableTyped(processInstanceId, variableName, false);
assertFalse(xmlValue.isDeserialized());
assertEquals(brokenXmlString, xmlValue.getValueSerialized());
// but not the deserialized properties
try {
xmlValue.getValue();
fail("exception expected");
} catch (SpinRuntimeException e) {
}
}
use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class XmlValueTest method testFailForNonExistingSerializationFormat.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailForNonExistingSerializationFormat() {
// given
XmlValueBuilder builder = xmlValue(xmlString).serializationDataFormat("non existing data format");
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
try {
// when (1)
runtimeService.setVariable(processInstanceId, variableName, builder);
fail("Exception expected");
} catch (ProcessEngineException e) {
// then (1)
assertTextPresent("Cannot find serializer for value", e.getMessage());
// happy path
}
try {
// when (2)
runtimeService.setVariable(processInstanceId, variableName, builder.create());
fail("Exception expected");
} catch (ProcessEngineException e) {
// then (2)
assertTextPresent("Cannot find serializer for value", e.getMessage());
// happy path
}
}
use of org.camunda.bpm.engine.test.Deployment 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.test.Deployment 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.test.Deployment in project camunda-bpm-platform by camunda.
the class JPASpringTest method testJpaVariableHappyPath.
@Deployment(resources = { "org/camunda/bpm/engine/spring/test/jpa/JPASpringTest.bpmn20.xml" })
public void testJpaVariableHappyPath() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("customerName", "John Doe");
variables.put("amount", 15000L);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("LoanRequestProcess", variables);
// Variable should be present containing the loanRequest created by the spring bean
Object value = runtimeService.getVariable(processInstance.getId(), "loanRequest");
assertNotNull(value);
assertTrue(value instanceof LoanRequest);
LoanRequest request = (LoanRequest) value;
assertEquals("John Doe", request.getCustomerName());
assertEquals(15000L, request.getAmount().longValue());
assertFalse(request.isApproved());
// We will approve the request, which will update the entity
variables = new HashMap<String, Object>();
variables.put("approvedByManager", Boolean.TRUE);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
taskService.complete(task.getId(), variables);
// If approved, the processsInstance should be finished, gateway based on loanRequest.approved value
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
Aggregations