org.flowable.spring.SpringProcessEngineConfiguration Java Examples

The following examples show how to use org.flowable.spring.SpringProcessEngineConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultSpringProcessEngineFactory.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Takes in an V6 process engine config, gives back an V5 Process engine.
 */
@Override
public ProcessEngine buildProcessEngine(ProcessEngineConfigurationImpl v6Configuration) {

    org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl v5Configuration = null;
    if (v6Configuration instanceof SpringProcessEngineConfiguration) {
        v5Configuration = new org.activiti.spring.SpringProcessEngineConfiguration();
        super.copyConfigItems(v6Configuration, v5Configuration);
        copySpringConfigItems((SpringProcessEngineConfiguration) v6Configuration, (org.activiti.spring.SpringProcessEngineConfiguration) v5Configuration);
        return v5Configuration.buildProcessEngine();

    } else {
        return super.buildProcessEngine(v6Configuration);
    }

}
 
Example #2
Source File: FlowableDebuggerConfiguration.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> debuggerProcessEngineConfigurationConfigurer(
    FlowableEngineAgendaFactory agendaFactory) {
    return processEngineConfiguration -> {
        processEngineConfiguration.setEnableDatabaseEventLogging(true);
        processEngineConfiguration.setAgendaFactory(agendaFactory);
        processEngineConfiguration.addCustomJobHandler(new BreakpointJobHandler());

        List<AsyncRunnableExecutionExceptionHandler> customAsyncRunnableExecutionExceptionHandlers = processEngineConfiguration.getCustomAsyncRunnableExecutionExceptionHandlers();
        ArrayList<AsyncRunnableExecutionExceptionHandler> exceptionHandlers;
        if (customAsyncRunnableExecutionExceptionHandlers == null) {
            exceptionHandlers = new ArrayList<>();
        } else {
            exceptionHandlers = new ArrayList<>(customAsyncRunnableExecutionExceptionHandlers);
        }
        exceptionHandlers.add(new DefaultDebuggerExecutionExceptionHandler());
        processEngineConfiguration.setCustomAsyncRunnableExecutionExceptionHandlers(exceptionHandlers);
    };
}
 
Example #3
Source File: FlowableJpaAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void withEntityManagerFactoryBeanAndMissingSpringProcessEngineConfigurationClass() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class
        ))
        .withClassLoader(new FilteredClassLoader(SpringProcessEngineConfiguration.class))
        .run(context -> {
            assertThat(context).doesNotHaveBean(FlowableJpaAutoConfiguration.class);
        });
}
 
Example #4
Source File: DefaultSpringProcessEngineFactory.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void copySpringConfigItems(SpringProcessEngineConfiguration v6Configuration, org.activiti.spring.SpringProcessEngineConfiguration v5Configuration) {
    v5Configuration.setApplicationContext(v6Configuration.getApplicationContext());
    v5Configuration.setTransactionManager(v6Configuration.getTransactionManager());

    Map<Object, Object> beans = v6Configuration.getBeans();

    if (!(beans instanceof org.flowable.common.engine.impl.cfg.SpringBeanFactoryProxyMap)) {
        v5Configuration.setBeans(new SpringBeanFactoryProxyMap(v6Configuration.getApplicationContext()));
    }
    if (v5Configuration.getExpressionManager() == null) {
        v5Configuration.setExpressionManager(new SpringExpressionManager(v6Configuration.getApplicationContext(), v6Configuration.getBeans()));
    }
}
 
Example #5
Source File: SpringJmsConfig.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager,
    JobManager jobManager) {
    SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
    configuration.setDataSource(dataSource);
    configuration.setTransactionManager(transactionManager);
    configuration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    configuration.setAsyncExecutorMessageQueueMode(true);
    configuration.setAsyncExecutorActivate(true);
    configuration.setJobManager(jobManager);
    return configuration;
}
 
Example #6
Source File: SpringJunitJupiterTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
    SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
    configuration.setDataSource(dataSource);
    configuration.setTransactionManager(transactionManager);
    configuration.setDatabaseSchemaUpdate("true");
    return configuration;
}
 
