Commit 32ad9148 authored by cijujoseph's avatar cijujoseph

Updated with new assert functions

parent 4ac24772
......@@ -10,7 +10,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.DelegateExecutionAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -39,7 +40,7 @@ public class APSAlfrescoDocumentPublishUnitTest extends AbstractBpmnTest {
fieldExtensions.put("account", "alfresco-2002-alfresco-2");
fieldExtensions.put("site", "my-site");
fieldExtensions.put("publishAsType", "process_initiator");
unitTestHelpers.assertFieldExtensions(5, execution, fieldExtensions);
DelegateExecutionAssert.assertThat(execution).assertFieldExtensions(5, fieldExtensions);
return null;
}
}).when(activiti_publishAlfrescoDelegate).execute((DelegateExecution) any());
......
......@@ -11,7 +11,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.DelegateExecutionAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -38,7 +39,7 @@ public class APSRestStepProcessUnitTest extends AbstractBpmnTest {
HashMap<String, String> fieldExtensions = new HashMap<String, String>();
fieldExtensions.put("restUrl", "https://api.github.com/");
fieldExtensions.put("httpMethod", "GET");
unitTestHelpers.assertFieldExtensions(2, execution, fieldExtensions);
DelegateExecutionAssert.assertThat(execution).assertFieldExtensions(2, fieldExtensions);
System.out.println("Process ID is " + execution.getProcessInstanceId());
// mock as if the rest step sets a variable
execution.setVariable("restResponse", "{}");
......
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -15,12 +15,12 @@ import static com.alfresco.aps.testutils.TestUtilsConstants.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
public class BoundaryTimerCatchProcessUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "BoundaryTimerCatchProcess";
}
@Test
public void testProcessExecution() throws Exception {
......@@ -28,12 +28,10 @@ public class BoundaryTimerCatchProcessUnitTest extends AbstractBpmnTest {
.startProcessInstanceByKey(processDefinitionKey);
assertNotNull(processInstance);
unitTestHelpers.assertReceiveTask(2, true, null, processDefinitionId);
ProcessInstanceAssert.assertThat(processInstance).isComplete();
ProcessInstanceAssert.assertThat(processInstance).receiveTaskCountIs(2).executeReceiveTasks().isComplete();
}
@Test
public void testProcessExecutionViaBoundary() throws Exception {
......@@ -42,13 +40,9 @@ public class BoundaryTimerCatchProcessUnitTest extends AbstractBpmnTest {
assertNotNull(processInstance);
//Assert in seconds and execute/action timer
unitTestHelpers.assertTimerJob(1, 5, TIME_UNIT_MINUTE, true);
//Assert days and execute/action timer
unitTestHelpers.assertTimerJob(1, 1, TIME_UNIT_DAY, true);
ProcessInstanceAssert.assertThat(processInstance).isComplete();
ProcessInstanceAssert.assertThat(processInstance).timerJobCountIs(2)
.timerJobsWithDueDateFromNow(5, TIME_UNIT_MINUTE).timerJobsWithDueDateFromNow(1, TIME_UNIT_DAY)
.executeTimerJobs(5, TIME_UNIT_MINUTE).executeTimerJobs(1, TIME_UNIT_DAY).isComplete();
}
}
\ No newline at end of file
......@@ -6,8 +6,8 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......
......@@ -6,8 +6,8 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......
......@@ -6,8 +6,8 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......
......@@ -20,7 +20,7 @@ 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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......@@ -29,56 +29,59 @@ import static org.junit.Assert.*;
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" })
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml",
"classpath:process-beans-and-mocks.xml" })
public class CustomListenersUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "CustomListeners";
}
@Autowired
TaskAssignedTaskListener taskAssignedTaskListener;
@Autowired
TimerFiredEventListener timerFiredEventListener;
@Autowired
ProcessEndExecutionListener processEndExecutionListener;
@Before
public void beforeTest() throws Exception {
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] arg = invocation.getArguments();
DelegateExecution execution = (DelegateExecution) arg[0];
// mock the listener stuff you require for next process step here (eg:set a variable)
// mock the listener stuff you require for next process step
// here (eg:set a variable)
execution.setVariable("processEndExecutionListener", "executed");
return null;
}
}).when(processEndExecutionListener).notify((DelegateExecution) any());
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] arg = invocation.getArguments();
ActivitiEvent event = (ActivitiEvent) arg[0];
assertTrue(event.getType().equals(ActivitiEventType.TIMER_FIRED));
return null;
}
}).when(timerFiredEventListener).onEvent((ActivitiEvent) any());
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] arg = invocation.getArguments();
DelegateTask task = (DelegateTask) arg[0];
// mock the listener stuff you require for next process step here (eg:set a variable)
// mock the listener stuff you require for next process step
// here (eg:set a variable)
task.setVariable("taskAssignedTaskListener", "executed");
return null;
}
......@@ -90,30 +93,30 @@ public class CustomListenersUnitTest extends AbstractBpmnTest {
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();
verify(taskAssignedTaskListener, times(1)).notify((DelegateTask) any());
taskService.complete(task.getId());
unitTestHelpers.assertTimerJob(1, 2, TIME_UNIT_MINUTE, true);
verify(timerFiredEventListener, times(1)).onEvent((ActivitiEvent) any());
verify(processEndExecutionListener, times(1)).notify((DelegateExecution) any());
ProcessInstanceAssert.assertThat(processInstance).isComplete();
Map<String, Object> variablesToAssert = new HashMap<String, Object>();
variablesToAssert.put("taskAssignedTaskListener", "executed");
variablesToAssert.put("processEndExecutionListener", "executed");
unitTestHelpers.assertHistoricVariableValues(processInstance.getProcessInstanceId(), variablesToAssert);
ProcessInstanceAssert.assertThat(processInstance).timerJobCountIs(1)
.timerJobsWithDueDateFromNow(2, TIME_UNIT_MINUTE).executeTimerJobs().isComplete()
.hasHistoricVariables(variablesToAssert);
verify(timerFiredEventListener, times(1)).onEvent((ActivitiEvent) any());
verify(processEndExecutionListener, times(1)).notify((DelegateExecution) any());
}
}
\ No newline at end of file
......@@ -11,8 +11,9 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.DelegateExecutionAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......@@ -40,7 +41,7 @@ public class DMNProcessUnitTest extends AbstractBpmnTest {
DelegateExecution execution = (DelegateExecution) arg[0];
HashMap<String, String> fieldExtensions = new HashMap<String, String>();
fieldExtensions.put("decisionTableReferenceKey", "dmntest");
unitTestHelpers.assertFieldExtensions(1, execution, fieldExtensions);
DelegateExecutionAssert.assertThat(execution).assertFieldExtensions(1, fieldExtensions);
// mock as if the dmn step sets a variable
execution.setVariable("output", "abc");
return null;
......@@ -70,7 +71,7 @@ public class DMNProcessUnitTest extends AbstractBpmnTest {
DelegateExecution execution = (DelegateExecution) arg[0];
HashMap<String, String> fieldExtensions = new HashMap<String, String>();
fieldExtensions.put("decisionTableReferenceKey", "dmntest");
unitTestHelpers.assertFieldExtensions(1, execution, fieldExtensions);
DelegateExecutionAssert.assertThat(execution).assertFieldExtensions(1, fieldExtensions);
// do not set any variable as if dmn rules didn't pass
return null;
}
......
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......
......@@ -8,8 +8,8 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static com.alfresco.aps.testutils.TestUtilsConstants.*;
......@@ -28,14 +28,10 @@ public class IntermediateTimerCatchProcessUnitTest extends AbstractBpmnTest {
.startProcessInstanceByKey(processDefinitionKey);
assertNotNull(processInstance);
//Assert in seconds and execute/action timer
unitTestHelpers.assertTimerJob(1, 5, TIME_UNIT_MINUTE, true);
//Assert days and execute/action timer
unitTestHelpers.assertTimerJob(1, 1, TIME_UNIT_DAY, true);
ProcessInstanceAssert.assertThat(processInstance).isComplete();
ProcessInstanceAssert.assertThat(processInstance).timerJobCountIs(2)
.timerJobsWithDueDateFromNow(5, TIME_UNIT_MINUTE).timerJobsWithDueDateFromNow(1, TIME_UNIT_DAY)
.executeTimerJobs(5, TIME_UNIT_MINUTE).executeTimerJobs(1, TIME_UNIT_DAY).isComplete();
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -14,7 +14,7 @@ import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
public class MessageCatchProcessUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "MessageCatch";
......@@ -28,18 +28,9 @@ public class MessageCatchProcessUnitTest extends AbstractBpmnTest {
assertNotNull(processInstance);
//Assert message and not execute
unitTestHelpers.assertMessageWait(1, null, "message-catch", false, null);
//Assert boundary message and not execute
unitTestHelpers.assertMessageWait(1, null, "message-boundary", false, null);
//Assert message and execute
unitTestHelpers.assertMessageWait(1, null, "message-catch", true, null);
//Assert boundary message and execute
unitTestHelpers.assertMessageWait(1, null, "message-boundary", true, null);
ProcessInstanceAssert.assertThat(processInstance).isComplete();
ProcessInstanceAssert.assertThat(processInstance).messageWaitCountIs(1, "message-catch")
.executeMessageWaitAtivities("message-catch", null).messageWaitCountIs(1, "message-boundary")
.executeMessageWaitAtivities("message-boundary", null).isComplete();
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -14,7 +14,7 @@ import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
public class ReceiveTaskProcessUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "ReceiveTaskProcess";
......@@ -27,10 +27,9 @@ public class ReceiveTaskProcessUnitTest extends AbstractBpmnTest {
.startProcessInstanceByKey(processDefinitionKey);
assertNotNull(processInstance);
unitTestHelpers.assertReceiveTask(1, true, null, processDefinitionId);
ProcessInstanceAssert.assertThat(processInstance).isComplete();
ProcessInstanceAssert.assertThat(processInstance).receiveTaskCountIs(1).executeReceiveTasks().isComplete();
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alfresco.aps.testutils.AbstractBpmnTest;
import com.alfresco.aps.testutils.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import org.activiti.engine.runtime.ProcessInstance;
import static org.junit.Assert.*;
......@@ -14,7 +14,7 @@ import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.cfg.xml", "classpath:common-beans-and-mocks.xml" })
public class SignalCatchProcessUnitTest extends AbstractBpmnTest {
static {
appName = "Test App";
processDefinitionKey = "SignalCatch";
......@@ -28,18 +28,11 @@ public class SignalCatchProcessUnitTest extends AbstractBpmnTest {
assertNotNull(processInstance);
ProcessInstanceAssert.assertThat(processInstance).signalWaitCountIs(1, "signal-catch")
.executeSignalWaitAtivities("signal-catch", null).signalWaitCountIs(1, "signal-boundary")
.executeSignalWaitAtivities("signal-boundary", null)
.isComplete();
//Assert signal and not execute
unitTestHelpers.assertSignalWait(1, null, "signal-catch", false, null);
//Assert boundary signal and not execute
unitTestHelpers.assertSignalWait(1, null, "signal-boundary", false, null);
//Assert signal and execute
unitTestHelpers.assertSignalWait(1, null, "signal-catch", true, null);
//Assert boundary signal and execute
unitTestHelpers.assertSignalWait(1, null, "signal-boundary", true, null);
ProcessInstanceAssert.assertThat(processInstance).isComplete();
}
}
\ No newline at end of file
......@@ -6,8 +6,8 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......
......@@ -9,8 +9,8 @@ import org.springframework.test.context.ContextConfiguration;
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 com.alfresco.aps.testutils.assertions.ProcessInstanceAssert;
import com.alfresco.aps.testutils.assertions.TaskAssert;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
......
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