Activiti test as integration (#2399)

This commit is contained in:
Grzegorz Piwowarek 2017-08-09 15:58:00 +02:00 committed by GitHub
parent b5478f7e9a
commit 1a001a5a68
2 changed files with 28 additions and 26 deletions

View File

@ -3,11 +3,12 @@ package com.example.activitiwithspring;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
public class ProcessEngineCreationTests {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class ProcessEngineCreationIntegrationTest {
@Test
public void givenXMLConfig_whenGetDefault_thenGotProcessEngine() {
@ -35,7 +36,7 @@ public class ProcessEngineCreationTests {
@Test
public void givenDifferentBeanNameInXMLConfig_whenGetProcessEngineConfig_thenGotResult() {
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResource("my.activiti.cfg.xml", "myProcessEngineConfiguration");
.createProcessEngineConfigurationFromResource("my.activiti.cfg.xml", "myProcessEngineConfiguration");
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
assertNotNull(processEngine);
assertEquals("baeldung", processEngine.getProcessEngineConfiguration().getJdbcUsername());
@ -45,8 +46,8 @@ public class ProcessEngineCreationTests {
public void givenNoXMLConfig_whenCreateInMemProcessEngineConfig_thenCreated() {
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
ProcessEngine processEngine = processEngineConfiguration
.setJdbcUrl("jdbc:h2:mem:my-own-in-mem-db;DB_CLOSE_DELAY=1000")
.buildProcessEngine();
.setJdbcUrl("jdbc:h2:mem:my-own-in-mem-db;DB_CLOSE_DELAY=1000")
.buildProcessEngine();
assertNotNull(processEngine);
assertEquals("sa", processEngine.getProcessEngineConfiguration().getJdbcUsername());
}
@ -55,9 +56,9 @@ public class ProcessEngineCreationTests {
public void givenNoXMLConfig_whenCreateProcessEngineConfig_thenCreated() {
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
ProcessEngine processEngine = processEngineConfiguration
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
.buildProcessEngine();
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
.buildProcessEngine();
assertNotNull(processEngine);
assertEquals("sa", processEngine.getProcessEngineConfiguration().getJdbcUsername());
}

View File

@ -1,10 +1,6 @@
package com.example.activitiwithspring;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
@ -13,19 +9,24 @@ import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ProcessExecutionTests {
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class ProcessExecutionIntegrationTest {
@Test
public void givenBPMN_whenDeployProcess_thenDeployed() {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
Long count = repositoryService.createProcessDefinitionQuery().count();
assertTrue(count >= 1);
}
@ -35,8 +36,8 @@ public class ProcessExecutionTests {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("employeeName", "Kermit");
@ -45,7 +46,7 @@ public class ProcessExecutionTests {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey("vacationRequest", variables);
.startProcessInstanceByKey("vacationRequest", variables);
Long count = runtimeService.createProcessInstanceQuery().count();
assertTrue(count >= 1);
@ -56,8 +57,8 @@ public class ProcessExecutionTests {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("employeeName", "Kermit");
@ -66,7 +67,7 @@ public class ProcessExecutionTests {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey("vacationRequest", variables);
.startProcessInstanceByKey("vacationRequest", variables);
TaskService taskService = processEngine.getTaskService();
List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
@ -87,8 +88,8 @@ public class ProcessExecutionTests {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
.addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
.deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
repositoryService.suspendProcessDefinitionByKey("vacationRequest");