Example #7
Source File: FlowableConfig.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
    engineConfiguration.setActivityFontName("宋体");
    engineConfiguration.setLabelFontName("宋体");
    engineConfiguration.setAnnotationFontName("宋体");
    StrongUuidGenerator uuidGenerator = new StrongUuidGenerator();
    engineConfiguration.setIdGenerator(uuidGenerator) ;
}
 
Example #8
Source File: DmnEngineAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "dmnProcessEngineConfigurationConfigurer")
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> dmnProcessEngineConfigurationConfigurer(
    DmnEngineConfigurator dmnEngineConfigurator
) {
    return processEngineConfiguration -> processEngineConfiguration.addConfigurator(dmnEngineConfigurator);
}
 
Example #9
Source File: FlowableJpaAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@ConditionalOnMissingBean(name = "jpaProcessEngineConfigurer")
@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> jpaProcessEngineConfigurer(EntityManagerFactory emf) {
    return processEngineConfiguration -> {
        processEngineConfiguration.setJpaEntityManagerFactory(emf);
        processEngineConfiguration.setJpaHandleTransaction(false);
        processEngineConfiguration.setJpaCloseEntityManager(false);
    };
}
 
Example #10
Source File: IdmEngineAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "idmProcessEngineConfigurationConfigurer")
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> idmProcessEngineConfigurationConfigurer(
    IdmEngineConfigurator idmEngineConfigurator
) {
    return processEngineConfiguration -> processEngineConfiguration.setIdmEngineConfigurator(idmEngineConfigurator);
}
 
Example #11
Source File: ProcessEngineServicesAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
public ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration configuration) throws Exception {
    ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
    processEngineFactoryBean.setProcessEngineConfiguration(configuration);
    
    invokeConfigurers(configuration);
    
    return processEngineFactoryBean;
}
 
Example #12
Source File: FormEngineAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "formProcessEngineConfigurationConfigurer")
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> formProcessEngineConfigurationConfigurer(
    FormEngineConfigurator formEngineConfigurator) {
    
    return processEngineConfiguration -> processEngineConfiguration.addConfigurator(formEngineConfigurator);
}
 
Example #13
Source File: EventRegistryAutoConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "eventProcessEngineConfigurationConfigurer")
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> eventProcessEngineConfigurationConfigurer(
                EventRegistryEngineConfigurator eventRegistryEngineConfigurator) {
    
    return processEngineConfiguration -> processEngineConfiguration.setEventRegistryConfigurator(eventRegistryEngineConfigurator);
}
 
Example #14
Source File: FlowableConfiguration.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Inject
@Bean
@DependsOn("coreChangelog")
public ProcessEngine processEngine(ApplicationContext applicationContext, SpringProcessEngineConfiguration processEngineConfiguration)
    throws Exception {
    ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
    processEngineFactoryBean.setApplicationContext(applicationContext);
    processEngineFactoryBean.setProcessEngineConfiguration(processEngineConfiguration);
    return processEngineFactoryBean.getObject();
}
 
Example #15
Source File: FlowableEngineConfig.java    From plumdo-work with Apache License 2.0 5 votes vote down vote up
@Override
public SpringProcessEngineConfiguration springProcessEngineConfiguration(DataSource dataSource, PlatformTransactionManager platformTransactionManager, ObjectProvider<AsyncExecutor> asyncExecutorProvider)
        throws IOException {
    SpringProcessEngineConfiguration conf = super.springProcessEngineConfiguration(dataSource, platformTransactionManager, asyncExecutorProvider);
    String databaseSchema = conf.getDatabaseSchema();
    conf.setDatabaseCatalog(databaseSchema);
    conf.setDatabaseTablePrefix(databaseSchema + ".");
    conf.setTablePrefixIsSchema(true);
    conf.setActivityFontName("黑体");
    conf.setLabelFontName("黑体");
    conf.setAnnotationFontName("黑体");
    return conf;
}
 
Example #16
Source File: FlowableConfig.java    From flowable-springboot with MIT License 4 votes vote down vote up
@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
    engineConfiguration.setActivityFontName("宋体");
    engineConfiguration.setLabelFontName("宋体");
    engineConfiguration.setAnnotationFontName("宋体");
}
 
