Search in sources :

Example 46 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableJsonSerializationTest method testSelectHistoricSerializedValues.

@Deployment(resources = ONE_TASK_PROCESS)
public void testSelectHistoricSerializedValues() 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));
        HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult();
        assertNotNull(historicVariable.getValue());
        assertNull(historicVariable.getErrorMessage());
        ObjectValue typedValue = (ObjectValue) historicVariable.getTypedValue();
        assertEquals(JSON_FORMAT_NAME, typedValue.getSerializationDataFormat());
        JSONAssert.assertEquals(bean.toExpectedJsonString(), new String(typedValue.getValueSerialized()), true);
        assertEquals(JsonSerializable.class.getName(), typedValue.getObjectTypeName());
    }
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 47 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class ProcessEngineRestServiceTest method testHistoryServiceEngineAccess_HistoricVariableInstanceBinaryFile.

@Ignore
@Test
public void testHistoryServiceEngineAccess_HistoricVariableInstanceBinaryFile() {
    HistoricVariableInstanceQuery query = mock(HistoricVariableInstanceQuery.class);
    HistoricVariableInstance instance = mock(HistoricVariableInstance.class);
    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();
    when(instance.getTypedValue()).thenReturn(variableValue);
    when(query.singleResult()).thenReturn(instance);
    when(mockHistoryService.createHistoricVariableInstanceQuery()).thenReturn(query);
    given().pathParam("name", EXAMPLE_ENGINE_NAME).pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).then().expect().statusCode(Status.OK.getStatusCode()).body(is(equalTo(new String(byteContent)))).and().header("Content-Disposition", "attachment; filename=" + filename).contentType(CoreMatchers.<String>either(equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")).or(equalTo(ContentType.TEXT.toString() + " ;charset=UTF-8"))).when().get(HISTORY_BINARY_VARIABLE_INSTANCE_URL);
    verify(mockHistoryService).createHistoricVariableInstanceQuery();
    verifyZeroInteractions(processEngine);
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Matchers.anyString(org.mockito.Matchers.anyString) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 48 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstanceSerialized.

@Test
public void testGetSingleVariableInstanceSerialized() {
    ObjectValue serializedValue = Variables.serializedObjectValue("a serialized value").serializationDataFormat("aDataFormat").objectTypeName("aTypeName").create();
    MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance().typedValue(serializedValue);
    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", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).queryParam("deserializeValue", false).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("a serialized value")).body("valueInfo.serializationDataFormat", equalTo("aDataFormat")).body("valueInfo.objectTypeName", equalTo("aTypeName")).body("processInstanceId", equalTo(builder.getProcessInstanceId())).body("processDefinitionKey", equalTo(builder.getProcessDefinitionKey())).body("processDefinitionId", equalTo(builder.getProcessDefinitionId())).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();
    verify(variableInstanceQueryMock, times(1)).disableCustomObjectDeserialization();
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) MockObjectValue(org.camunda.bpm.engine.rest.helper.MockObjectValue) MockHistoricVariableInstanceBuilder(org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 49 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceRestServiceInteractionTest method testGetBinaryDataForFileVariable.

@Test
public void testGetBinaryDataForFileVariable() {
    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();
    HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(variableValue).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()).and().body(is(equalTo(new String(byteContent)))).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(variableInstanceQueryMock, never()).disableBinaryFetching();
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) Response(com.jayway.restassured.response.Response) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 50 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstanceDeserialized.

@Test
public void testGetSingleVariableInstanceDeserialized() {
    ObjectValue serializedValue = MockObjectValue.fromObjectValue(Variables.objectValue("a value").serializationDataFormat("aDataFormat").create()).objectTypeName("aTypeName");
    MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance().typedValue(serializedValue);
    HistoricVariableInstance variableInstanceMock = builder.build();
    when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
    given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).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("a 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("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();
    verify(variableInstanceQueryMock, never()).disableCustomObjectDeserialization();
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) MockObjectValue(org.camunda.bpm.engine.rest.helper.MockObjectValue) MockHistoricVariableInstanceBuilder(org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Aggregations

HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)88 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)44 Test (org.junit.Test)42 Deployment (org.camunda.bpm.engine.test.Deployment)39 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)18 Task (org.camunda.bpm.engine.task.Task)17 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)12 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)10 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)10 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)10 HashMap (java.util.HashMap)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)8 VariableMap (org.camunda.bpm.engine.variable.VariableMap)8 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)7 Date (java.util.Date)6 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 MockHistoricVariableInstanceBuilder (org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder)6