@Test public void testOutputSourceExpression() { // given: String source = "${a}"; ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class); sourceElement.setCamundaSourceExpression(source); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); CallableElementParameter parameter = callableElement.getOutputs().get(0); assertNotNull(parameter); assertFalse(parameter.isAllVariables()); ParameterValueProvider sourceExpressionValueProvider = parameter.getSourceValueProvider(); assertNotNull(sourceExpressionValueProvider); assertTrue(sourceExpressionValueProvider instanceof ElValueProvider); ElValueProvider valueProvider = (ElValueProvider) sourceExpressionValueProvider; assertEquals(source, valueProvider.getExpression().getExpressionText()); }
@Test public void testCallableElement() { // given: a plan item // when CmmnActivity activity = handler.handleElement(planItem, context); // then // there exists a callableElement CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); assertNotNull(behavior.getCallableElement()); }
@Test public void testBinding() { // given: CallableElementBinding caseBinding = CallableElementBinding.LATEST; caseTask.setCamundaCaseBinding(caseBinding.getValue()); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); CallableElementBinding binding = callableElement.getBinding(); assertNotNull(binding); assertEquals(caseBinding, binding); }
@Test public void testOutputVariables() { // given: ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaOut variablesElement = createElement(extensionElements, null, CamundaOut.class); variablesElement.setCamundaVariables("all"); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); CallableElementParameter parameter = callableElement.getOutputs().get(0); assertNotNull(parameter); assertTrue(parameter.isAllVariables()); }
@Test public void testVersionConstant() { // given: String caseVersion = "2"; caseTask.setCamundaCaseVersion(caseVersion); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); ParameterValueProvider caseVersionValueProvider = callableElement.getVersionValueProvider(); assertNotNull(caseVersionValueProvider); assertTrue(caseVersionValueProvider instanceof ConstantValueProvider); assertEquals(caseVersion, caseVersionValueProvider.getValue(null)); }
@Test public void testCaseRefExpression() { // given: String caseRef = "${aCaseToCall}"; caseTask.setCase(caseRef); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider(); assertNotNull(caseRefValueProvider); assertTrue(caseRefValueProvider instanceof ElValueProvider); ElValueProvider valueProvider = (ElValueProvider) caseRefValueProvider; assertEquals(caseRef, valueProvider.getExpression().getExpressionText()); }
@Test public void testOutputTarget() { // given: String target = "b"; ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class); sourceElement.setCamundaTarget(target); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); CallableElementParameter parameter = callableElement.getOutputs().get(0); assertNotNull(parameter); assertFalse(parameter.isAllVariables()); assertEquals(target, parameter.getTarget()); }
@Test public void testBusinessKeyConstant() { // given: String businessKey = "myBusinessKey"; ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaIn businessKeyElement = createElement(extensionElements, null, CamundaIn.class); businessKeyElement.setCamundaBusinessKey(businessKey); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); ParameterValueProvider businessKeyValueProvider = callableElement.getBusinessKeyValueProvider(); assertNotNull(businessKeyValueProvider); assertTrue(businessKeyValueProvider instanceof ConstantValueProvider); assertEquals(businessKey, businessKeyValueProvider.getValue(null)); }
@Test public void testOutputs() { // given: ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaOut variablesElement = createElement(extensionElements, null, CamundaOut.class); variablesElement.setCamundaVariables("all"); CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class); sourceElement.setCamundaSource("a"); CamundaOut sourceExpressionElement = createElement(extensionElements, null, CamundaOut.class); sourceExpressionElement.setCamundaSourceExpression("${b}"); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); List<CallableElementParameter> outputs = callableElement.getOutputs(); assertNotNull(outputs); assertFalse(outputs.isEmpty()); assertEquals(3, outputs.size()); }