Java Code Examples for org.flowable.engine.ProcessEngine#getProcessEngineConfiguration()

The following examples show how to use org.flowable.engine.ProcessEngine#getProcessEngineConfiguration() . 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: TestHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void annotationDeploymentTearDown(ProcessEngine processEngine, String deploymentId, Class<?> testClass, String methodName) {
    LOGGER.debug("annotation @Deployment deletes deployment for {}.{}", testClass.getSimpleName(), methodName);
    if (deploymentId != null) {
        try {
            ProcessEngineConfigurationImpl processEngineConfig = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
            processEngineConfig.getFlowable5CompatibilityHandler().deleteDeployment(deploymentId, true);
        } catch (FlowableObjectNotFoundException e) {
            // Deployment was already deleted by the test case. Ignore.
        }
    }
}
 
Example 2
Source File: AbstractFlowableTestCase.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected static void cleanDeployments(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    for (String autoDeletedDeploymentId : deploymentIdsForAutoCleanup) {
        processEngineConfiguration.getRepositoryService().deleteDeployment(autoDeletedDeploymentId, true);
    }
    deploymentIdsForAutoCleanup.clear();
}
 
Example 3
Source File: EventRegistryAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private static EventRegistryEngineConfiguration eventRegistryEngine(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    return EngineServiceUtil.getEventRegistryEngineConfiguration(processEngineConfiguration);
}
 
Example 4
Source File: CmmnEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private static CmmnEngineConfigurationApi cmmnEngine(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    return EngineServiceUtil.getCmmnEngineConfiguration(processEngineConfiguration);
}
 
Example 5
Source File: IdmEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private static IdmEngineConfigurationApi idmEngine(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    return EngineServiceUtil.getIdmEngineConfiguration(processEngineConfiguration);
}
 
Example 6
Source File: ContentEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private static ContentEngineConfigurationApi contentEngine(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    return EngineServiceUtil.getContentEngineConfiguration(processEngineConfiguration);
}
 
Example 7
Source File: FormEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private static FormEngineConfigurationApi formEngine(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    return EngineServiceUtil.getFormEngineConfiguration(processEngineConfiguration);
}
 
Example 8
Source File: DmnEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private static DmnEngineConfigurationApi dmnEngine(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    return EngineServiceUtil.getDmnEngineConfiguration(processEngineConfiguration);
}
 
Example 9
Source File: AbstractFlowableTestCase.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected static void validateHistoryData(ProcessEngine processEngine) {
    ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
    HistoryService historyService = processEngine.getHistoryService();
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {

        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().finished().list();

        for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
            
            assertNotNull("Historic process instance has no process definition id", historicProcessInstance.getProcessDefinitionId());
            assertNotNull("Historic process instance has no process definition key", historicProcessInstance.getProcessDefinitionKey());
            assertNotNull("Historic process instance has no process definition version", historicProcessInstance.getProcessDefinitionVersion());
            assertNotNull("Historic process instance has no deployment id", historicProcessInstance.getDeploymentId());
            assertNotNull("Historic process instance has no start activity id", historicProcessInstance.getStartActivityId());
            assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime());
            assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime());

            String processInstanceId = historicProcessInstance.getId();

            // tasks
            List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery()
                    .processInstanceId(processInstanceId).list();
            
            if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
                for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
                    assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId());
                    if (historicTaskInstance.getClaimTime() != null) {
                        assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no work time", historicTaskInstance.getWorkTimeInMillis());
                    }
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no id", historicTaskInstance.getId());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process instance id", historicTaskInstance.getProcessInstanceId());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no execution id", historicTaskInstance.getExecutionId());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process definition id", historicTaskInstance.getProcessDefinitionId());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no task definition key", historicTaskInstance.getTaskDefinitionKey());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no create time", historicTaskInstance.getCreateTime());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime());
                    assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
                }
            }

            // activities
            List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery()
                    .processInstanceId(processInstanceId).list();
            if (historicActivityInstances != null && historicActivityInstances.size() > 0) {
                for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
                    assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no activity id", historicActivityInstance.getActivityId());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no activity type", historicActivityInstance.getActivityType());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no process definition id", historicActivityInstance.getProcessDefinitionId());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no process instance id", historicActivityInstance.getProcessInstanceId());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no execution id", historicActivityInstance.getExecutionId());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime());
                    assertNotNull("Historic activity instance " + historicActivityInstance.getId() + " / " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime());
                    if (historicProcessInstance.getEndTime() == null) {
                        assertActivityInstancesAreSame(historicActivityInstance,
                            processEngine.getRuntimeService().createActivityInstanceQuery().activityInstanceId(historicActivityInstance.getId()).singleResult()
                        );
                    }
                }
            }
        }

    }
}
 
Example 10
Source File: InternalFlowableExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected void doFinally(ExtensionContext context, TestInstance.Lifecycle lifecycleForClean) {
    ProcessEngine processEngine = getProcessEngine(context);
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
    boolean isAsyncHistoryEnabled = processEngineConfiguration.isAsyncHistoryEnabled();

    if (isAsyncHistoryEnabled) {
        ManagementService managementService = processEngine.getManagementService();
        List<HistoryJob> jobs = managementService.createHistoryJobQuery().list();
        for (HistoryJob job : jobs) {
            managementService.deleteHistoryJob(job.getId());
        }
    }

    HistoryManager asyncHistoryManager = null;
    try {
        if (isAsyncHistoryEnabled) {
            processEngineConfiguration.setAsyncHistoryEnabled(false);
            asyncHistoryManager = processEngineConfiguration.getHistoryManager();
            processEngineConfiguration
                .setHistoryManager(new DefaultHistoryManager(processEngineConfiguration, 
                        processEngineConfiguration.getHistoryLevel(), processEngineConfiguration.isUsePrefixId()));
        }

        String annotationDeploymentKey = context.getUniqueId() + ANNOTATION_DEPLOYMENT_ID_KEY;
        String deploymentIdFromDeploymentAnnotation = getStore(context).get(annotationDeploymentKey, String.class);
        if (deploymentIdFromDeploymentAnnotation != null) {
            TestHelper.annotationDeploymentTearDown(processEngine, deploymentIdFromDeploymentAnnotation, context.getRequiredTestClass(),
                context.getRequiredTestMethod().getName());
            getStore(context).remove(annotationDeploymentKey);
        }

        AnnotationSupport.findAnnotation(context.getTestMethod(), CleanTest.class)
            .ifPresent(cleanTest -> removeDeployments(processEngine.getRepositoryService()));

        AbstractFlowableTestCase.cleanDeployments(processEngine);
        
        if (context.getTestInstanceLifecycle().orElse(TestInstance.Lifecycle.PER_METHOD) == lifecycleForClean
                && processEngineConfiguration.isUsingRelationalDatabase()) { // the logic only is applicable to a relational database with tables
            cleanTestAndAssertAndEnsureCleanDb(context, processEngine);
        }

    } finally {

        if (isAsyncHistoryEnabled) {
            processEngineConfiguration.setAsyncHistoryEnabled(true);
            processEngineConfiguration.setHistoryManager(asyncHistoryManager);
        }

        processEngineConfiguration.getClock().reset();
    }
}