@Test public void testOutputSource() { // given: String source = "a"; ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class); sourceElement.setCamundaSource(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 sourceValueProvider = parameter.getSourceValueProvider(); assertNotNull(sourceValueProvider); assertTrue(sourceValueProvider instanceof ConstantValueProvider); assertEquals(source, sourceValueProvider.getValue(null)); }
@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 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)); }
protected Integer evaluateValueProvider( ParameterValueProvider valueProvider, ExecutionEntity execution, JobDeclaration<?> jobDeclaration) { Object value = valueProvider.getValue(execution); if (!(value instanceof Integer)) { throw new ProcessEngineException( "Priority for job " + jobDeclaration.getActivityId() + "/" + jobDeclaration.getJobHandlerType() + " instantiated " + "in context of " + execution + " is not an Integer"); } else { return (Integer) value; } }