Commit 2d56a62e authored by cijujoseph's avatar cijujoseph

More enhancements and bpmn path coverage tests

parent 8ff208d8
package com.alfresco.aps.test.dmn;
import static com.alfresco.aps.testutils.TestUtilsConstants.DMN_RESOURCE_PATH;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.activiti.dmn.engine.RuleEngineExecutionResult;
import com.activiti.dmn.engine.domain.entity.DmnDeployment;
import com.alfresco.aps.testutils.AbstractDmnTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.dmn.cfg.xml" })
public class DmnUnitTest extends AbstractDmnTest {
String decisonTableKey = "dmntest";
String appName = "Test App";
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
//Deploy the dmn files
Iterator<File> it = FileUtils.iterateFiles(new File(DMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("dmn")) {
DmnDeployment dmnDeplyment = repositoryService.createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
deploymentList.add(dmnDeplyment.getId());
}
}
}
@After
public void after() {
for (Long deploymentId : deploymentList) {
repositoryService.deleteDeployment(deploymentId);
}
deploymentList.clear();
static {
appName = "Test App";
decisonTableKey = "dmntest";
}
@Test
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -18,43 +11,24 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class APSRestStepProcessUnitTest extends AbstractTest {
public class APSRestStepProcessUnitTest extends AbstractBpmnTest {
String appName = "Test App";
String processDefinitionKey = "APSRestStepProcess";
static {
appName = "Test App";
processDefinitionKey = "APSRestStepProcess";
}
@Before
public void before() throws Exception {
public void beforeTest() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
activitiRule.getRepositoryService().createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
......@@ -73,14 +47,6 @@ public class APSRestStepProcessUnitTest extends AbstractTest {
}).when(activiti_restCallDelegate).execute((DelegateExecution) any());
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
}
@Test
public void testProcessExecution() throws Exception {
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class BoundaryTimerCatchProcessUnitTest extends AbstractTest {
public class BoundaryTimerCatchProcessUnitTest extends AbstractBpmnTest {
String appName = "Test App";
String processDefinitionKey = "BoundaryTimerCatchProcess";
static {
appName = "Test App";
processDefinitionKey = "BoundaryTimerCatchProcess";
}
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
@Test
public void testProcessExecution() throws Exception {
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
activitiRule.getRepositoryService().createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
}
ProcessInstance processInstance = activitiRule.getRuntimeService()
.startProcessInstanceByKey(processDefinitionKey);
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
}
assertNotNull(processInstance);
unitTestHelpers.assertReceiveTask(2, true, null, processDefinitionId);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
}
@Test
public void testProcessExecution() throws Exception {
public void testProcessExecutionViaBoundary() throws Exception {
ProcessInstance processInstance = activitiRule.getRuntimeService()
.startProcessInstanceByKey(processDefinitionKey);
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class CandidateGroupAssignmentUnitTest extends AbstractTest {
String appName = "Test App";
String processDefinitionKey = "CandidateGroupAssignment";
public class CandidateGroupAssignmentUnitTest extends AbstractBpmnTest {
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
repositoryService.createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
static {
appName = "Test App";
processDefinitionKey = "CandidateGroupAssignment";
}
@Test
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class CandidateUserAssignmentUnitTest extends AbstractTest {
public class CandidateUserAssignmentUnitTest extends AbstractBpmnTest {
String appName = "Test App";
String processDefinitionKey = "CandidateUserAssignment";
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
repositoryService.createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
static {
appName = "Test App";
processDefinitionKey = "CandidateUserAssignment";
}
@Test
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class CandidateUserGroupFixedAssignmentUnitTest extends AbstractTest {
public class CandidateUserGroupFixedAssignmentUnitTest extends AbstractBpmnTest {
String appName = "Test App";
String processDefinitionKey = "CandidateUserGroupFixedAssignment";
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
repositoryService.createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
static {
appName = "Test App";
processDefinitionKey = "CandidateUserGroupFixedAssignment";
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
}
@Test
public void testProcessExecution() throws Exception {
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -26,14 +20,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.example.listeners.ProcessEndExecutionListener;
import com.alfresco.aps.example.listeners.TaskAssignedTaskListener;
import com.alfresco.aps.example.listeners.TimerFiredEventListener;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
......@@ -41,10 +30,12 @@ import static org.mockito.Mockito.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml", "classpath:process-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class CustomListenersUnitTest extends AbstractTest {
public class CustomListenersUnitTest extends AbstractBpmnTest {
String appName = "Test App";
String processDefinitionKey = "CustomListeners";
static {
appName = "Test App";
processDefinitionKey = "CustomListeners";
}
@Autowired
TaskAssignedTaskListener taskAssignedTaskListener;
......@@ -56,22 +47,7 @@ public class CustomListenersUnitTest extends AbstractTest {
ProcessEndExecutionListener processEndExecutionListener;
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
activitiRule.getRepositoryService().createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
public void beforeTest() throws Exception {
doAnswer(new Answer<Void>() {
@Override
......@@ -109,14 +85,6 @@ public class CustomListenersUnitTest extends AbstractTest {
}).when(taskAssignedTaskListener).notify((DelegateTask) any());
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
}
@Test
public void testProcessExecution() throws Exception {
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
......@@ -19,51 +11,20 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class DMNProcessUnitTest extends AbstractTest {
public class DMNProcessUnitTest extends AbstractBpmnTest {
String appName = "Test App";
String processDefinitionKey = "DMNProcess";
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
activitiRule.getRepositoryService().createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
static {
appName = "Test App";
processDefinitionKey = "DMNProcess";
}
@Test
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import org.activiti.engine.repository.Deployment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractTest;
import com.alfresco.aps.testutils.resources.ActivitiResources;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import static org.junit.Assert.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
public class EmailTaskProcessUnitTest extends AbstractTest {
String appName = "Test App";
String processDefinitionKey = "EmailTaskProcess";
@Before
public void before() throws Exception {
if(env.getProperty ("aps.app.download", Boolean.class, false)){
ActivitiResources.forceGet(appName);
}
Iterator<File> it = FileUtils.iterateFiles(new File(BPMN_RESOURCE_PATH), null, false);
while (it.hasNext()) {
String bpmnXml = ((File) it.next()).getPath();
String extension = FilenameUtils.getExtension(bpmnXml);
if (extension.equals("xml")) {
activitiRule.getRepositoryService().createDeployment()
.addInputStream(bpmnXml, new FileInputStream(bpmnXml)).deploy();
}
}
}
@After
public void after() {
List<Deployment> deploymentList = activitiRule.getRepositoryService().createDeploymentQuery().list();
for (Deployment deployment : deploymentList) {
activitiRule.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
public class EmailTaskProcessUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "EmailTaskProcess";
}
@Test
......
package com.alfresco.aps.test.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;