use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest 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();
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate();
HistoricVariableUpdate detailMock = builder.typedValue(variableValue).build();
when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(detailMock);
given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_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.rest.helper.MockHistoricVariableUpdateBuilder in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest method testGetSingleVariableUpdateSerialized.
@Test
public void testGetSingleVariableUpdateSerialized() {
ObjectValue serializedValue = Variables.serializedObjectValue("a serialized value").serializationDataFormat("aDataFormat").objectTypeName("aTypeName").create();
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate().typedValue(serializedValue);
HistoricVariableUpdate variableInstanceMock = builder.build();
when(historicDetailQueryMock.detailId(variableInstanceMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableBinaryFetching()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", builder.getId()).queryParam("deserializeValue", false).then().expect().statusCode(Status.OK.getStatusCode()).and().body("id", equalTo(builder.getId())).body("variableName", equalTo(builder.getName())).body("variableInstanceId", equalTo(builder.getVariableInstanceId())).body("variableType", equalTo(VariableTypeHelper.toExpectedValueTypeName(builder.getTypedValue().getType()))).body("value", equalTo("a serialized value")).body("valueInfo.serializationDataFormat", equalTo("aDataFormat")).body("valueInfo.objectTypeName", equalTo("aTypeName")).body("processDefinitionKey", equalTo(builder.getProcessDefinitionKey())).body("processDefinitionId", equalTo(builder.getProcessDefinitionId())).body("processInstanceId", equalTo(builder.getProcessInstanceId())).body("errorMessage", equalTo(builder.getErrorMessage())).body("activityInstanceId", equalTo(builder.getActivityInstanceId())).body("revision", equalTo(builder.getRevision())).body("time", equalTo(builder.getTime())).body("taskId", equalTo(builder.getTaskId())).body("executionId", equalTo(builder.getExecutionId())).body("caseDefinitionKey", equalTo(builder.getCaseDefinitionKey())).body("caseDefinitionId", equalTo(builder.getCaseDefinitionId())).body("caseInstanceId", equalTo(builder.getCaseInstanceId())).body("caseExecutionId", equalTo(builder.getCaseExecutionId())).body("tenantId", equalTo(builder.getTenantId())).when().get(HISTORIC_DETAIL_URL);
verify(historicDetailQueryMock, times(1)).disableBinaryFetching();
verify(historicDetailQueryMock, times(1)).disableCustomObjectDeserialization();
}
use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest method testGetSingleVariableInstanceForBinaryVariable.
@Test
public void testGetSingleVariableInstanceForBinaryVariable() {
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate();
HistoricVariableUpdate detailMock = builder.typedValue(Variables.byteArrayValue(null)).build();
when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableBinaryFetching()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(detailMock);
given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_ID).then().expect().statusCode(Status.OK.getStatusCode()).and().body("id", equalTo(builder.getId())).body("variableName", equalTo(builder.getName())).body("variableInstanceId", equalTo(builder.getVariableInstanceId())).body("variableType", 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("errorMessage", equalTo(builder.getErrorMessage())).body("activityInstanceId", equalTo(builder.getActivityInstanceId())).body("revision", equalTo(builder.getRevision())).body("time", equalTo(builder.getTime())).body("taskId", equalTo(builder.getTaskId())).body("executionId", equalTo(builder.getExecutionId())).body("caseDefinitionKey", equalTo(builder.getCaseDefinitionKey())).body("caseDefinitionId", equalTo(builder.getCaseDefinitionId())).body("caseInstanceId", equalTo(builder.getCaseInstanceId())).body("caseExecutionId", equalTo(builder.getCaseExecutionId())).body("tenantId", equalTo(builder.getTenantId())).when().get(HISTORIC_DETAIL_URL);
verify(historicDetailQueryMock, times(1)).disableBinaryFetching();
}
use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest method testBinaryDataForFileVariable.
@Test
public void testBinaryDataForFileVariable() {
String filename = "test.txt";
byte[] byteContent = "test".getBytes();
String encoding = "UTF-8";
FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create();
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate();
HistoricVariableUpdate detailMock = builder.typedValue(variableValue).build();
when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(detailMock);
Response response = given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_ID).then().expect().statusCode(Status.OK.getStatusCode()).body(is(equalTo(new String(byteContent)))).and().header("Content-Disposition", "attachment; filename=" + filename).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
// due to some problems with wildfly we gotta check this separately
String contentType = response.getContentType();
assertThat(contentType, is(either(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + "; charset=UTF-8")).or(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + ";charset=UTF-8"))));
verify(historicDetailQueryMock, never()).disableBinaryFetching();
}
use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest method testBinaryDataForBinaryVariable.
@Test
public void testBinaryDataForBinaryVariable() {
final byte[] byteContent = "some bytes".getBytes();
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate();
HistoricVariableUpdate detailMock = builder.typedValue(Variables.byteArrayValue(byteContent)).build();
when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(detailMock);
Response response = given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_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(historicDetailQueryMock, never()).disableBinaryFetching();
}
Aggregations