From 1a001a5a6834a57f332c0a34e023757a367fee27 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 9 Aug 2017 15:58:00 +0200 Subject: [PATCH] Activiti test as integration (#2399) --- ...ProcessEngineCreationIntegrationTest.java} | 19 +++++----- ...a => ProcessExecutionIntegrationTest.java} | 35 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) rename spring-activiti/src/test/java/com/example/activitiwithspring/{ProcessEngineCreationTests.java => ProcessEngineCreationIntegrationTest.java} (85%) rename spring-activiti/src/test/java/com/example/activitiwithspring/{ProcessExecutionTests.java => ProcessExecutionIntegrationTest.java} (85%) diff --git a/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessEngineCreationTests.java b/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessEngineCreationIntegrationTest.java similarity index 85% rename from spring-activiti/src/test/java/com/example/activitiwithspring/ProcessEngineCreationTests.java rename to spring-activiti/src/test/java/com/example/activitiwithspring/ProcessEngineCreationIntegrationTest.java index 7f07191cde..00afd14590 100644 --- a/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessEngineCreationTests.java +++ b/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessEngineCreationIntegrationTest.java @@ -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()); } diff --git a/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessExecutionTests.java b/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessExecutionIntegrationTest.java similarity index 85% rename from spring-activiti/src/test/java/com/example/activitiwithspring/ProcessExecutionTests.java rename to spring-activiti/src/test/java/com/example/activitiwithspring/ProcessExecutionIntegrationTest.java index cae28d5281..9c35ea413b 100644 --- a/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessExecutionTests.java +++ b/spring-activiti/src/test/java/com/example/activitiwithspring/ProcessExecutionIntegrationTest.java @@ -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 variables = new HashMap(); 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 variables = new HashMap(); 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 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");