Commit 81a46e45 authored by cijujoseph's avatar cijujoseph

updated test cases to use the new assert classes

parent c655157f
......@@ -11,6 +11,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
......@@ -54,7 +56,7 @@ public class APSAlfrescoDocumentPublishUnitTest extends AbstractBpmnTest {
verify(activiti_publishAlfrescoDelegate, times(1)).execute((DelegateExecution) any());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
......@@ -60,7 +62,7 @@ public class APSRestStepProcessUnitTest extends AbstractBpmnTest {
verify(activiti_restCallDelegate, times(1)).execute((DelegateExecution) any());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
......@@ -31,7 +33,7 @@ public class BoundaryTimerCatchProcessUnitTest extends AbstractBpmnTest {
unitTestHelpers.assertReceiveTask(2, true, null, processDefinitionId);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
@Test
......@@ -48,7 +50,7 @@ public class BoundaryTimerCatchProcessUnitTest extends AbstractBpmnTest {
//Assert days and execute/action timer
unitTestHelpers.assertTimerJob(1, 1, TIME_UNIT_DAY, true);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,9 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.*;
......@@ -30,11 +33,10 @@ public class CandidateGroupAssignmentUnitTest extends AbstractBpmnTest {
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertCandidateAssignment(new String[]{"group1", "group2"}, null, task, true, false);
taskService.complete(task.getId());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
TaskAssert.assertThat(task).hasCandidateGroups(new String[]{"group1", "group2"}, true, false).complete();
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,9 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.*;
......@@ -29,12 +32,12 @@ public class CandidateUserAssignmentUnitTest extends AbstractBpmnTest {
assertNotNull(processInstance);
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertCandidateAssignment(null, new String[]{"user1@example.com", "user2@example.com"}, task, true, false);
taskService.complete(task.getId());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
TaskAssert.assertThat(task).hasCandidateUsers(new String[]{"user1@example.com", "user2@example.com"}, true, false).complete();
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,35 +7,40 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
@TestPropertySource(value = "classpath:local-dev-test.properties")
public class CandidateUserGroupFixedAssignmentUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "CandidateUserGroupFixedAssignment";
}
@Test
public void testProcessExecution() throws Exception {
ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey(processDefinitionKey);
ProcessInstance processInstance = activitiRule.getRuntimeService()
.startProcessInstanceByKey(processDefinitionKey);
assertNotNull(processInstance);
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertUserAssignment("assignee", task, false, null);
unitTestHelpers.assertCandidateAssignment(new String[]{"group1", "group2", "group3"}, new String[]{"user1", "user2", "user3"}, task, false, null);
taskService.complete(task.getId());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
TaskAssert.assertThat(task).hasAssignee("assignee", false, null)
.hasCandidateGroups(new String[] { "group1", "group2", "group3" }, false, null)
.hasCandidateUsers(new String[] { "user1", "user2", "user3" }, false, null).complete();
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -21,6 +21,8 @@ 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.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
......@@ -108,7 +110,7 @@ public class CustomListenersUnitTest extends AbstractBpmnTest {
verify(processEndExecutionListener, times(1)).notify((DelegateExecution) any());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
Map<String, Object> variablesToAssert = new HashMap<String, Object>();
variablesToAssert.put("taskAssignedTaskListener", "executed");
......
......@@ -12,6 +12,9 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.*;
......@@ -19,9 +22,9 @@ import static org.mockito.Mockito.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
@TestPropertySource(value = "classpath:local-dev-test.properties")
public class DMNProcessUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "DMNProcess";
......@@ -34,7 +37,7 @@ public class DMNProcessUnitTest extends AbstractBpmnTest {
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] arg = invocation.getArguments();
DelegateExecution execution = (DelegateExecution) arg[0];
HashMap<String, String> fieldExtensions = new HashMap<String, String>();
......@@ -53,18 +56,18 @@ public class DMNProcessUnitTest extends AbstractBpmnTest {
verify(activiti_executeDecisionDelegate, times(1)).execute((DelegateExecution) any());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
@Test
public void testRuleExecutionFailPath() throws Exception {
Mockito.reset(activiti_executeDecisionDelegate);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] arg = invocation.getArguments();
DelegateExecution execution = (DelegateExecution) arg[0];
HashMap<String, String> fieldExtensions = new HashMap<String, String>();
......@@ -81,14 +84,15 @@ public class DMNProcessUnitTest extends AbstractBpmnTest {
assertNotNull(processInstance);
verify(activiti_executeDecisionDelegate, times(1)).execute((DelegateExecution) any());
assertEquals(1, taskService.createTaskQuery().count());
Task rejectTask = taskService.createTaskQuery().singleResult();
assertEquals("Rule Not Evaluated", rejectTask.getName());
unitTestHelpers.assertUserAssignment("$INITIATOR", rejectTask, false, false);
taskService.complete(rejectTask.getId());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
TaskAssert.assertThat(rejectTask).hasAssignee("$INITIATOR", false, false)
.hasName("Rule Not Evaluated").complete();
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -33,7 +35,7 @@ public class EmailTaskProcessUnitTest extends AbstractBpmnTest {
actualEmails.removeAll(actualEmails);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -9,6 +9,9 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.*;
......@@ -37,14 +40,12 @@ public class GatewaysAndConditionsUnitTest extends AbstractBpmnTest {
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertUserAssignment("$INITIATOR", task, false, false);
Map<String, Object> taskCompleteVars = new HashMap<String, Object>();
processVars.put(unitTestHelpers.getTaskOutcomeVariable(task), "Approve");
taskService.complete(task.getId(), taskCompleteVars);
TaskAssert.assertThat(task).hasAssignee("$INITIATOR", false, false).complete(taskCompleteVars);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
@Test
......@@ -61,18 +62,17 @@ public class GatewaysAndConditionsUnitTest extends AbstractBpmnTest {
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertUserAssignment("$INITIATOR", task, false, false);
Map<String, Object> taskCompleteVars = new HashMap<String, Object>();
taskCompleteVars.put(unitTestHelpers.getTaskOutcomeVariable(task), "Reject");
taskService.complete(task.getId(), taskCompleteVars);
TaskAssert.assertThat(task).hasAssignee("$INITIATOR", false, false).complete(taskCompleteVars);
assertEquals(1, taskService.createTaskQuery().count());
Task rejectTask = taskService.createTaskQuery().singleResult();
assertEquals("rejected", rejectTask.getName());
unitTestHelpers.assertUserAssignment("$INITIATOR", rejectTask, false, false);
taskService.complete(rejectTask.getId());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
TaskAssert.assertThat(rejectTask).hasName("rejected").hasAssignee("$INITIATOR", false, false)
.complete();
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
import static org.junit.Assert.*;
......@@ -35,7 +37,7 @@ public class IntermediateTimerCatchProcessUnitTest extends AbstractBpmnTest {
//Assert days and execute/action timer
unitTestHelpers.assertTimerJob(1, 1, TIME_UNIT_DAY, true);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -39,7 +41,7 @@ public class MessageCatchProcessUnitTest extends AbstractBpmnTest {
//Assert boundary message and execute
unitTestHelpers.assertMessageWait(1, null, "message-boundary", true, null);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -27,7 +29,7 @@ public class NoOpProcessUnitTest extends AbstractBpmnTest {
assertNotNull(processInstance);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -30,7 +32,7 @@ public class ReceiveTaskProcessUnitTest extends AbstractBpmnTest {
unitTestHelpers.assertReceiveTask(1, true, null, processDefinitionId);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -39,7 +41,7 @@ public class SignalCatchProcessUnitTest extends AbstractBpmnTest {
//Assert boundary signal and execute
unitTestHelpers.assertSignalWait(1, null, "signal-boundary", true, null);
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -7,15 +7,18 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
@TestPropertySource(value = "classpath:local-dev-test.properties")
public class UserAssignmentUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "UserAssignment";
......@@ -24,17 +27,17 @@ public class UserAssignmentUnitTest extends AbstractBpmnTest {
@Test
public void testProcessExecution() throws Exception {
ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey(processDefinitionKey);
ProcessInstance processInstance = activitiRule.getRuntimeService()
.startProcessInstanceByKey(processDefinitionKey);
assertNotNull(processInstance);
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertUserAssignment("user1@example.com", task, true, false);
taskService.complete(task.getId());
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
TaskAssert.assertThat(task).hasAssignee("user1@example.com", true, false).complete();
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -10,6 +10,9 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
......@@ -17,9 +20,9 @@ import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
@TestPropertySource(value="classpath:local-dev-test.properties")
@TestPropertySource(value = "classpath:local-dev-test.properties")
public class UserTaskUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "UserTaskProcess";
......@@ -29,21 +32,18 @@ public class UserTaskUnitTest extends AbstractBpmnTest {
public void testProcessExecution() throws Exception {
Map<String, Object> processVars = new HashMap<String, Object>();
processVars.put("initiator", "$INITIATOR");
ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey(processDefinitionKey, processVars);
ProcessInstance processInstance = activitiRule.getRuntimeService()
.startProcessInstanceByKey(processDefinitionKey, processVars);
assertNotNull(processInstance);
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
unitTestHelpers.assertTaskDueDate(2, TIME_UNIT_DAY, task);
unitTestHelpers.assertUserAssignment("$INITIATOR", task, false, false);
taskService.complete(task.getId());
TaskAssert.assertThat(task).hasAssignee("$INITIATOR", false, false).hasDueDate(2, TIME_UNIT_DAY)
.complete();
unitTestHelpers.assertNullProcessInstance(processInstance.getProcessInstanceId());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment