/** * Test for bug ACT-10: whitespaces/newlines in expressions lead to exceptions */ @Deployment public void testWhitespaceInExpression() { // Starting a process instance will lead to an exception if whitespace are incorrectly handled runtimeService.startProcessInstanceByKey("whiteSpaceInExpression", CollectionUtil.singletonMap("input", 1)); }
/** * Test for bug ACT-10: whitespaces/newlines in expressions lead to exceptions */ @Deployment public void testWhitespaceInExpression() { // Starting a process instance will lead to an exception if whitespace are // incorrectly handled runtimeService.startProcessInstanceByKey("inclusiveWhiteSpaceInExpression", CollectionUtil.singletonMap("input", 1)); }
@Deployment public void testHtmlMail() throws Exception { runtimeService.startProcessInstanceByKey("htmlMail", CollectionUtil.singletonMap("gender", "male")); List<WiserMessage> messages = wiser.getMessages(); assertEquals(1, messages.size()); assertEmailSend(messages.get(0), true, "Test", "Mr. <b>Kermit</b>", "camunda@localhost", Arrays.asList("kermit@camunda.org"), null); }
@Deployment public void testHtmlMail() throws Exception { runtimeService.startProcessInstanceByKey("htmlMail", CollectionUtil.singletonMap("gender", "male")); List<WiserMessage> messages = wiser.getMessages(); assertEquals(1, messages.size()); assertEmailSend(messages.get(0), true, "Test", "Mr. <b>Kermit</b>", "camunda@localhost", Arrays.asList("kermit@camunda.org"), null); }
@Deployment public void testNoSequenceFlowSelected() { try { runtimeService.startProcessInstanceByKey("exclusiveGwNoSeqFlowSelected", CollectionUtil.singletonMap("input", 4)); fail(); } catch (ProcessEngineException e) { assertTextPresent("ENGINE-02004 No outgoing sequence flow for the element with id 'exclusiveGw' could be selected for continuing the process.", e.getMessage()); } }
@Deployment public void testNoSequenceFlowSelected() { try { runtimeService.startProcessInstanceByKey("inclusiveGwNoSeqFlowSelected", CollectionUtil.singletonMap("input", 4)); fail(); } catch (ProcessEngineException e) { assertTextPresent("ENGINE-02004 No outgoing sequence flow for the element with id 'inclusiveGw' could be selected for continuing the process.", e.getMessage()); } }
@org.camunda.bpm.engine.test.Deployment public void testGroovyScriptExecution() { try { processEngineConfiguration.setAutoStoreScriptVariables(true); int[] inputArray = new int[] {1, 2, 3, 4, 5}; ProcessInstance pi = runtimeService.startProcessInstanceByKey("scriptExecution", CollectionUtil.singletonMap("inputArray", inputArray)); Integer result = (Integer) runtimeService.getVariable(pi.getId(), "sum"); assertEquals(15, result.intValue()); } finally { processEngineConfiguration.setAutoStoreScriptVariables(false); } }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/gateway/InclusiveGatewayTest.testDivergingInclusiveGateway.bpmn20.xml" }) public void testUnknownVariableInExpression() { // Instead of 'input' we're starting a process instance with the name // 'iinput' (ie. a typo) try { runtimeService.startProcessInstanceByKey("inclusiveGwDiverging", CollectionUtil.singletonMap("iinput", 1)); fail(); } catch (ProcessEngineException e) { assertTextPresent("Unknown property used in expression", e.getMessage()); } }
@Deployment public void testMultipleValidConditions() { runtimeService.startProcessInstanceByKey("exclusiveGwMultipleValidConditions", CollectionUtil.singletonMap("input", 5)); assertEquals("Task 2", taskService.createTaskQuery().singleResult().getName()); }
@Deployment public void testInvalidMethodExpression() { try { runtimeService.startProcessInstanceByKey("inclusiveInvalidMethodExpression", CollectionUtil.singletonMap("order", new InclusiveGatewayTestOrder(50))); fail(); } catch (ProcessEngineException e) { assertTextPresent("Unknown method used in expression", e.getMessage()); } }
@Deployment public void testInvalidMethodExpression() { try { runtimeService.startProcessInstanceByKey("invalidMethodExpression", CollectionUtil.singletonMap("order", new ExclusiveGatewayTestOrder(50))); fail(); } catch (ProcessEngineException e) { assertTextPresent("Unknown method used in expression", e.getMessage()); } }
@Deployment public void testSequentialServiceTaskWithClass() { ProcessInstance procInst = runtimeService.startProcessInstanceByKey("multiInstanceServiceTask", CollectionUtil.singletonMap("result", 5)); Integer result = (Integer) runtimeService.getVariable(procInst.getId(), "result"); assertEquals(160, result.intValue()); runtimeService.signal(procInst.getId()); assertProcessEnded(procInst.getId()); }
@Deployment public void testDefaultSequenceFlowOnTask() { String procId = runtimeService.startProcessInstanceByKey("defaultSeqFlow", CollectionUtil.singletonMap("input", 2)).getId(); assertNotNull(runtimeService.createExecutionQuery().processInstanceId(procId).activityId("task2").singleResult()); procId = runtimeService.startProcessInstanceByKey("defaultSeqFlow", CollectionUtil.singletonMap("input", 3)).getId(); assertNotNull(runtimeService.createExecutionQuery().processInstanceId(procId).activityId("task3").singleResult()); procId = runtimeService.startProcessInstanceByKey("defaultSeqFlow", CollectionUtil.singletonMap("input", 123)).getId(); assertNotNull(runtimeService.createExecutionQuery().processInstanceId(procId).activityId("task1").singleResult()); }
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/gateway/InclusiveGatewayTest.testDefaultSequenceFlow.bpmn20.xml") public void testDefaultSequenceFlowExecutionIsActive() { // given a triggered inclusive gateway default flow runtimeService.startProcessInstanceByKey("inclusiveGwDefaultSequenceFlow", CollectionUtil.singletonMap("input", 5)); // then the process instance execution is not deactivated ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().singleResult(); assertEquals("theTask2", execution.getActivityId()); assertTrue(execution.isActive()); }
@Deployment public void testDivergingExclusiveGateway() { for (int i = 1; i <= 3; i++) { ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveGwDiverging", CollectionUtil.singletonMap("input", i)); assertEquals("Task " + i, taskService.createTaskQuery().singleResult().getName()); runtimeService.deleteProcessInstance(pi.getId(), "testing deletion"); } }
@Deployment public void testDecideBasedOnBeanMethod() { runtimeService.startProcessInstanceByKey("decisionBasedOnBeanMethod", CollectionUtil.singletonMap("order", new ExclusiveGatewayTestOrder(300))); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); assertEquals("Gold Member service", task.getName()); }
@Deployment public void testJavaServiceDelegation() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("javaServiceDelegation", CollectionUtil.singletonMap("input", "Activiti BPM Engine")); Execution execution = runtimeService.createExecutionQuery() .processInstanceId(pi.getId()) .activityId("waitState") .singleResult(); assertEquals("ACTIVITI BPM ENGINE", runtimeService.getVariable(execution.getId(), "input")); }
@Deployment @Test public void testGetTaskFormKeyWithExpression() { runtimeService.startProcessInstanceByKey("FormsProcess", CollectionUtil.singletonMap("dynamicKey", "test")); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); assertEquals("test", formService.getTaskFormData(task.getId()).getFormKey()); }
@Deployment public void testParallelSubProcessAllAutomatic() { String procId = runtimeService.startProcessInstanceByKey("miParallelSubprocessAllAutomatics", CollectionUtil.singletonMap("nrOfLoops", 5)).getId(); Execution waitState = runtimeService.createExecutionQuery().singleResult(); assertEquals(10, runtimeService.getVariable(waitState.getId(), "sum")); runtimeService.signal(waitState.getId()); assertProcessEnded(procId); }
@Deployment public void testMergingInclusiveGatewayAsync() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("inclusiveGwMerging", CollectionUtil.singletonMap("input", 2)); List<Job> list = managementService.createJobQuery().list(); for (Job job : list) { managementService.executeJob(job.getId()); } assertEquals(1, taskService.createTaskQuery().count()); runtimeService.deleteProcessInstance(pi.getId(), "testing deletion"); }