@Test public void shouldResolveByteArray_SetVariable() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when runtimeService.setVariable(processInstance.getId(), "aVariableName", new ByteArrayInputStream("hello world".getBytes())); HistoricVariableInstanceEntity historicVariableInstance = (HistoricVariableInstanceEntity) historyService.createHistoricVariableInstanceQuery().singleResult(); ByteArrayEntity byteArray = findByteArrayById(historicVariableInstance.getByteArrayId()); // assume assertThat(byteArray, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_CreateAttachmentByTask() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, taskId, null, null, null, new ByteArrayInputStream("hello world".getBytes())); ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId()); // assume assertThat(byteArray, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_CreateAttachmentByTask() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ClockUtil.setCurrentTime(START_DATE); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, taskId, null, null, null, new ByteArrayInputStream("hello world".getBytes())); ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId()); // assume assertThat(byteArray.getRemovalTime(), nullValue()); ClockUtil.setCurrentTime(END_DATE); // when taskService.complete(taskId); byteArray = findByteArrayById(attachment.getContentId()); Date removalTime = addDays(END_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_CreateAttachmentByProcessInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String calledProcessInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, null, calledProcessInstanceId, null, null, new ByteArrayInputStream("hello world".getBytes())); ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId()); // assume assertThat(byteArray, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_SetVariable() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ClockUtil.setCurrentTime(START_DATE); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); runtimeService.setVariable(processInstance.getId(), "aVariableName", new ByteArrayInputStream("hello world".getBytes())); HistoricVariableInstanceEntity historicVariableInstance = (HistoricVariableInstanceEntity) historyService.createHistoricVariableInstanceQuery().singleResult(); ByteArrayEntity byteArray = findByteArrayById(historicVariableInstance.getByteArrayId()); // assume assertThat(byteArray.getRemovalTime(), nullValue()); String taskId = taskService.createTaskQuery().singleResult().getId(); ClockUtil.setCurrentTime(END_DATE); // when taskService.complete(taskId); byteArray = findByteArrayById(historicVariableInstance.getByteArrayId()); Date removalTime = addDays(END_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_CreateAttachmentByProcessInstance() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ClockUtil.setCurrentTime(START_DATE); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String calledProcessInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, null, calledProcessInstanceId, null, null, new ByteArrayInputStream("hello world".getBytes())); ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId()); // assume assertThat(byteArray.getRemovalTime(), nullValue()); ClockUtil.setCurrentTime(END_DATE); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.complete(taskId); byteArray = findByteArrayById(attachment.getContentId()); Date removalTime = addDays(END_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_UpdateVariable() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("aVariableName", Variables.stringValue("aVariableValue"))); // when runtimeService.setVariable(processInstance.getId(), "aVariableName", new ByteArrayInputStream("hello world".getBytes())); HistoricDetailVariableInstanceUpdateEntity historicDetails = (HistoricDetailVariableInstanceUpdateEntity) historyService.createHistoricDetailQuery() .variableUpdates() .variableTypeIn("Bytes") .singleResult(); // assume ByteArrayEntity byteArray = findByteArrayById(historicDetails.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_UpdateVariable() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ClockUtil.setCurrentTime(START_DATE); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("aVariableName", Variables.stringValue("aVariableValue"))); runtimeService.setVariable(processInstance.getId(), "aVariableName", new ByteArrayInputStream("hello world".getBytes())); HistoricDetailVariableInstanceUpdateEntity historicDetails = (HistoricDetailVariableInstanceUpdateEntity) historyService.createHistoricDetailQuery() .variableUpdates() .variableTypeIn("Bytes") .singleResult(); ByteArrayEntity byteArray = findByteArrayById(historicDetails.getByteArrayValueId()); // assume assertThat(byteArray.getRemovalTime(), nullValue()); ClockUtil.setCurrentTime(END_DATE); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.complete(taskId); byteArray = findByteArrayById(historicDetails.getByteArrayValueId()); Date removalTime = addDays(END_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" }) public void shouldResolveByteArray_StandaloneDecisionInput() { // given ClockUtil.setCurrentTime(START_DATE); DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionKey("testDecision") .singleResult(); repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 5); // when decisionService.evaluateDecisionTableByKey("testDecision", Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeInputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionInputInstanceEntity historicDecisionInputInstanceEntity = (HistoricDecisionInputInstanceEntity) historicDecisionInstance.getInputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionInputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" }) public void shouldResolveByteArray_StandaloneDecisionOutput() { // given ClockUtil.setCurrentTime(START_DATE); DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionKey("testDecision") .singleResult(); repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 5); // when decisionService.evaluateDecisionTableByKey("testDecision", Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionOutputInstanceEntity historicDecisionOutputInstanceEntity = (HistoricDecisionOutputInstanceEntity) historicDecisionInstance.getOutputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionOutputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test @Deployment( resources = { "org/camunda/bpm/engine/test/api/history/removaltime/HistoricRootProcessInstanceTest.shouldResolveByteArray_DecisionOutputLiteralExpression.dmn" }) public void shouldResolveByteArray_StandaloneDecisionOutputLiteralExpression() { // given ClockUtil.setCurrentTime(START_DATE); DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionKey("testDecision") .singleResult(); repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 5); // when decisionService.evaluateDecisionTableByKey("testDecision", Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionOutputInstanceEntity historicDecisionOutputInstanceEntity = (HistoricDecisionOutputInstanceEntity) historicDecisionInstance.getOutputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionOutputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveByteArray_JobLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); taskService.complete(taskService.createTaskQuery().singleResult().getId()); String jobId = managementService.createJobQuery() .singleResult() .getId(); try { // when managementService.executeJob(jobId); } catch (Exception ignored) { } HistoricJobLogEventEntity jobLog = (HistoricJobLogEventEntity) historyService.createHistoricJobLogQuery() .jobExceptionMessage("I'm supposed to fail!") .singleResult(); // assume assertThat(jobLog, notNullValue()); ByteArrayEntity byteArray = findByteArrayById(jobLog.getExceptionByteArrayId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" }) public void shouldResolveByteArray_DecisionInput() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeInputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionInputInstanceEntity historicDecisionInputInstanceEntity = (HistoricDecisionInputInstanceEntity) historicDecisionInstance.getInputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionInputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test @Deployment( resources = { "org/camunda/bpm/engine/test/api/history/removaltime/HistoricRootProcessInstanceTest.shouldResolveByteArray_DecisionOutputLiteralExpression.dmn" }) public void shouldResolveByteArray_DecisionOutputLiteralExpression() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionOutputInstanceEntity historicDecisionOutputInstanceEntity = (HistoricDecisionOutputInstanceEntity) historicDecisionInstance.getOutputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionOutputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" }) public void shouldResolveByteArray_DecisionOutput() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionOutputInstanceEntity historicDecisionOutputInstanceEntity = (HistoricDecisionOutputInstanceEntity) historicDecisionInstance.getOutputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionOutputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); } @Test
assertThat(byteArrayEntity.getRemovalTime(), nullValue()); assertThat(byteArrayEntity.getRemovalTime(), is(removalTime));
assertThat(byteArrayEntity.getRemovalTime(), nullValue()); assertThat(byteArrayEntity.getRemovalTime(), is(removalTime));
assertThat(byteArrayEntity.getRemovalTime(), nullValue()); assertThat(byteArrayEntity.getRemovalTime(), is(removalTime));
assertThat(byteArrayEntity.getRemovalTime(), nullValue()); assertThat(byteArrayEntity.getRemovalTime(), is(removalTime));
@Test public void shouldResolveByteArray_ExternalTaskLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("aTopicName") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .camundaHistoryTimeToLive(5) .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callingProcess"); List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, "aWorkerId") .topic("aTopicName", Integer.MAX_VALUE) .execute(); // when externalTaskService.handleFailure(tasks.get(0).getId(), "aWorkerId", null, "errorDetails", 5, 3000L); HistoricExternalTaskLogEntity externalTaskLog = (HistoricExternalTaskLogEntity) historyService.createHistoricExternalTaskLogQuery() .failureLog() .singleResult(); // assume assertThat(externalTaskLog, notNullValue()); ByteArrayEntity byteArrayEntity = findByteArrayById(externalTaskLog.getErrorDetailsByteArrayId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }