use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoricProcessInstanceQueryTest method testLocalization.
@Deployment
public void testLocalization() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("historicProcessLocalization");
String processInstanceId = processInstance.getId();
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricProcessInstance> processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).list();
assertEquals(1, processes.size());
assertNull(processes.get(0).getName());
assertNull(processes.get(0).getDescription());
ObjectNode infoNode = dynamicBpmnService.changeLocalizationName("en-GB", "historicProcessLocalization", "Historic Process Name 'en-GB'");
dynamicBpmnService.changeLocalizationDescription("en-GB", "historicProcessLocalization", "Historic Process Description 'en-GB'", infoNode);
dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
dynamicBpmnService.changeLocalizationName("en", "historicProcessLocalization", "Historic Process Name 'en'", infoNode);
dynamicBpmnService.changeLocalizationDescription("en", "historicProcessLocalization", "Historic Process Description 'en'", infoNode);
dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).list();
assertEquals(1, processes.size());
assertNull(processes.get(0).getName());
assertNull(processes.get(0).getDescription());
processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-GB").list();
assertEquals(1, processes.size());
assertEquals("Historic Process Name 'en-GB'", processes.get(0).getName());
assertEquals("Historic Process Description 'en-GB'", processes.get(0).getDescription());
processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).listPage(0, 10);
assertEquals(1, processes.size());
assertNull(processes.get(0).getName());
assertNull(processes.get(0).getDescription());
processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-GB").listPage(0, 10);
assertEquals(1, processes.size());
assertEquals("Historic Process Name 'en-GB'", processes.get(0).getName());
assertEquals("Historic Process Description 'en-GB'", processes.get(0).getDescription());
HistoricProcessInstance process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertNull(process.getName());
assertNull(process.getDescription());
process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-GB").singleResult();
assertEquals("Historic Process Name 'en-GB'", process.getName());
assertEquals("Historic Process Description 'en-GB'", process.getDescription());
process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en").singleResult();
assertEquals("Historic Process Name 'en'", process.getName());
assertEquals("Historic Process Description 'en'", process.getDescription());
process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-AU").withLocalizationFallback().singleResult();
assertEquals("Historic Process Name 'en'", process.getName());
assertEquals("Historic Process Description 'en'", process.getDescription());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testQueryEqualsIgnoreCase.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryEqualsIgnoreCase() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("mixed", "AbCdEfG");
vars.put("lower", "ABCDEFG");
vars.put("upper", "abcdefg");
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("mixed", "abcdefg").singleResult();
assertNotNull(instance);
assertEquals(processInstance1.getId(), instance.getId());
instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("lower", "abcdefg").singleResult();
assertNotNull(instance);
assertEquals(processInstance1.getId(), instance.getId());
instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("upper", "abcdefg").singleResult();
assertNotNull(instance);
assertEquals(processInstance1.getId(), instance.getId());
// Pass in non-lower-case string
instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("upper", "ABCdefg").singleResult();
assertNotNull(instance);
assertEquals(processInstance1.getId(), instance.getId());
// Pass in null-value, should cause exception
try {
historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("upper", null).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
assertEquals("value is null", ae.getMessage());
}
// Pass in null name, should cause exception
try {
historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase(null, "abcdefg").singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
assertEquals("name is null", ae.getMessage());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoricProcessInstanceQueryEscapeClauseTest method testQueryByProcessInstanceNameLikeIgnoreCase.
@Test
public void testQueryByProcessInstanceNameLikeIgnoreCase() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
// processInstanceNameLike
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLikeIgnoreCase("%\\%%").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance1.getId(), historicProcessInstance.getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLikeIgnoreCase("%\\_%").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance2.getId(), historicProcessInstance.getId());
// orQuery
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLikeIgnoreCase("%\\%%").processDefinitionId("undefined").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance1.getId(), historicProcessInstance.getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLikeIgnoreCase("%\\_%").processDefinitionId("undefined").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance2.getId(), historicProcessInstance.getId());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoricProcessInstanceQueryEscapeClauseTest method testQueryLikeIgnoreCaseByQueryVariableValue.
@Test
public void testQueryLikeIgnoreCaseByQueryVariableValue() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
// queryVariableValueIgnoreCase
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%\\%%").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance1.getId(), historicProcessInstance.getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%\\_%").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance2.getId(), historicProcessInstance.getId());
// orQuery
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%\\%%").processDefinitionId("undefined").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance1.getId(), historicProcessInstance.getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%\\_%").processDefinitionId("undefined").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance2.getId(), historicProcessInstance.getId());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoricProcessInstanceQueryEscapeClauseTest method testQueryLikeByQueryVariableValue.
@Test
public void testQueryLikeByQueryVariableValue() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
// queryVariableValue
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLike("var1", "%\\%%").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance1.getId(), historicProcessInstance.getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLike("var1", "%\\_%").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance2.getId(), historicProcessInstance.getId());
// orQuery
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLike("var1", "%\\%%").processDefinitionId("undefined").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance1.getId(), historicProcessInstance.getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLike("var1", "%\\_%").processDefinitionId("undefined").singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance2.getId(), historicProcessInstance.getId());
}
}
Aggregations