Skip to content

Commit

Permalink
refactoring junit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jun 7, 2018
1 parent 6a2a26b commit c5a8491
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected void createSubprocesses(final List<String> subProcessDefinitions, fina
sModelVersion=originWorkitem.getModelVersion();
}
workitemSubProcess.replaceItemValue(WorkflowKernel.MODELVERSION,sModelVersion);
workitemSubProcess.replaceItemValue(WorkflowKernel.PROCESSID,
workitemSubProcess.setTaskID(
Integer.valueOf(processData.getItemValueString("processid")));
workitemSubProcess.setEventID(
Integer.valueOf(processData.getItemValueString("activityid")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ public void testConditionalEvent1()
workitem.replaceItemValue(WorkflowKernel.MODELVERSION, WorkflowSimulationEnvironment.DEFAULT_MODEL_VERSION);

// test none condition ...
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.setEventID(10);
workitem = wse.processWorkItem(workitem);
Assert.assertEquals("1.0.0", workitem.getItemValueString("$ModelVersion"));
Assert.assertEquals(1000, workitem.getProcessID());
Assert.assertEquals(1000, workitem.getTaskID());

// test _budget<100
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.replaceItemValue("_budget", 99);
workitem.setEventID(10);
workitem = wse.simulationService.processWorkItem(workitem, null);
Assert.assertEquals(1200, workitem.getProcessID());
Assert.assertEquals(1200, workitem.getTaskID());

// test _budget>100
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.replaceItemValue("_budget", 9999);
workitem.setEventID(10);
workitem = wse.simulationService.processWorkItem(workitem, null);
Assert.assertEquals(1100, workitem.getProcessID());
Assert.assertEquals(1100, workitem.getTaskID());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testProcessSimple()
// load test workitem
ItemCollection workitem = workflowMockEnvironment.database.get("W0000-00001");
workitem.replaceItemValue(WorkflowKernel.MODELVERSION, WorkflowMockEnvironment.DEFAULT_MODEL_VERSION);
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 100);
workitem.setTaskID(100);

workitem = workflowMockEnvironment.workflowService.processWorkItem(workitem);

Expand All @@ -74,7 +74,7 @@ public void testGetEventsSimple() {

// get workitem
ItemCollection workitem = workflowMockEnvironment.database.get("W0000-00001");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 200);
workitem.setTaskID(200);

List<ItemCollection> eventList = null;
try {
Expand All @@ -96,7 +96,7 @@ public void testGetEventsComplex() {

// get workitem
ItemCollection workitem = workflowMockEnvironment.database.get("W0000-00001");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 100);
workitem.setTaskID(100);

Vector<String> members = new Vector<String>();
members.add("jo");
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testGetEventsComplexRestricted() {

// get workitem
ItemCollection workitem = workflowMockEnvironment.database.get("W0000-00001");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 100);
workitem.setTaskID(100);

Vector<String> members = new Vector<String>();
members.add("jo");
Expand Down Expand Up @@ -167,7 +167,7 @@ public List<String> answer(InvocationOnMock invocation) throws Throwable {

// get workitem
ItemCollection workitem = workflowMockEnvironment.database.get("W0000-00001");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 300);
workitem.setTaskID(300);

Vector<String> members = new Vector<String>();
members.add("jo");
Expand Down Expand Up @@ -208,7 +208,7 @@ public List<String> answer(InvocationOnMock invocation) throws Throwable {

// get workitem
ItemCollection workitem = workflowMockEnvironment.database.get("W0000-00001");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 300);
workitem.setTaskID(300);

Vector<String> members = new Vector<String>();
members.add("jo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ public void testConditionalEvent1()
workitem.replaceItemValue(WorkflowKernel.MODELVERSION, WorkflowMockEnvironment.DEFAULT_MODEL_VERSION);

// test none condition ...
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.setEventID(10);
workitem = workflowMockEnvironment.workflowService.processWorkItem(workitem);
Assert.assertEquals("1.0.0", workitem.getItemValueString("$ModelVersion"));
Assert.assertEquals(1000, workitem.getProcessID());
Assert.assertEquals(1000, workitem.getTaskID());

// test _budget<100
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.replaceItemValue("_budget", 99);
workitem.setEventID(10);
workitem = workflowMockEnvironment.workflowService.processWorkItem(workitem);
Assert.assertEquals(1200, workitem.getProcessID());
Assert.assertEquals(1200, workitem.getTaskID());

// test _budget>100
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.replaceItemValue("_budget", 9999);
workitem.setEventID(10);
workitem = workflowMockEnvironment.workflowService.processWorkItem(workitem);
Assert.assertEquals(1100, workitem.getProcessID());
Assert.assertEquals(1100, workitem.getTaskID());

}

Expand All @@ -102,11 +102,11 @@ public void testSplitEvent1()

// test none condition ...
workitem.replaceItemValue("_subject", "Hello");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 1000);
workitem.setTaskID(1000);
workitem.setEventID(10);
workitem = workflowMockEnvironment.workflowService.processWorkItem(workitem);
Assert.assertEquals("1.0.0", workitem.getItemValueString("$ModelVersion"));
Assert.assertEquals(1100, workitem.getProcessID());
Assert.assertEquals(1100, workitem.getTaskID());

// lookup the version.....
List<ItemCollection> versions = new ArrayList<ItemCollection>();
Expand All @@ -122,7 +122,7 @@ public void testSplitEvent1()
Assert.assertNotNull(version);

Assert.assertEquals("Hello", version.getItemValueString("_subject"));
Assert.assertEquals(1200, version.getProcessID());
Assert.assertEquals(1200, version.getTaskID());
Assert.assertEquals(20, version.getItemValueInteger("$lastevent"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.logging.Logger;

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.WorkflowKernel;
import org.imixs.workflow.engine.WorkflowMockEnvironment;
import org.imixs.workflow.engine.plugins.AccessPlugin;
import org.imixs.workflow.exceptions.ModelException;
Expand Down Expand Up @@ -188,7 +187,7 @@ public void testCondition() throws ModelException {

// case I.

documentContext.replaceItemValue(WorkflowKernel.PROCESSID, 200);
documentContext.setTaskID(200);
documentContext.setEventID(20);
documentContext.replaceItemValue("_budget", 50);
try {
Expand All @@ -201,14 +200,14 @@ public void testCondition() throws ModelException {

List writeAccess = documentContext.getItemValue("$WriteAccess");

Assert.assertEquals(300, documentContext.getProcessID());
Assert.assertEquals(300, documentContext.getTaskID());
Assert.assertEquals(2, writeAccess.size());
Assert.assertTrue(writeAccess.contains("joe"));
Assert.assertTrue(writeAccess.contains("sam"));

// case II.

documentContext.replaceItemValue(WorkflowKernel.PROCESSID, 200);
documentContext.setTaskID(200);
documentContext.setEventID(20);
documentContext.replaceItemValue("_budget", 570);
try {
Expand All @@ -221,7 +220,7 @@ public void testCondition() throws ModelException {

writeAccess = documentContext.getItemValue("$WriteAccess");

Assert.assertEquals(400, documentContext.getProcessID());
Assert.assertEquals(400, documentContext.getTaskID());
Assert.assertEquals(1, writeAccess.size());
Assert.assertTrue(writeAccess.contains("tom"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void setup() throws PluginException, ModelException {
documentContext.replaceItemValue("namTeam", list);
documentContext.replaceItemValue("namCreator", "ronny");
documentContext.replaceItemValue(WorkflowKernel.MODELVERSION, WorkflowMockEnvironment.DEFAULT_MODEL_VERSION);
documentContext.replaceItemValue(WorkflowKernel.PROCESSID, 100);
documentContext.setTaskID(100);
documentContext.replaceItemValue(WorkflowKernel.UNIQUEID, WorkflowKernel.generateUniqueID());
workflowMockEnvironment.getDocumentService().save(documentContext);

Expand Down

0 comments on commit c5a8491

Please sign in to comment.