use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class MockHistoricVariableInstanceBuilder method build.
public HistoricVariableInstance build() {
HistoricVariableInstance mockVariable = mock(HistoricVariableInstance.class);
when(mockVariable.getId()).thenReturn(id);
when(mockVariable.getName()).thenReturn(name);
when(mockVariable.getVariableName()).thenReturn(name);
when(mockVariable.getTypeName()).thenReturn(value.getType().getName());
when(mockVariable.getVariableTypeName()).thenReturn(value.getType().getName());
if (ObjectValue.class.isAssignableFrom(value.getClass())) {
ObjectValue objectValue = (ObjectValue) value;
if (objectValue.isDeserialized()) {
when(mockVariable.getValue()).thenReturn(value.getValue());
} else {
when(mockVariable.getValue()).thenReturn(null);
}
} else {
when(mockVariable.getValue()).thenReturn(value.getValue());
}
when(mockVariable.getTypedValue()).thenReturn(value);
when(mockVariable.getProcessDefinitionKey()).thenReturn(processDefinitionKey);
when(mockVariable.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId);
when(mockVariable.getExecutionId()).thenReturn(executionId);
when(mockVariable.getErrorMessage()).thenReturn(errorMessage);
when(mockVariable.getActivtyInstanceId()).thenReturn(activityInstanceId);
when(mockVariable.getActivityInstanceId()).thenReturn(activityInstanceId);
when(mockVariable.getCaseDefinitionKey()).thenReturn(caseDefinitionKey);
when(mockVariable.getCaseDefinitionId()).thenReturn(caseDefinitionId);
when(mockVariable.getCaseInstanceId()).thenReturn(caseInstanceId);
when(mockVariable.getCaseExecutionId()).thenReturn(caseExecutionId);
when(mockVariable.getTaskId()).thenReturn(taskId);
when(mockVariable.getTenantId()).thenReturn(tenantId);
return mockVariable;
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableJsonSerializationTest method testSelectHistoricVariableInstances.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSelectHistoricVariableInstances() throws JSONException {
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
JsonSerializable bean = new JsonSerializable("a String", 42, false);
runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(bean).serializationDataFormat(JSON_FORMAT_NAME).create());
HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult();
assertNotNull(historicVariable.getValue());
assertNull(historicVariable.getErrorMessage());
assertEquals(ValueType.OBJECT.getName(), historicVariable.getTypeName());
assertEquals(ValueType.OBJECT.getName(), historicVariable.getVariableTypeName());
JsonSerializable historyValue = (JsonSerializable) historicVariable.getValue();
assertEquals(bean.getStringProperty(), historyValue.getStringProperty());
assertEquals(bean.getIntProperty(), historyValue.getIntProperty());
assertEquals(bean.getBooleanProperty(), historyValue.getBooleanProperty());
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testGetBinaryDataForNullFileVariable.
@Test
public void testGetBinaryDataForNullFileVariable() {
String filename = "test.txt";
byte[] byteContent = null;
FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).create();
HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(variableValue).build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.getStatusCode()).and().contentType(ContentType.TEXT).and().body(is(equalTo(new String()))).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstanceForBinaryVariable.
@Test
public void testGetSingleVariableInstanceForBinaryVariable() {
MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance();
HistoricVariableInstance variableInstanceMock = builder.typedValue(Variables.byteArrayValue(null)).build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.getStatusCode()).and().body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.BYTES))).body("value", nullValue()).when().get(VARIABLE_INSTANCE_URL);
verify(variableInstanceQueryMock, times(1)).disableBinaryFetching();
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testBinaryDataForNonBinaryVariable.
@Test
public void testBinaryDataForNonBinaryVariable() {
HistoricVariableInstance variableInstanceMock = MockProvider.createMockHistoricVariableInstance();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body(containsString("Value of variable with id " + variableInstanceMock.getId() + " is not a binary value")).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
verify(variableInstanceQueryMock, never()).disableBinaryFetching();
}
Aggregations