use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testBinaryDataForBinaryVariable.
@Test
public void testBinaryDataForBinaryVariable() {
final byte[] byteContent = "some bytes".getBytes();
HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(Variables.byteArrayValue(byteContent)).build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.getStatusCode()).contentType(ContentType.BINARY.toString()).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
byte[] responseBytes = response.getBody().asByteArray();
Assert.assertEquals(new String(byteContent), new String(responseBytes));
verify(variableInstanceQueryMock, never()).disableBinaryFetching();
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstance.
@Test
public void testGetSingleVariableInstance() {
MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance();
HistoricVariableInstance variableInstanceMock = builder.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", builder.getId()).then().expect().statusCode(Status.OK.getStatusCode()).and().body("id", equalTo(builder.getId())).body("name", equalTo(builder.getName())).body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(builder.getTypedValue().getType()))).body("value", equalTo(builder.getValue())).body("processDefinitionKey", equalTo(builder.getProcessDefinitionKey())).body("processDefinitionId", equalTo(builder.getProcessDefinitionId())).body("processInstanceId", equalTo(builder.getProcessInstanceId())).body("executionId", equalTo(builder.getExecutionId())).body("errorMessage", equalTo(builder.getErrorMessage())).body("activityInstanceId", equalTo(builder.getActivityInstanceId())).body("caseDefinitionKey", equalTo(builder.getCaseDefinitionKey())).body("caseDefinitionId", equalTo(builder.getCaseDefinitionId())).body("caseInstanceId", equalTo(builder.getCaseInstanceId())).body("caseExecutionId", equalTo(builder.getCaseExecutionId())).body("taskId", equalTo(builder.getTaskId())).body("tenantId", equalTo(builder.getTenantId())).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 HistoricVariableInstanceQueryImpl method executeList.
public List<HistoricVariableInstance> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
ensureVariablesInitialized();
List<HistoricVariableInstance> historicVariableInstances = commandContext.getHistoricVariableInstanceManager().findHistoricVariableInstancesByQueryCriteria(this, page);
if (historicVariableInstances != null) {
for (HistoricVariableInstance historicVariableInstance : historicVariableInstances) {
HistoricVariableInstanceEntity variableInstanceEntity = (HistoricVariableInstanceEntity) historicVariableInstance;
if (shouldFetchValue(variableInstanceEntity)) {
try {
variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled);
} catch (Exception t) {
// do not fail if one of the variables fails to load
LOG.exceptionWhileGettingValueForVariable(t);
}
}
}
}
return historicVariableInstances;
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class RestartProcessInstancesCmd method collectLastVariables.
protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) {
HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService();
List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance.getId()).list();
VariableMap variables = new VariableMapImpl();
for (HistoricVariableInstance variable : historicVariables) {
variables.putValueTyped(variable.getName(), variable.getTypedValue());
}
return variables;
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class FormServiceTest method testSubmitTaskFormForStandaloneTask.
@Test
public void testSubmitTaskFormForStandaloneTask() {
// given
String id = "standaloneTask";
Task task = taskService.newTask(id);
taskService.saveTask(task);
// when
formService.submitTaskForm(task.getId(), Variables.createVariables().putValue("foo", "bar"));
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) {
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().taskIdIn(id).singleResult();
assertNotNull(variableInstance);
assertEquals("foo", variableInstance.getName());
assertEquals("bar", variableInstance.getValue());
}
taskService.deleteTask(id, true);
}
Aggregations