Skip to content

Commit

Permalink
issue #385
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jun 6, 2018
1 parent 0372a0c commit d1eecf7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,11 @@ public void setTaskID(int taskID) {
// deprecated processID is still supported for a long period. See issue #384
replaceItemValue("$processid", taskID);
}

public ItemCollection task(int taskID) {
setTaskID(taskID);
return this;
}

/**
* This method is deprecated. Use instead getEventID()
Expand Down Expand Up @@ -1152,13 +1157,53 @@ public void setEventID(int eventID) {
replaceItemValue("$activityid", eventID);
}
}

public ItemCollection event(int eventID) {
setEventID(eventID);
return this;
}

/**
* @return current $ModelVersion
*/
public String getModelVersion() {
return getItemValueString(WorkflowKernel.MODELVERSION);
}

/**
* set the $ModelVersion
*/
public void setModelVersion(String modelversion) {
replaceItemValue(WorkflowKernel.MODELVERSION,modelversion);
}

public ItemCollection model(String modelversion) {
setModelVersion(modelversion);
return this;
}



/**
* @return current $ModelVersion
*/
public String getWorkflowGroup() {
return getItemValueString(WorkflowKernel.WORKFLOWGROUP);
}

/**
* set the $ModelVersion
*/
public void setWorkflowGroup(String group) {
replaceItemValue(WorkflowKernel.WORKFLOWGROUP, group);
}

public ItemCollection workflowGroup(String group) {
setWorkflowGroup(group);
return this;
}



/**
* @return $UniqueID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,16 +734,35 @@ public void testFileData() {

}

/*
* Test the fluent code interface.
*/
@Test
@Category(org.imixs.workflow.ItemCollection.class)
public void testFluentInterface() {
ItemCollection itemCollection = new ItemCollection().model("1.0.0").task(1).event(10);

Assert.assertEquals("1.0.0", itemCollection.getModelVersion());
Assert.assertEquals(1, itemCollection.getTaskID());
Assert.assertEquals(10, itemCollection.getEventID());

// set group
itemCollection = new ItemCollection().workflowGroup("Ticket").task(1).event(10);
Assert.assertEquals("Ticket", itemCollection.getWorkflowGroup());
Assert.assertEquals(1, itemCollection.getTaskID());
Assert.assertEquals(10, itemCollection.getEventID());
}

/**
* Test issue #383, #384
*/
@Test
@Category(org.imixs.workflow.ItemCollection.class)
public void testDeprecatedFieldProcessID() {

Assert.assertEquals("$processid", WorkflowKernel.PROCESSID);
Assert.assertEquals("$taskid", WorkflowKernel.TASKID);

ItemCollection itemColSource = new ItemCollection();

itemColSource.replaceItemValue("$processid", 42);
Expand All @@ -757,10 +776,10 @@ public void testDeprecatedFieldProcessID() {
Assert.assertEquals(43, itemColSource.getTaskID());
Assert.assertEquals(43, itemColSource.getProcessID());
Assert.assertEquals(43, itemColSource.getItemValueInteger("$processid"));

// test direct setting
itemColSource = new ItemCollection();
itemColSource.replaceItemValue("$taskid",44);
itemColSource.replaceItemValue("$taskid", 44);
Assert.assertEquals(44, itemColSource.getTaskID());
Assert.assertEquals(44, itemColSource.getProcessID());
// !!!
Expand Down

0 comments on commit d1eecf7

Please sign in to comment.