protected void determineAutoHistoryLevel(ProcessEngineConfigurationImpl engineConfiguration, HistoryLevel databaseHistoryLevel) { HistoryLevel configuredHistoryLevel = engineConfiguration.getHistoryLevel(); if (configuredHistoryLevel == null && ProcessEngineConfiguration.HISTORY_AUTO.equals(engineConfiguration.getHistory())) { // automatically determine history level or use default AUDIT if (databaseHistoryLevel != null) { engineConfiguration.setHistoryLevel(databaseHistoryLevel); } else { engineConfiguration.setHistoryLevel(engineConfiguration.getDefaultHistoryLevel()); } } }
@Test public void shouldInitHistoryLevelByObject() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
@Deployment public void testCompensateMiSubprocessWithCompensationEventSubprocessVariableSnapshots() { // see referenced java delegates in the process definition. List<String> hotels = Arrays.asList("Rupert", "Vogsphere", "Milliways", "Taunton", "Ysolldins"); SetVariablesDelegate.setValues(hotels); // SetVariablesDelegate take the first element of static list and set the value as local variable // GetVariablesDelegate read the variable and add the value to static list runtimeService.startProcessInstanceByKey("compensateProcess"); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookHotel").count()); } assertTrue(GetVariablesDelegate.values.containsAll(hotels)); }
@Test public void shouldInitHistoryLevelByString() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistory(HistoryLevel.HISTORY_LEVEL_FULL.getName()); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
protected void determineAutoHistoryLevel(ProcessEngineConfigurationImpl engineConfiguration, HistoryLevel databaseHistoryLevel) { HistoryLevel configuredHistoryLevel = engineConfiguration.getHistoryLevel(); if (configuredHistoryLevel == null && ProcessEngineConfiguration.HISTORY_AUTO.equals(engineConfiguration.getHistory())) { // automatically determine history level or use default AUDIT if (databaseHistoryLevel != null) { engineConfiguration.setHistoryLevel(databaseHistoryLevel); } else { engineConfiguration.setHistoryLevel(engineConfiguration.getDefaultHistoryLevel()); } } }
@Deployment public void testCompensateMiSubprocessVariableSnapshots() { // see referenced java delegates in the process definition. List<String> hotels = Arrays.asList("Rupert", "Vogsphere", "Milliways", "Taunton", "Ysolldins"); SetVariablesDelegate.setValues(hotels); // SetVariablesDelegate take the first element of static list and set the value as local variable // GetVariablesDelegate read the variable and add the value to static list runtimeService.startProcessInstanceByKey("compensateProcess"); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookHotel").count()); } assertTrue(GetVariablesDelegate.values.containsAll(hotels)); }
@Test public void shouldInitHistoryLevelByObject() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
@Test public void secondEngineCopiesHistoryLevelFromFirst() { // given buildEngine(config("true", ProcessEngineConfiguration.HISTORY_FULL)); // when ProcessEngineImpl processEngineTwo = buildEngine(config("true", ProcessEngineConfiguration.HISTORY_AUTO)); // then assertThat(processEngineTwo.getProcessEngineConfiguration().getHistory(), is(ProcessEngineConfiguration.HISTORY_AUTO)); assertThat(processEngineTwo.getProcessEngineConfiguration().getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); }
/** * enable test case when bug is fixed * * @see https://app.camunda.com/jira/browse/CAM-4268 */ @Deployment public void FAILING_testCompensateMiSubprocessVariableSnapshotOfElementVariable() { Map<String, Object> variables = new HashMap<String, Object>(); // multi instance collection List<String> flights = Arrays.asList("STS-14", "STS-28"); variables.put("flights", flights); // see referenced java delegates in the process definition // java delegates read element variable (flight) and add the variable value // to a static list ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess", variables); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(flights.size(), historyService.createHistoricActivityInstanceQuery().activityId("undoBookFlight").count()); } // java delegates should be invoked for each element in collection assertEquals(flights, BookFlightService.bookedFlights); assertEquals(flights, CancelFlightService.canceledFlights); assertProcessEnded(processInstance.getId()); }
@Test public void secondEngineCopiesHistoryLevelFromFirst() { // given buildEngine(config("true", ProcessEngineConfiguration.HISTORY_FULL)); // when ProcessEngineImpl processEngineTwo = buildEngine(config("true", ProcessEngineConfiguration.HISTORY_AUTO)); // then assertThat(processEngineTwo.getProcessEngineConfiguration().getHistory(), is(ProcessEngineConfiguration.HISTORY_AUTO)); assertThat(processEngineTwo.getProcessEngineConfiguration().getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCallActivityCompensationHandler.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensationHandler.bpmn20.xml" }) public void testCallActivityCompensationHandler() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess"); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookHotel").count()); } runtimeService.signal(processInstance.getId()); assertProcessEnded(processInstance.getId()); assertEquals(0, runtimeService.createProcessInstanceQuery().count()); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(6, historyService.createHistoricProcessInstanceQuery().count()); } }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) // ACT-1098 public void testDeleteReason() { if(!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) { final String deleteReason = "some delete reason"; ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), deleteReason); HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(deleteReason, hpi.getDeleteReason()); } }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) @Test public void testDeleteProcessInstanceSkipCustomListenersEnsureHistoryWritten() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); // if we skip the custom listeners, runtimeService.deleteProcessInstance(processInstance.getId(), null, true); // buit-in listeners are still invoked and thus history is written if(!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) { // verify that all historic activity instances are ended List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery().list(); for (HistoricActivityInstance hai : hais) { assertNotNull(hai.getEndTime()); } } }
@Deployment public void testCompensationEndEventWithScope() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess"); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookHotel").count()); assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookFlight").count()); } assertProcessEnded(processInstance.getId()); }
@Deployment public void testCompensationEndEventWithActivityRef() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess"); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookHotel").count()); assertEquals(0, historyService.createHistoricActivityInstanceQuery().activityId("undoBookFlight").count()); } assertProcessEnded(processInstance.getId()); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) @Test public void testDeleteProcessInstance() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count()); runtimeService.deleteProcessInstance(processInstance.getId(), TESTING_INSTANCE_DELETION); assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count()); // test that the delete reason of the process instance shows up as delete reason of the task in history // ACT-848 if(!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) { HistoricTaskInstance historicTaskInstance = historyService .createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()) .singleResult(); assertEquals(TESTING_INSTANCE_DELETION, historicTaskInstance.getDeleteReason()); } }
if(!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(1, historyService.createHistoricActivityInstanceQuery() .activityId("undoBookFlight")
if(!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(1, historyService.createHistoricActivityInstanceQuery() .activityId("undoBookFlight")
@Deployment public void testCompensateMiSubprocessVariableSnapshots() { // see referenced java delegates in the process definition. List<String> hotels = Arrays.asList("Rupert", "Vogsphere", "Milliways", "Taunton", "Ysolldins"); SetVariablesDelegate.setValues(hotels); // SetVariablesDelegate take the first element of static list and set the value as local variable // GetVariablesDelegate read the variable and add the value to static list runtimeService.startProcessInstanceByKey("compensateProcess"); if (!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("undoBookHotel").count()); } assertTrue(GetVariablesDelegate.values.containsAll(hotels)); }
if(!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) { assertEquals(5, historyService.createHistoricActivityInstanceQuery() .activityId("innerTxundoBookHotel")