Unit Testing CaseMigration

Hi,

I’m trying to implement a case migration and I’m starting to write some unit tests so that I can confirm the end result is what I’m expecting.

I’ve used the migration unit tests from here as a starting point. These tests work since they are relatively simple unit tests, however, the cmmn model I’m working with includes a Process Task and when executing the test I’m getting the following error

org.flowable.common.engine.api.FlowableException: Could not start process instance: no interface org.flowable.cmmn.engine.impl.process.ProcessInstanceService implementation found

Currently I’m using the same flowable.cmmn.cfg.xml from your tests minus the test delegate beans and although I’ve tried a few different approaches in the cfg file to get the processInstanceService instantiated I’ve yet to have any success.

Is there any direction you can provide or links to a sample? I looked through all the cmmn test cases thinking there must be one for a model that includes a process task but couldn’t find any.

Thanks,
Dan

Is it possible to share the CMMN xml’s in question and the code you are using to test with? That way we can reproduce.

Looking at the exception: do you have the flowable-cmmn-engine-configurator dependency on your classpath (as that’s where the default implementation of ProcessInstanceService is in)?

Hi,

I’ll create a representative sample of the CMMN xml and share that along with some sample code when I get a chance.

We were able to get past the ProcessInstanceService issue and a few follow on issues by including a processEngine configuration in the flowable.cmmn.cfg.xml and then adding it to the cmmn engine’s configurator property. Here’s more or less what the working config looks like. In order for it to work we also had to include an idGenerator

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="dataSource" class="org.flowable.common.engine.impl.test.ClosingDataSource">
        <constructor-arg>
            <bean class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
                <constructor-arg>
                    <bean class="com.zaxxer.hikari.HikariConfig">
                        <property name="minimumIdle" value="0" />
                        <!-- <property name="jdbcUrl" value="${jdbc.url:jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000}" /> -->
                        <property name="jdbcUrl" value="${jdbc.url:jdbc:h2:~/flowable-db/db6;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9091;DB_CLOSE_DELAY=-1}" />
                        <property name="driverClassName" value="${jdbc.driver:org.h2.Driver}" />
                        <property name="username"  value="${jdbc.username:flowable}" />
                        <property name="password" value="${jdbc.password:flowable}" />
                    </bean>
                </constructor-arg>
            </bean>
        </constructor-arg>
    </bean>
    
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean> 

    <bean id="cmmnEngineConfiguration" class="org.flowable.cmmn.engine.impl.cfg.StandaloneInMemCmmnEngineConfiguration">

        <property name="dataSource" ref="dataSource"/>

        <property name="engineLifecycleListeners">
            <list>
                <ref bean="dataSource"/>
            </list>
        </property>
        <property name="databaseSchemaUpdate" value="true" />
       <!--  <property name="transactionManager" ref="transactionManager" />-->
        <property name="asyncExecutorActivate" value="false" />
        <property name="asyncExecutorDefaultAsyncJobAcquireWaitTime" value="1000" />
        <property name="asyncExecutorDefaultTimerJobAcquireWaitTime" value="1000" />

        <property name="asyncFailedJobWaitTime" value="1" />

        <property name="enableEntityLinks" value="true" />
        <!-- <property name="enableCaseDefinitionHistoryLevel" value="true" /> -->

        <property name="enableHistoricTaskLogging" value="true" />

        <property name="mailServerPort" value="5025" />    
        
        
         <property name="processInstanceService" >
           <ref bean="defaultProcessInstanceService" />        
        </property> 
          <property name="configurators">
            <list>
                <bean class="org.flowable.engine.configurator.ProcessEngineConfigurator">
                    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
                </bean>               
            </list>
        </property>
 
 
    </bean>    
   
     <bean id="defaultProcessInstanceService" class="org.flowable.cmmn.engine.configurator.impl.process.DefaultProcessInstanceService">
        <constructor-arg ref="processEngineConfiguration"/> 
    </bean>

  
    <bean id="processEngineConfiguration" class="org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <property name="jdbcUrl" value="${jdbc.url:jdbc:h2:~/flowable-db/db6;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9091;DB_CLOSE_DELAY=-1}" />
        <property name="jdbcDriver" value="${jdbc.driver:org.h2.Driver}" />
        <property name="jdbcUsername" value="${jdbc.username:flowable}" />
        <property name="jdbcPassword" value="${jdbc.password:flowable}" />
        <property name="databaseSchemaUpdate" value="true" />
        
        <property name="asyncExecutorActivate" value="false" />
        <property name="asyncExecutorDefaultAsyncJobAcquireWaitTime" value="1000" />
        <property name="asyncExecutorDefaultTimerJobAcquireWaitTime" value="1000" />
        
        <property name="asyncFailedJobWaitTime" value="1" />
        
        <property name="enableEntityLinks" value="true" />
        <property name="enableProcessDefinitionInfoCache" value="true" />  
        <property name="idGenerator">
			<bean class="org.flowable.common.engine.impl.persistence.StrongUuidGenerator" />
		</property>  
		
		 
      
    </bean>

    
</beans>

We did, however, run into other issues with this approach as it wasn’t autowiring our delegates. We had to remove the @FlowableCmmnTest annotation from the AbstractCaseMigrationTest and replaced with:

@SpringBootTest(classes = OurApplication.class )
@ActiveProfiles("development")

This negated the whole use of the flowable.cmmn.cfg.xml file and used the engine config in our app instead and allowed us to Autowire our delegates. We’re now having some issues with the actual migration but I’ll post that separately.