Search in sources :

Example 1 with FailingSerializable

use of org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable in project camunda-bpm-platform by camunda.

the class VariableInstanceQueryTest method testDisableCustomObjectDeserialization.

@Test
public void testDisableCustomObjectDeserialization() {
    // given
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("customSerializable", new CustomSerializable());
    variables.put("failingSerializable", new FailingSerializable());
    Task task = taskService.newTask();
    taskService.saveTask(task);
    taskService.setVariablesLocal(task.getId(), variables);
    // when
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().disableCustomObjectDeserialization();
    // then
    List<VariableInstance> results = query.list();
    // both variables are not deserialized, but their serialized values are available
    assertEquals(2, results.size());
    for (VariableInstance variableInstance : results) {
        assertNull(variableInstance.getErrorMessage());
        ObjectValue typedValue = (ObjectValue) variableInstance.getTypedValue();
        assertNotNull(typedValue);
        assertFalse(typedValue.isDeserialized());
        // cannot access the deserialized value
        try {
            typedValue.getValue();
        } catch (IllegalStateException e) {
            assertTextPresent("Object is not deserialized", e.getMessage());
        }
        assertNotNull(typedValue.getValueSerialized());
    }
    // delete task
    taskService.deleteTask(task.getId(), true);
}
Also used : FailingSerializable(org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable) Task(org.camunda.bpm.engine.task.Task) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) HashMap(java.util.HashMap) CustomSerializable(org.camunda.bpm.engine.test.api.runtime.util.CustomSerializable) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 2 with FailingSerializable

use of org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable in project camunda-bpm-platform by camunda.

the class FullHistoryTest method testDisableCustomObjectDeserialization.

@Test
public void testDisableCustomObjectDeserialization() {
    Task newTask = taskService.newTask();
    taskService.saveTask(newTask);
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("customSerializable", new CustomSerializable());
    variables.put("failingSerializable", new FailingSerializable());
    taskService.setVariables(newTask.getId(), variables);
    List<HistoricDetail> results = historyService.createHistoricDetailQuery().disableBinaryFetching().disableCustomObjectDeserialization().variableUpdates().list();
    // both variables are not deserialized, but their serialized values are available
    assertEquals(2, results.size());
    for (HistoricDetail update : results) {
        HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) update;
        assertNull(variableUpdate.getErrorMessage());
        ObjectValue typedValue = (ObjectValue) variableUpdate.getTypedValue();
        assertNotNull(typedValue);
        assertFalse(typedValue.isDeserialized());
        // cannot access the deserialized value
        try {
            typedValue.getValue();
        } catch (IllegalStateException e) {
            Assert.assertThat(e.getMessage(), CoreMatchers.containsString("Object is not deserialized"));
        }
        assertNotNull(typedValue.getValueSerialized());
    }
    taskService.deleteTask(newTask.getId(), true);
}
Also used : FailingSerializable(org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable) HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) HashMap(java.util.HashMap) CustomSerializable(org.camunda.bpm.engine.test.api.runtime.util.CustomSerializable) Test(org.junit.Test)

Example 3 with FailingSerializable

use of org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable in project camunda-bpm-platform by camunda.

the class FullHistoryTest method testErrorMessage.

@Test
public void testErrorMessage() {
    Task newTask = taskService.newTask();
    taskService.saveTask(newTask);
    String variableName = "failingSerializable";
    taskService.setVariable(newTask.getId(), variableName, new FailingSerializable());
    HistoricDetail result = historyService.createHistoricDetailQuery().disableBinaryFetching().variableUpdates().singleResult();
    assertNull(((HistoricVariableUpdate) result).getValue());
    assertNotNull(((HistoricVariableUpdate) result).getErrorMessage());
    taskService.deleteTask(newTask.getId(), true);
}
Also used : FailingSerializable(org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test)

Example 4 with FailingSerializable

use of org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable in project camunda-bpm-platform by camunda.

the class VariableInstanceQueryTest method testSerializableErrorMessage.

@Test
public void testSerializableErrorMessage() {
    // given
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("customSerializable", new CustomSerializable());
    variables.put("failingSerializable", new FailingSerializable());
    Task task = taskService.newTask();
    taskService.saveTask(task);
    taskService.setVariablesLocal(task.getId(), variables);
    // when
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
    // then
    List<VariableInstance> results = query.list();
    // both variables are fetched
    assertEquals(2, results.size());
    for (VariableInstance variableInstance : results) {
        if (variableInstance.getName().equals("customSerializable")) {
            assertNotNull(variableInstance.getValue());
            assertTrue(variableInstance.getValue() instanceof CustomSerializable);
        }
        if (variableInstance.getName().equals("failingSerializable")) {
            // no value was fetched
            assertNull(variableInstance.getValue());
            // error message is present
            assertNotNull(variableInstance.getErrorMessage());
        }
    }
    // delete task
    taskService.deleteTask(task.getId(), true);
}
Also used : FailingSerializable(org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable) Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) CustomSerializable(org.camunda.bpm.engine.test.api.runtime.util.CustomSerializable) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 5 with FailingSerializable

use of org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceTest method testErrorMessage.

public void testErrorMessage() {
    Task newTask = taskService.newTask();
    taskService.saveTask(newTask);
    String variableName = "failingSerializable";
    taskService.setVariable(newTask.getId(), variableName, new FailingSerializable());
    HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName(variableName).singleResult();
    assertNull(variableInstance.getValue());
    assertNotNull(variableInstance.getErrorMessage());
    taskService.deleteTask(newTask.getId(), true);
}
Also used : FailingSerializable(org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable) Task(org.camunda.bpm.engine.task.Task)

Aggregations

Task (org.camunda.bpm.engine.task.Task)7 FailingSerializable (org.camunda.bpm.engine.test.api.runtime.util.FailingSerializable)7 CustomSerializable (org.camunda.bpm.engine.test.api.runtime.util.CustomSerializable)5 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)2 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)2 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)2 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)1