Search in sources :

Example 6 with FailingSerializable

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

the class HistoricVariableInstanceTest method testDisableCustomObjectDeserializationNativeQuery.

public void testDisableCustomObjectDeserializationNativeQuery() {
    // given
    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);
    // when
    List<HistoricVariableInstance> variableInstances = historyService.createNativeHistoricVariableInstanceQuery().sql("SELECT * from " + managementService.getTableName(HistoricVariableInstance.class)).disableCustomObjectDeserialization().list();
    // then
    assertEquals(2, variableInstances.size());
    for (HistoricVariableInstance variableInstance : variableInstances) {
        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());
    }
    taskService.deleteTask(newTask.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) CustomSerializable(org.camunda.bpm.engine.test.api.runtime.util.CustomSerializable)

Example 7 with FailingSerializable

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

the class HistoricVariableInstanceTest method testDisableCustomObjectDeserialization.

public void testDisableCustomObjectDeserialization() {
    // given
    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);
    // when
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery().disableCustomObjectDeserialization().list();
    // then
    assertEquals(2, variableInstances.size());
    for (HistoricVariableInstance variableInstance : variableInstances) {
        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());
    }
    taskService.deleteTask(newTask.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) CustomSerializable(org.camunda.bpm.engine.test.api.runtime.util.CustomSerializable)

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