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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations