@Override public BusinessRuleTaskBuilder builder() { return new BusinessRuleTaskBuilder((BpmnModelInstance) modelInstance, this); }
public void testEvaluateDecisionTenantIdExpression() { BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("latest") .camundaDecisionRefTenantId("${'"+TENANT_ONE+"'}") .camundaMapDecisionResult("singleEntry") .camundaResultVariable("decisionVar") .camundaAsyncAfter() .endEvent() .done(); deploymentForTenant(TENANT_ONE, DMN_FILE); deploymentForTenant(TENANT_TWO, DMN_FILE_VERSION_TWO); deployment(process); ProcessInstance processInstanceOne = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold").execute(); assertThat((String)runtimeService.getVariable(processInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE)); }
private BpmnModelInstance prepareFailingBusinessRuleTask() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .businessRuleTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .endEvent() .done(); return modelInstance; }
public void testFailEvaluateDecisionFromOtherTenantWithVersionBinding() { BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("version") .camundaDecisionRefVersion("2") .camundaAsyncAfter() .endEvent() .done(); deploymentForTenant(TENANT_ONE, DMN_FILE, process); deploymentForTenant(TENANT_TWO, DMN_FILE); deploymentForTenant(TENANT_TWO, DMN_FILE); try { runtimeService.createProcessInstanceByKey("process") .processDefinitionTenantId(TENANT_ONE) .execute(); fail("expected exception"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("no decision definition deployed with key = 'decision', version = '2' and tenant-id 'tenant1'")); } }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionInstance() { // given testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); // then assertThat(historicDecisionInstances.get(0).getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); assertThat(historicDecisionInstances.get(1).getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); assertThat(historicDecisionInstances.get(2).getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void providerCalledWithExecution_BusinessRuleTasks() { ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider(); TestTenantIdProvider.delegate = tenantIdProvider; BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .businessRuleTask() .camundaDecisionRef(DECISION_DEFINITION_KEY) .camundaAsyncAfter() .endEvent() .done(); testRule.deploy(process, DMN_FILE); // if a process instance is started engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEFINITION_KEY, createVariables()); Execution execution = engineRule.getRuntimeService().createExecutionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult(); // then the tenant id provider is invoked assertThat(tenantIdProvider.dmnParameters.size(), is(1)); ExecutionEntity passedExecution = (ExecutionEntity) tenantIdProvider.dmnParameters.get(0).getExecution(); assertThat(passedExecution, is(notNullValue())); assertThat(passedExecution.getParent().getId(), is(execution.getId())); }
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .userTask() .endEvent().done());
public void testFailEvaluateDecisionFromOtherTenantWithDeploymentBinding() { BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("deployment") .camundaAsyncAfter() .endEvent() .done(); deploymentForTenant(TENANT_ONE, process); deploymentForTenant(TENANT_TWO, DMN_FILE); try { runtimeService.createProcessInstanceByKey("process") .processDefinitionTenantId(TENANT_ONE) .execute(); fail("expected exception"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("no decision definition deployed with key = 'decision'")); } }
@Test public void providerCalledForHistoricDecisionDefinitionWithoutTenantId_BusinessRuleTask() { ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider(); TestTenantIdProvider.delegate = tenantIdProvider; BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .businessRuleTask() .camundaDecisionRef(DECISION_DEFINITION_KEY) .endEvent() .done(); // given a deployment without tenant id testRule.deploy(process, DMN_FILE); // if a decision definition is evaluated engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEFINITION_KEY, createVariables()); // then the tenant id provider is invoked assertThat(tenantIdProvider.dmnParameters.size(), is(1)); }
@Test public void setNullTenantIdForHistoricDecisionInstance_BusinessRuleTask() { String tenantId = null; SetValueOnHistoricDecisionInstanceTenantIdProvider tenantIdProvider = new SetValueOnHistoricDecisionInstanceTenantIdProvider(tenantId); TestTenantIdProvider.delegate = tenantIdProvider; BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .businessRuleTask() .camundaDecisionRef(DECISION_DEFINITION_KEY) .camundaAsyncAfter() .endEvent() .done(); testRule.deploy(process, DMN_FILE); // if a process instance is started engineRule.getRuntimeService().createProcessInstanceByKey(PROCESS_DEFINITION_KEY).setVariables(createVariables()).execute(); // then the tenant id provider can set the tenant id to a value HistoricDecisionInstance historicDecisionInstance = engineRule.getHistoryService().createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult(); assertThat(historicDecisionInstance.getTenantId(), is(nullValue())); }
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .userTask() .endEvent().done());
@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 testFailEvaluateDecisionFromOtherTenantWithLatestBinding() { BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("latest") .camundaAsyncAfter() .endEvent() .done(); deploymentForTenant(TENANT_ONE, process); deploymentForTenant(TENANT_TWO, DMN_FILE); try { runtimeService.createProcessInstanceByKey("process") .processDefinitionTenantId(TENANT_ONE) .execute(); fail("expected exception"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("no decision definition deployed with key 'decision'")); } }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime)); }
.startEvent() .businessRuleTask() .camundaAsyncAfter() .camundaDecisionRef("dish-decision") .endEvent().done());
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .userTask() .endEvent().done());
private BpmnModelInstance prepareFailingBusinessRuleTask() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .businessRuleTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .endEvent() .done(); return modelInstance; }
@Override public BusinessRuleTaskBuilder builder() { return new BusinessRuleTaskBuilder((BpmnModelInstance) modelInstance, this); }
public void testEvaluateDecisionTenantIdConstant() { BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("latest") .camundaDecisionRefTenantId(TENANT_ONE) .camundaMapDecisionResult("singleEntry") .camundaResultVariable("decisionVar") .camundaAsyncAfter() .endEvent() .done(); deploymentForTenant(TENANT_ONE, DMN_FILE); deploymentForTenant(TENANT_TWO, DMN_FILE_VERSION_TWO); deployment(process); ProcessInstance processInstanceOne = runtimeService.createProcessInstanceByKey("process") .setVariable("status", "gold").execute(); assertThat((String)runtimeService.getVariable(processInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE)); }
public void testFailEvaluateDecisionFromOtherTenantWithVersionBinding() { BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .businessRuleTask() .camundaDecisionRef("decision") .camundaDecisionRefBinding("version") .camundaDecisionRefVersion("2") .camundaAsyncAfter() .endEvent() .done(); deploymentForTenant(TENANT_ONE, DMN_FILE, process); deploymentForTenant(TENANT_TWO, DMN_FILE); deploymentForTenant(TENANT_TWO, DMN_FILE); try { runtimeService.createProcessInstanceByKey("process") .processDefinitionTenantId(TENANT_ONE) .execute(); fail("expected exception"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("no decision definition deployed with key = 'decision', version = '2' and tenant-id 'tenant1'")); } }