public void testEndEvent() throws Exception { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process") .startEvent() .endEvent() .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("R5/PT5M") .camundaExecutionListenerClass("start", "foo") .done(); deployment(bpmnModelInstance); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date startDate = simpleDateFormat.parse("2018-01-01T10:00:00"); ClockUtil.setCurrentTime(startDate); runtimeService.startProcessInstanceByKey("process"); Job job = managementService.createJobQuery().singleResult(); // assume Assert.assertEquals(3, job.getRetries()); // when job fails try { managementService.executeJob(job.getId()); } catch (Exception e) { // ignore } // then job = managementService.createJobQuery().singleResult(); Assert.assertEquals(4, job.getRetries()); Date expectedDate = simpleDateFormat.parse("2018-01-01T10:05:00"); assertEquals(expectedDate, ((JobEntity) job).getLockExpirationTime()); }
@Test public void decisionRefVersionTagBindingWithoutVersionTag() { // expected thrown.expect(ProcessEngineException.class); thrown.expectMessage("Could not parse BPMN process."); // when testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("testDecision") .camundaDecisionRefBinding("versionTag") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("result") .endEvent() .camundaAsyncBefore() .done()); }
public void testEvaluateDecisionWithVersionTagBinding() { // given deploymentForTenant(TENANT_ONE, DMN_FILE_VERSION_TAG); deployment(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefTenantId(TENANT_ONE) .camundaDecisionRefBinding("versionTag") .camundaDecisionRefVersionTag("0.0.2") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("decisionVar") .endEvent() .camundaAsyncBefore() .done()); // when ProcessInstance processInstance = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold") .execute(); // then assertThat((String)runtimeService.getVariable(processInstance.getId(), "decisionVar"), is(RESULT_OF_VERSION_TAG_ONE)); }
public void testEvaluateDecisionWithVersionTagBinding_ResolveTenantFromDefinition() { // given BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("versionTag") .camundaDecisionRefVersionTag("0.0.2") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("decisionVar") .endEvent() .camundaAsyncBefore() .done(); deploymentForTenant(TENANT_ONE, DMN_FILE_VERSION_TAG, process); deploymentForTenant(TENANT_TWO, DMN_FILE_VERSION_TAG_TWO, process); ProcessInstance processInstanceOne = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold") .processDefinitionTenantId(TENANT_ONE).execute(); ProcessInstance processInstanceTwo = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold") .processDefinitionTenantId(TENANT_TWO).execute(); assertThat((String)runtimeService.getVariable(processInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_TAG_ONE)); assertThat((String)runtimeService.getVariable(processInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TAG_TWO)); }
@Deployment( resources = DECISION_LITERAL_EXPRESSION_DMN ) @Test public void evaluateDecisionWithLiteralExpression() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decisionLiteralExpression") .camundaResultVariable("result") .camundaMapDecisionResult("singleEntry") .endEvent() .camundaAsyncBefore() .done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", Variables.createVariables() .putValue("a", 2) .putValue("b", 3)); assertEquals(5, getDecisionResult(processInstance)); }
@Deployment( resources = DRD_DISH_RESOURCE ) @Test public void evaluateDecisionWithRequiredDecisions() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .camundaResultVariable("result") .camundaMapDecisionResult("singleEntry") .endEvent() .camundaAsyncBefore() .done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); assertEquals("Light salad", getDecisionResult(processInstance)); }
@Test public void decisionRefVersionTagBindingExpression() { // given testRule.deploy(DECISION_VERSION_TAG_OKAY_DMN); testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("versionTag") .camundaDecisionRefVersionTag("${versionTagExpr}") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("result") .endEvent() .camundaAsyncBefore() .done()); // when VariableMap variables = Variables.createVariables() .putValue("versionTagExpr", "0.0.2") .putValue("status", "gold"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", variables); // then assertEquals("A", getDecisionResult(processInstance)); }
.endEvent() .subProcessDone() .endEvent("end").camundaAsyncBefore() .done() );
public void testEndEvent() throws Exception { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process") .startEvent() .endEvent() .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("R5/PT5M") .camundaExecutionListenerClass("start", "foo") .done(); deployment(bpmnModelInstance); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date startDate = simpleDateFormat.parse("2018-01-01T10:00:00"); ClockUtil.setCurrentTime(startDate); runtimeService.startProcessInstanceByKey("process"); Job job = managementService.createJobQuery().singleResult(); // assume Assert.assertEquals(3, job.getRetries()); // when job fails try { managementService.executeJob(job.getId()); } catch (Exception e) { // ignore } // then job = managementService.createJobQuery().singleResult(); Assert.assertEquals(4, job.getRetries()); Date expectedDate = simpleDateFormat.parse("2018-01-01T10:05:00"); assertEquals(expectedDate, ((JobEntity) job).getLockExpirationTime()); }
@Test public void decisionRefVersionTagBindingWithoutVersionTag() { // expected thrown.expect(ProcessEngineException.class); thrown.expectMessage("Could not parse BPMN process."); // when testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("testDecision") .camundaDecisionRefBinding("versionTag") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("result") .endEvent() .camundaAsyncBefore() .done()); }
public void testEvaluateDecisionWithVersionTagBinding() { // given deploymentForTenant(TENANT_ONE, DMN_FILE_VERSION_TAG); deployment(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefTenantId(TENANT_ONE) .camundaDecisionRefBinding("versionTag") .camundaDecisionRefVersionTag("0.0.2") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("decisionVar") .endEvent() .camundaAsyncBefore() .done()); // when ProcessInstance processInstance = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold") .execute(); // then assertThat((String)runtimeService.getVariable(processInstance.getId(), "decisionVar"), is(RESULT_OF_VERSION_TAG_ONE)); }
public void testEvaluateDecisionWithVersionTagBinding_ResolveTenantFromDefinition() { // given BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("versionTag") .camundaDecisionRefVersionTag("0.0.2") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("decisionVar") .endEvent() .camundaAsyncBefore() .done(); deploymentForTenant(TENANT_ONE, DMN_FILE_VERSION_TAG, process); deploymentForTenant(TENANT_TWO, DMN_FILE_VERSION_TAG_TWO, process); ProcessInstance processInstanceOne = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold") .processDefinitionTenantId(TENANT_ONE).execute(); ProcessInstance processInstanceTwo = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold") .processDefinitionTenantId(TENANT_TWO).execute(); assertThat((String)runtimeService.getVariable(processInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_TAG_ONE)); assertThat((String)runtimeService.getVariable(processInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TAG_TWO)); }
@Deployment( resources = DRD_DISH_RESOURCE ) @Test public void evaluateDecisionWithRequiredDecisions() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .camundaResultVariable("result") .camundaMapDecisionResult("singleEntry") .endEvent() .camundaAsyncBefore() .done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); assertEquals("Light salad", getDecisionResult(processInstance)); }
@Deployment( resources = DECISION_LITERAL_EXPRESSION_DMN ) @Test public void evaluateDecisionWithLiteralExpression() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decisionLiteralExpression") .camundaResultVariable("result") .camundaMapDecisionResult("singleEntry") .endEvent() .camundaAsyncBefore() .done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", Variables.createVariables() .putValue("a", 2) .putValue("b", 3)); assertEquals(5, getDecisionResult(processInstance)); }
@Test public void decisionRefVersionTagBindingExpression() { // given testRule.deploy(DECISION_VERSION_TAG_OKAY_DMN); testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("versionTag") .camundaDecisionRefVersionTag("${versionTagExpr}") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("result") .endEvent() .camundaAsyncBefore() .done()); // when VariableMap variables = Variables.createVariables() .putValue("versionTagExpr", "0.0.2") .putValue("status", "gold"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", variables); // then assertEquals("A", getDecisionResult(processInstance)); }
.endEvent() .subProcessDone() .endEvent("end").camundaAsyncBefore() .done() );