Example #17
Source File: CmmnEngineAutoConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "cmmnProcessEngineConfigurationConfigurer")
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> cmmnProcessEngineConfigurationConfigurer(
    CmmnEngineConfigurator cmmnEngineConfigurator) {
    return processEngineConfiguration -> processEngineConfiguration.addConfigurator(cmmnEngineConfigurator);
}
 
Example #18
Source File: SpringJunitJupiterTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration processEngineConfiguration) {
    ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
    factoryBean.setProcessEngineConfiguration(processEngineConfiguration);
    return factoryBean;
}
 
Example #19
Source File: SpringProcessEngineConfigurator.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public SpringProcessEngineConfiguration getProcessEngineConfiguration() {
    return (SpringProcessEngineConfiguration) processEngineConfiguration;
}
 
Example #20
Source File: SpringAutoDeployTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration processEngineConfiguration) {
    ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
    processEngineFactoryBean.setProcessEngineConfiguration(processEngineConfiguration);
    return processEngineFactoryBean;
}
 
Example #21
Source File: SpringTransactionAndExceptionsTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEngineFactoryBean cmmnEngine(SpringProcessEngineConfiguration processEngineConfiguration) {
    ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
    processEngineFactoryBean.setProcessEngineConfiguration(processEngineConfiguration);
    return processEngineFactoryBean;
}
 
Example #22
Source File: CustomUserEngineConfigurerConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customUserSpringProcessEngineConfigurer() {
    return this::configurationInvoked;
}
 
Example #23
Source File: ProcessEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customIdGeneratorConfigurer() {
    return engineConfiguration -> engineConfiguration.setIdGenerator(new DbIdGenerator());
}
 
Example #24
Source File: ProcessEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneProcessEngineWithBasicDatasourceAndCustomAutoDeploymentStrategies() {
    contextRunner.withUserConfiguration(CustomAutoDeploymentStrategyConfiguration.class)
        .run(context -> {
            assertThat(context).as("Process engine").hasSingleBean(ProcessEngine.class);
            assertThat(context)
                .doesNotHaveBean(AppEngine.class)
                .doesNotHaveBean(IdGenerator.class)
                .doesNotHaveBean("processAppEngineConfigurationConfigurer");

            ProcessEngine processEngine = context.getBean(ProcessEngine.class);

            assertThat(processEngine.getProcessEngineConfiguration().getIdGenerator()).isInstanceOf(StrongUuidGenerator.class);

            assertAllServicesPresent(context, processEngine);
            assertAutoDeployment(context);

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactly(
                            SpringProcessEngineConfiguration.class
                        );
                });

            SpringProcessEngineConfiguration springProcessEngineConfiguration = (SpringProcessEngineConfiguration) processEngine
                .getProcessEngineConfiguration();

            Collection<AutoDeploymentStrategy<ProcessEngine>> deploymentStrategies = springProcessEngineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOf(TestProcessEngineAutoDeploymentStrategy.class);

            assertThat(deploymentStrategies).element(1)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                });

            assertThat(deploymentStrategies).element(2)
                .isInstanceOfSatisfying(SingleResourceAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                });

            assertThat(deploymentStrategies).element(3)
                .isInstanceOfSatisfying(ResourceParentFolderAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isFalse();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                });

            deleteDeployments(processEngine);
        });
}
 
