Search in sources :

Example 66 with ProcessEngineException

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
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 67 with ProcessEngineException

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());
    }
}
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) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 68 with ProcessEngineException

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());
    }
}
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) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 69 with ProcessEngineException

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) {
    }
}
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 70 with ProcessEngineException

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
    }
}
Also used : XmlValueBuilder(org.camunda.spin.plugin.variable.value.builder.XmlValueBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)611 Test (org.junit.Test)185 Deployment (org.camunda.bpm.engine.test.Deployment)138 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)79 HashMap (java.util.HashMap)62 RestException (org.camunda.bpm.engine.rest.exception.RestException)62 Matchers.anyString (org.mockito.Matchers.anyString)60 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)57 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)47 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)41 Task (org.camunda.bpm.engine.task.Task)40 ArrayList (java.util.ArrayList)39 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)36 Matchers.containsString (org.hamcrest.Matchers.containsString)35 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)22 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)21 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)21 NotValidException (org.camunda.bpm.engine.exception.NotValidException)19 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18