public static ProcessEngineConfiguration parseProcessEngineConfiguration(Resource springResource, String beanName) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); xmlBeanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlBeanDefinitionReader.loadBeanDefinitions(springResource); ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) beanFactory.getBean(beanName); if (processEngineConfiguration.getBeans() == null) { processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(beanFactory)); } return processEngineConfiguration; }
public static ProcessEngineConfiguration parseProcessEngineConfiguration(Resource springResource, String beanName) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); xmlBeanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlBeanDefinitionReader.loadBeanDefinitions(springResource); ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) beanFactory.getBean(beanName); if (processEngineConfiguration.getBeans() == null) { processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(beanFactory)); } return processEngineConfiguration; }
@Deployment public void testExceptionThrownBySecondScopeServiceTaskIsNotHandled(){ Map<Object, Object> beans = processEngineConfiguration.getBeans(); beans.put("dummyServiceTask", new DummyServiceTask()); processEngineConfiguration.setBeans(beans); try{ runtimeService.startProcessInstanceByKey("process", Collections.<String, Object>singletonMap("count", 0)); fail(); // the EL resolver will wrap the actual exception inside a process engine exception } //since the NVE extends the ProcessEngineException we have to handle it separately catch(NullValueException nve){ fail("Shouldn't have received NullValueException"); } catch(ProcessEngineException e){ assertThat(e.getMessage(), containsString("Invalid format")); } }
@Deployment @Test public void testExceptionThrownBySecondScopeServiceTaskIsNotHandled() { Map<Object, Object> beans = processEngineConfiguration.getBeans(); beans.put("dummyServiceTask", new DummyServiceTask()); processEngineConfiguration.setBeans(beans); try { runtimeService.startProcessInstanceByKey("process", Collections.<String, Object> singletonMap("count", 0)); fail(); } // since the NVE extends the ProcessEngineException we have to handle it // separately catch (NullValueException nve) { fail("Shouldn't have received NullValueException"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Invalid format")); } }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowBpmnError() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowBpmnError()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowException(); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowBpmnErrorOutput() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowBpmnErrorOutput()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowExceptionOutput(); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowException() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowException()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowException(); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowExceptionOutput() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowExceptionOutput()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowExceptionOutput(); }
@Deployment @Test public void testExceptionThrownBySecondScopeServiceTaskIsNotHandled() { Map<Object, Object> beans = processEngineConfiguration.getBeans(); beans.put("dummyServiceTask", new DummyServiceTask()); processEngineConfiguration.setBeans(beans); try { runtimeService.startProcessInstanceByKey("process", Collections.<String, Object> singletonMap("count", 0)); fail(); } // since the NVE extends the ProcessEngineException we have to handle it // separately catch (NullValueException nve) { fail("Shouldn't have received NullValueException"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Invalid format")); } }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpression.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpression() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegatedVarMapping()); engineRule.getProcessEngineConfiguration().setBeans(vars); engineRule.getRuntimeService().startProcessInstanceByKey("callSimpleSubProcess"); TaskQuery taskQuery = engineRule.getTaskService().createTaskQuery(); //when Task taskInSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskInSubProcess.getName()); //then check if variable mapping was executed - check if input variable exist Object inputVar = engineRule.getRuntimeService().getVariable(taskInSubProcess.getProcessInstanceId(), "TestInputVar"); assertEquals("inValue", inputVar); //when completing the task in the subprocess, finishes the subprocess engineRule.getTaskService().complete(taskInSubProcess.getId()); Task taskAfterSubProcess = taskQuery.singleResult(); assertEquals("Task after subprocess", taskAfterSubProcess.getName()); //then check if variable output mapping was executed - check if output variable exist ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().singleResult(); Object outputVar = engineRule.getRuntimeService().getVariable(processInstance.getId(), "TestOutputVar"); assertEquals("outValue", outputVar); }
public static ProcessEngineConfiguration parseProcessEngineConfiguration(Resource springResource, String beanName) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); xmlBeanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlBeanDefinitionReader.loadBeanDefinitions(springResource); ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) beanFactory.getBean(beanName); if (processEngineConfiguration.getBeans() == null) { processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(beanFactory)); } return processEngineConfiguration; }
@Deployment public void testExceptionThrownBySecondScopeServiceTaskIsNotHandled(){ Map<Object, Object> beans = processEngineConfiguration.getBeans(); beans.put("dummyServiceTask", new DummyServiceTask()); processEngineConfiguration.setBeans(beans); try{ runtimeService.startProcessInstanceByKey("process", Collections.<String, Object>singletonMap("count", 0)); fail(); // the EL resolver will wrap the actual exception inside a process engine exception } //since the NVE extends the ProcessEngineException we have to handle it separately catch(NullValueException nve){ fail("Shouldn't have received NullValueException"); } catch(ProcessEngineException e){ assertThat(e.getMessage(), containsString("Invalid format")); } }
@Deployment @Test public void testExceptionThrownBySecondScopeServiceTaskIsNotHandled() { Map<Object, Object> beans = processEngineConfiguration.getBeans(); beans.put("dummyServiceTask", new DummyServiceTask()); processEngineConfiguration.setBeans(beans); try { runtimeService.startProcessInstanceByKey("process", Collections.<String, Object> singletonMap("count", 0)); fail(); } // since the NVE extends the ProcessEngineException we have to handle it // separately catch (NullValueException nve) { fail("Shouldn't have received NullValueException"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Invalid format")); } }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowExceptionOutput() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowExceptionOutput()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowExceptionOutput(); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowBpmnErrorOutput() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowBpmnErrorOutput()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowExceptionOutput(); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowException() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowException()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowException(); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpressionThrowException.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpressionThrowBpmnError() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegateVarMappingThrowBpmnError()); engineRule.getProcessEngineConfiguration().setBeans(vars); delegateVariableMappingThrowException(); }
@Deployment @Test public void testExceptionThrownBySecondScopeServiceTaskIsNotHandled() { Map<Object, Object> beans = processEngineConfiguration.getBeans(); beans.put("dummyServiceTask", new DummyServiceTask()); processEngineConfiguration.setBeans(beans); try { runtimeService.startProcessInstanceByKey("process", Collections.<String, Object> singletonMap("count", 0)); fail(); } // since the NVE extends the ProcessEngineException we have to handle it // separately catch (NullValueException nve) { fail("Shouldn't have received NullValueException"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Invalid format")); } }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSimpleSubProcessDelegateVarMappingExpression.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testCallSubProcessWithDelegatedVariableMappingeExpression() { //given Map<Object, Object> vars = engineRule.getProcessEngineConfiguration().getBeans(); vars.put("expr", new DelegatedVarMapping()); engineRule.getProcessEngineConfiguration().setBeans(vars); engineRule.getRuntimeService().startProcessInstanceByKey("callSimpleSubProcess"); TaskQuery taskQuery = engineRule.getTaskService().createTaskQuery(); //when Task taskInSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskInSubProcess.getName()); //then check if variable mapping was executed - check if input variable exist Object inputVar = engineRule.getRuntimeService().getVariable(taskInSubProcess.getProcessInstanceId(), "TestInputVar"); assertEquals("inValue", inputVar); //when completing the task in the subprocess, finishes the subprocess engineRule.getTaskService().complete(taskInSubProcess.getId()); Task taskAfterSubProcess = taskQuery.singleResult(); assertEquals("Task after subprocess", taskAfterSubProcess.getName()); //then check if variable output mapping was executed - check if output variable exist ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().singleResult(); Object outputVar = engineRule.getRuntimeService().getVariable(processInstance.getId(), "TestOutputVar"); assertEquals("outValue", outputVar); }