Search in sources :

Example 1 with SpinRuntimeException

use of org.camunda.spin.SpinRuntimeException 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) {
    }
}
Also used : SpinRuntimeException(org.camunda.spin.SpinRuntimeException) XmlValue(org.camunda.spin.plugin.variable.value.XmlValue) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with SpinRuntimeException

use of org.camunda.spin.SpinRuntimeException in project camunda-bpm-platform by camunda.

the class JsonValueTest method testFailingDeserialization.

@Deployment(resources = ONE_TASK_PROCESS)
public void testFailingDeserialization() {
    // given
    JsonValue value = jsonValue(brokenJsonString).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
    JsonValue jsonValue = runtimeService.getVariableTyped(processInstanceId, variableName, false);
    assertFalse(jsonValue.isDeserialized());
    assertEquals(brokenJsonString, jsonValue.getValueSerialized());
    // but not the deserialized properties
    try {
        jsonValue.getValue();
        fail("exception expected");
    } catch (SpinRuntimeException e) {
    }
}
Also used : SpinRuntimeException(org.camunda.spin.SpinRuntimeException) JsonValue(org.camunda.spin.plugin.variable.value.JsonValue) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 SpinRuntimeException (org.camunda.spin.SpinRuntimeException)2 JsonValue (org.camunda.spin.plugin.variable.value.JsonValue)1 XmlValue (org.camunda.spin.plugin.variable.value.XmlValue)1