Example #25
Source File: ProcessEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneProcessEngineWithBasicDatasourceAndAutoDeploymentWithLocking() {
    contextRunner
        .withPropertyValues(
            "flowable.auto-deployment.engine.bpmn.use-lock=true",
            "flowable.auto-deployment.engine.bpmn.lock-wait-time=10m",
            "flowable.auto-deployment.engine.bpmn.throw-exception-on-deployment-failure=false",
            "flowable.auto-deployment.engine.bpmn.lock-name=testLock"
        )
        .run(context -> {
            assertThat(context).as("Process engine")
                    .hasSingleBean(ProcessEngine.class)
                    .doesNotHaveBean(AppEngine.class)
                    .doesNotHaveBean(IdGenerator.class)
                    .doesNotHaveBean("processAppEngineConfigurationConfigurer");

            ProcessEngine processEngine = context.getBean(ProcessEngine.class);

            assertThat(processEngine.getProcessEngineConfiguration().getIdGenerator()).isInstanceOf(StrongUuidGenerator.class);

            assertAllServicesPresent(context, processEngine);
            assertAutoDeployment(context);

            assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
                .getBean(CustomUserEngineConfigurerConfiguration.class)
                .satisfies(configuration -> {
                    assertThat(configuration.getInvokedConfigurations())
                        .containsExactly(
                            SpringProcessEngineConfiguration.class
                        );
                });

            SpringProcessEngineConfiguration springProcessEngineConfiguration = (SpringProcessEngineConfiguration) processEngine
                .getProcessEngineConfiguration();

            Collection<AutoDeploymentStrategy<ProcessEngine>> deploymentStrategies = springProcessEngineConfiguration.getDeploymentStrategies();

            assertThat(deploymentStrategies).element(0)
                .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            assertThat(deploymentStrategies).element(1)
                .isInstanceOfSatisfying(SingleResourceAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            assertThat(deploymentStrategies).element(2)
                .isInstanceOfSatisfying(ResourceParentFolderAutoDeploymentStrategy.class, strategy -> {
                    assertThat(strategy.isUseLockForDeployments()).isTrue();
                    assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(10));
                    assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isFalse();
                    assertThat(strategy.getLockName()).isEqualTo("testLock");
                });

            deleteDeployments(processEngine);
        });
}
 
Example #26
Source File: ProcessEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void standaloneProcessEngineWithBasicDatasource() {
    contextRunner.run(context -> {
        assertThat(context).as("Process engine")
                .hasSingleBean(ProcessEngine.class)
                .doesNotHaveBean(AppEngine.class)
                .doesNotHaveBean(IdGenerator.class)
                .doesNotHaveBean("processAppEngineConfigurationConfigurer");

        ProcessEngine processEngine = context.getBean(ProcessEngine.class);

        assertThat(processEngine.getProcessEngineConfiguration().getIdGenerator()).isInstanceOf(StrongUuidGenerator.class);

        assertAllServicesPresent(context, processEngine);
        assertAutoDeployment(context);

        assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
            .getBean(CustomUserEngineConfigurerConfiguration.class)
            .satisfies(configuration -> {
                assertThat(configuration.getInvokedConfigurations())
                    .containsExactly(
                        SpringProcessEngineConfiguration.class
                    );
            });

        SpringProcessEngineConfiguration springProcessEngineConfiguration = (SpringProcessEngineConfiguration) processEngine
            .getProcessEngineConfiguration();

        Collection<AutoDeploymentStrategy<ProcessEngine>> deploymentStrategies = springProcessEngineConfiguration.getDeploymentStrategies();

        assertThat(deploymentStrategies).element(0)
            .isInstanceOfSatisfying(DefaultAutoDeploymentStrategy.class, strategy -> {
                assertThat(strategy.isUseLockForDeployments()).isFalse();
                assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                assertThat(strategy.getLockName()).isNull();
            });

        assertThat(deploymentStrategies).element(1)
            .isInstanceOfSatisfying(SingleResourceAutoDeploymentStrategy.class, strategy -> {
                assertThat(strategy.isUseLockForDeployments()).isFalse();
                assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                assertThat(strategy.getLockName()).isNull();
            });

        assertThat(deploymentStrategies).element(2)
            .isInstanceOfSatisfying(ResourceParentFolderAutoDeploymentStrategy.class, strategy -> {
                assertThat(strategy.isUseLockForDeployments()).isFalse();
                assertThat(strategy.getDeploymentLockWaitTime()).isEqualTo(Duration.ofMinutes(5));
                assertThat(strategy.isThrowExceptionOnDeploymentFailure()).isTrue();
                assertThat(strategy.getLockName()).isNull();
            });

        deleteDeployments(processEngine);
    });
}
 
