use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class RepetitionRuleTest method testDefaultVariableBasedRepetitionRuleEvaluatesToFalse.
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/repetition/RepetitionRuleTest.testDefaultVariableBasedRule.cmmn")
public void testDefaultVariableBasedRepetitionRuleEvaluatesToFalse() {
// given
VariableMap variables = Variables.createVariables().putValue("repeat", false);
createCaseInstanceByKey("case", variables);
String humanTask1 = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
// when
complete(humanTask1);
// then
CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2");
assertEquals(1, query.count());
assertEquals(1, query.active().count());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testCatchErrorThrownByExecuteOfParallelDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownByParallelDelegateExpression.bpmn20.xml" })
public void testCatchErrorThrownByExecuteOfParallelDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
variables.putAll(throwError());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskError", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testCatchErrorThrownBySignalOfSequentialDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownBySequentialDelegateExpression.bpmn20.xml" })
public void testCatchErrorThrownBySignalOfSequentialDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
// signal 2 times to execute first sequential behaviors
runtimeService.setVariables(pi, leaveExecution());
runtimeService.signal(runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult().getId());
runtimeService.setVariables(pi, leaveExecution());
runtimeService.signal(runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult().getId());
Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult();
assertNotNull(serviceTask);
runtimeService.setVariables(pi, throwError());
runtimeService.signal(serviceTask.getId());
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertTrue((Boolean) runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskError", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class RetryIntervalsConfigurationTest method testlocalConfigurationWithNestedChangingExpression.
@Test
public void testlocalConfigurationWithNestedChangingExpression() throws ParseException {
BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process").startEvent().serviceTask().camundaClass("foo").camundaAsyncBefore().camundaFailedJobRetryTimeCycle("${var}").endEvent().done();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date startDate = simpleDateFormat.parse("2017-01-01T09:55:00");
ClockUtil.setCurrentTime(startDate);
testRule.deploy(bpmnModelInstance);
VariableMap params = Variables.createVariables();
params.putValue("var", "${nestedVar1},PT15M,${nestedVar3}");
params.putValue("nestedVar", "PT13M");
params.putValue("nestedVar1", "PT5M");
params.putValue("nestedVar3", "PT25M");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", params);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 5);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(2, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 15);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
runtimeService.setVariable(pi.getProcessInstanceId(), "var", "${nestedVar}");
jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 13);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class InvoiceTestCase method testApproveInvoiceAssignment.
@Deployment(resources = { "invoice.v2.bpmn", "invoiceBusinessDecisions.dmn" })
public void testApproveInvoiceAssignment() {
InputStream invoiceInputStream = InvoiceProcessApplication.class.getClassLoader().getResourceAsStream("invoice.pdf");
VariableMap variables = Variables.createVariables().putValue("creditor", "Great Pizza for Everyone Inc.").putValue("amount", 300.0d).putValue("invoiceCategory", "Travel Expenses").putValue("invoiceNumber", "GPFE-23232323").putValue("invoiceDocument", fileValue("invoice.pdf").file(invoiceInputStream).mimeType("application/pdf").create()).putValue("approverGroups", Arrays.asList("sales", "accounting"));
ProcessInstance pi = runtimeService.createProcessInstanceByKey("invoice").setVariables(variables).startBeforeActivity("approveInvoice").execute();
// givent that the process instance is waiting at task "approveInvoice"
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("approveInvoice", task.getTaskDefinitionKey());
// and task has candidate groups
List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId());
Set<String> approverGroups = new HashSet<String>();
for (IdentityLink link : links) {
approverGroups.add(link.getGroupId());
}
assertEquals(2, approverGroups.size());
assertTrue(approverGroups.contains("accounting"));
assertTrue(approverGroups.contains("sales"));
// and variable approver is null
assertNull(taskService.getVariable(task.getId(), "approver"));
// if mary claims the task
taskService.claim(task.getId(), "mary");
// then the variable "approver" exists and is set to mary
assertEquals("mary", taskService.getVariable(task.getId(), "approver"));
}
Aggregations