use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JsonSerializationTest method testFailForNonExistingSerializationFormat.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailForNonExistingSerializationFormat() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
JsonSerializable jsonSerializable = new JsonSerializable();
try {
runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(jsonSerializable).serializationDataFormat("non existing data format"));
fail("Exception expected");
} catch (ProcessEngineException e) {
assertTextPresent("Cannot find serializer for value", e.getMessage());
// happy path
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JsonSerializationTest method testFailingDeserialization.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailingDeserialization() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
FailingDeserializationBean failingBean = new FailingDeserializationBean("a String", 42, true);
runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(failingBean).serializationDataFormat(JSON_FORMAT_NAME));
try {
runtimeService.getVariable(instance.getId(), "simpleBean");
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
try {
runtimeService.getVariableTyped(instance.getId(), "simpleBean");
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
// However, I can access the serialized value
ObjectValue objectValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean", false);
assertFalse(objectValue.isDeserialized());
assertNotNull(objectValue.getObjectTypeName());
assertNotNull(objectValue.getValueSerialized());
// but not the deserialized properties
try {
objectValue.getValue();
fail("exception expected");
} catch (IllegalStateException e) {
assertTextPresent("Object is not deserialized", e.getMessage());
}
try {
objectValue.getValue(JsonSerializable.class);
fail("exception expected");
} catch (IllegalStateException e) {
assertTextPresent("Object is not deserialized", e.getMessage());
}
try {
objectValue.getObjectType();
fail("exception expected");
} catch (IllegalStateException e) {
assertTextPresent("Object is not deserialized", e.getMessage());
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testFailingDeserialization.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailingDeserialization() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
FailingXmlDeserializationBean failingBean = new FailingXmlDeserializationBean("a String", 42, true);
runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(failingBean).serializationDataFormat(XML_FORMAT_NAME));
try {
runtimeService.getVariable(instance.getId(), "simpleBean");
fail("exception expected");
} catch (ProcessEngineException e) {
assertTextPresent("Cannot deserialize object in variable 'simpleBean'", e.getMessage());
}
try {
runtimeService.getVariableTyped(instance.getId(), "simpleBean");
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
// However, I can access the serialized value
ObjectValue objectValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean", false);
assertFalse(objectValue.isDeserialized());
assertNotNull(objectValue.getObjectTypeName());
assertNotNull(objectValue.getValueSerialized());
// but not the deserialized properties
try {
objectValue.getValue();
fail("exception expected");
} catch (IllegalStateException e) {
assertTextPresent("Object is not deserialized", e.getMessage());
}
try {
objectValue.getValue(XmlSerializable.class);
fail("exception expected");
} catch (IllegalStateException e) {
assertTextPresent("Object is not deserialized", e.getMessage());
}
try {
objectValue.getObjectType();
fail("exception expected");
} catch (IllegalStateException e) {
assertTextPresent("Object is not deserialized", e.getMessage());
}
}
use of org.camunda.bpm.engine.ProcessEngineException 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.ProcessEngineException 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
}
}
Aggregations