Example #27
Source File: AppEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customIdGeneratorConfigurer() {
    return engineConfiguration -> engineConfiguration.setIdGenerator(new DbIdGenerator());
}
 
Example #28
Source File: AllEnginesAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void testInclusiveGatewayProcessTask() {
    contextRunner.run((context -> {
        SpringCmmnEngineConfiguration cmmnEngineConfiguration = context.getBean(SpringCmmnEngineConfiguration.class);
        SpringProcessEngineConfiguration processEngineConfiguration = context.getBean(SpringProcessEngineConfiguration.class);

        CmmnRuntimeService cmmnRuntimeService = cmmnEngineConfiguration.getCmmnRuntimeService();
        CmmnHistoryService cmmnHistoryService = cmmnEngineConfiguration.getCmmnHistoryService();
        RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
        TaskService taskService = processEngineConfiguration.getTaskService();

        CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("myCase").start();
        assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero();
        assertThat(runtimeService.createProcessInstanceQuery().count()).isZero();

        List<PlanItemInstance> planItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery()
                .caseInstanceId(caseInstance.getId())
                .planItemDefinitionId("theTask")
                .planItemInstanceState(PlanItemInstanceState.ACTIVE)
                .list();
        assertThat(planItemInstances).hasSize(1);
        cmmnRuntimeService.triggerPlanItemInstance(planItemInstances.get(0).getId());
        assertThat(runtimeService.createProcessInstanceQuery().count()).as("No process instance started").isEqualTo(1L);

        assertThat(taskService.createTaskQuery().count()).isEqualTo(2);

        List<Task> tasks = taskService.createTaskQuery().list();
        taskService.complete(tasks.get(0).getId());
        taskService.complete(tasks.get(1).getId());

        assertThat(taskService.createTaskQuery().count()).isZero();
        assertThat(runtimeService.createProcessInstanceQuery().count()).isZero();

        planItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery()
                .caseInstanceId(caseInstance.getId())
                .planItemDefinitionId("theTask2")
                .list();
        assertThat(planItemInstances)
                .extracting(PlanItemInstance::getName, PlanItemInstance::getState)
                .containsExactly(tuple("Task Two", PlanItemInstanceState.ENABLED));
    }));
}
 
Example #29
Source File: FlowableJpaAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void withEntityManagerFactoryBeanAndSpringProcessEngineConfigurationClass() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class
        ))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(FlowableJpaAutoConfiguration.class)
                .hasBean("jpaProcessEngineConfigurer");

            EntityManagerFactory entityManagerFactory = context.getBean(EntityManagerFactory.class);
            @SuppressWarnings("unchecked")
            EngineConfigurationConfigurer<SpringProcessEngineConfiguration> jpaProcessEngineConfigurer =
                (EngineConfigurationConfigurer<SpringProcessEngineConfiguration>) context
                    .getBean("jpaProcessEngineConfigurer", EngineConfigurationConfigurer.class);

            SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();

            assertThat(configuration.getJpaEntityManagerFactory())
                .as("Process JPA Entity Manager Factory")
                .isNull();
            assertThat(configuration.isJpaHandleTransaction())
                .as("Process JPA handle transaction")
                .isFalse();
            assertThat(configuration.isJpaCloseEntityManager())
                .as("Process JPA close entity manager")
                .isFalse();

            jpaProcessEngineConfigurer.configure(configuration);

            assertThat(configuration.getJpaEntityManagerFactory())
                .as("Process JPA Entity Manager Factory")
                .isSameAs(entityManagerFactory);
            assertThat(configuration.isJpaHandleTransaction())
                .as("Process JPA handle transaction")
                .isFalse();
            assertThat(configuration.isJpaCloseEntityManager())
                .as("Process JPA close entity manager")
                .isFalse();
        });
}
 
Example #30
Source File: SpringProcessEngineConfigurator.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public SpringProcessEngineConfigurator setProcessEngineConfiguration(SpringProcessEngineConfiguration processEngineConfiguration) {
    this.processEngineConfiguration = processEngineConfiguration;
    return this;
}