Merging DEV/ACTIVITI_INTEGRATION2 to HEAD

25933: Updated activiti jars to 5.3 release + temporarily disabled query-tests for activtiti
	25932: Fixed failing FormServiceImplTest.
	25930: Fixed ClassCastException and NullPointerException when using JBPM and Activiti tasks in Alfresco Explorer.
	25898: Implemented testGetWorkflows() which tests the methods getWorkflows() getActiveWorkflows() and getCompletedWorkflows() for both workflow engines.
	25888: Fixed failing testOutcome.
	25884: Workflow console fully tested using activiti engine + small bugfixes
	25854: Implemented testGetPathProperties on AbstractWorkflowServiceIntegrationTest. This tests getPathProperties for Activiti and JBPM workflow engines.
	25827: Added lifecycle sample for activiti engine
	25801: Added a new WorkflowRestApiTest testTaskInstancesForWorkflowGet. Also fixed issues with ActivitWorkflowEngine.queryTasks() relating to the start task being returned incorrectly.
	25731: Added timer execution test to verify Authentication and Transactional behavior + added license headers to 2 files
	25682: ALF-6902 delete identitylinks + added timer sample + adhoc notify me feature
	25649: Redeploying of parallel activiti WF's turned of (remainder from development)
	25645: Fixing getWorkflows test, using valid date to check "due before"
	25642: Implemented getPathProperties() on ActivitiWorkflowEngine. Also refactored ActivitiTypeConverter to create ActivitiPropertyConverter which uses a WorkflowPropertyHandlerRegistry.
	25636: Fixes for use of Activiti workflows in JSF client
	25615: Added parallel review and approve process (regular + grouped)
	25520: Added REST-test for review workflow and pooled review workflow for both engines
	25471: Added queryTasks test for both engines
	25397: Testing getTimers() on both engines
	25368: Using authorityName instead of name for candidate-group + fixed priority WF vs. Task mixup in start-task
	25335: F96: A form control for LIST constraint based decision properties in Activiti tasks exists
	25324: Added correct sources for current 5.3-SNAPSHOT
	25323: Implemented TaskQuery further and added extra test-coverage + delete/cancel WF now deletes History as well 
	25318: The signal() method on ActivitiWorkflowEngine now returns a WorkflowPath if the signal ended the WorkflowInstance.
	25300: Fixed start workflow form for Activiti pooled review and approve process definition
	25294: Implemented signal() method on ActivitiWorkflowEngine. Currently it returns null if the signal() ended the Workflowinstance.
	25199: Implemented getTimers() + fixed some issues with the outcome prop name + upgraded to activiti 5.3
	25179: Added support for wf:outcome property on Activiti tasks. Now ian arbitrary property can be set as the property from which outcomes are read.
	25152: Refactored the WorkflowServiceImplTest to create an AbstractWorkflowServiceImplTest. Extended this base test with Jbpm and Activiti implementations.
	25134: Fixed workflowPath node issue on start-task + Task variables are no longer flushed to process-instance variables
	25131: ALF-6901 start task completion date + taskListeners using ScriptService instead of activiti's built-in JSR-223
	25105: Implemented getWorkflows() and getCompletedWorkflows() methods on ActivitiWorkflowEngine.
	25098: Mandatory properties are now checked in TaskCompleteListener to allow setting of mandatory properties in end-task listeners before the check is performed + review-pooled used person to set as bpm_assignee + removed duplicate messageService in ActivitiWE
	25089: Merged ActivitiTaskComponent and ActivitiWorkflowComponent into a single class, ActivitiWorkflowEngine.
	25048: Implemented getStartTask(String) method on WorkflowService interface. This gets the start task instance for a given workflow instance Id. Also, modified the start task returned by the ActivitiTaskComponent so that it has the correct title.
	25028: Added WorkflowDefinitionGet webscript and test + tested WorkflowInstanceDelete and fixed WorkflowTaskDefinition bug
	25003: Added getStartTask() method to WorkflowService. Implemented for JBPMEngine and ActivitiTaskComponent.
	24996: Added activiti process-definition for pooled review/approve workflow + new version of activiti 5.2 to allow releasing task to pool agian
	24972: Extended TaskInstanceGet REST-test + upgraded activiti lib due to bug in HistoricTaskInstance
	24934: Refactored package assignment/creation so that it is now mainly performed by the WOrkflowPackageComponent rather than the WorkflowComponent or TaskComponent. Implemented correct package behaviour for Activiti workflow engine.
	24926: Extended TaskInstancePut REST-test + added extra logic for ignoring tasks for deleted/canceled WF's
	24895: Added new tests to FormServiceImplTest to check TaskFormProcessor correctly transitions tasks with both workflow engines.
	24888: Updated WorkflowRestApiTest, enhanced testing of getTaskInstances
	24861: Updated the FormServiceImplTest so that it includes tests for the TaskFormProcessor using both workflow engines.
	24851: Made WorkflowRestApiTest abstract and created a subtype for activiti and jbpm
	24832: Added integration test to FormServiceImplTest to check WorkflowFormProcessor works correctly with both Activiti and Jbpm engines.
	24829: ALF-6195 Pooled actors are now available on completed tasks
	24806: Added null check for parameters variable
	24805: Cleaned up WorkflowRestAPITest to remove deprecated field access.
	24797: ALF-6016 start-task now contains variables, upgraded to activiti 5.2-SNAPSHOT
	24796: Removed accidentaly checked-in folder
	24795: Share project "Catalina-virtual" into "https://svn.alfresco.com/repos/enterprise/alfresco/BRANCHES/DEV/ACTIVITI_INTEGRATION2/root"
	24780: Created Activiti Review & Approve workflow.
	24702: ALF-6201 cleaned up WOFactory.createInstance + removed candidate group from adhoc WF (pooled task)
	24693: ALF-6438 implemented getWorkflowById for completed workflows + added unittest for getWorkflowById from running and complete processes
	24686: ALF-6195 added formKey (typeDefinition name) to variables to make available in history + added test for getTaskById() for a completed task
	24642: ALF-6003 + ALF-6195 Introduced mapping of WorkfloTask from HistoricTaskInstance and it's variables
	24565: ALF-6016 tested getting start task by id + added initial test for taskQuery
	24560: ALF-6217 implemented and tested pooled actors using activiti-candidate user/group
	24520: ALF-6003 ALF-6014 tested + various minor improvements + TaskTypeEvaluator matchin pattern adjusted to be able to use workflow-detail form for activiti start-tasks
	24417: ALF-6003, ALF-6014 Added tasklisteners to set default task props + flush variables when task ends + running script in tasklistener (to set task-variables in script based on wf-props)
	24399: Merged BRANCHES/V3.4 to BRANCHES/DEV/ACTIVITI_INTEGRATION2:
   24396: Fix for ALF-6126: TaskTypeEvaluator uses task-name instead of taskType-name for node-type matching
	24396: Fix for ALF-6126: TaskTypeEvaluator uses task-name instead of taskType-name for node-type matching
	24334: ALF-6015 ALF-6016: Completing a task implemented + using task-local variables
	24125: ALF-5995 properties passed when starting workflow are stored
	24111: ALF-5974, ALF-5972 Task-update implemented + capturing company-home, initiator and initiator home implemented and tested
	23891: Fixing failing tests in ActivitiWorkflowComponentTest
	23776: Upgraded activiti to 5.0-SNAPSHOT + Introduced error-handling using messages + initial support for HistoricActivity/ProcessInstances
	23600: Removing unneeded folder that was introduced accidentally when reattaching SVN to eclipse
	23599: 
	23298: 
	23250: Rolling back revisions 23212 to 23113 to fix issue with logging in.
	23212: Trying to fix the problem with logging in.
	23200: Added Form config for the Activiti Adhoc Process. Fixed failing tests in ActivitiWorkflowComponentTest.
	23197: Fixed failing tests in WorkflowServiceeImplTest. Updated Activiti jars in 3rdParty.
	23191: Adding Activiti Ahodc Workflow to Workflow Deployer to demonstrate Activiti Workflow/Task..Component integration with UI.
	23129: Copy Activiti JAR files when building WAR and doing exploded deploy
	23113: Implemented ActivitiTaskComponent.getTaskById()
	23079: Created ActivitiTaskComponent and started to implement various task getter methods.
	22890: Added testStartTask to WorkflowServiceImplTests to test that the start task functionality works as required by the Workflow UI.
	22889: Added testStartTask to WorkflowServiceImplTests to test that the start task functionality works as required by the Workflow UI.
	22888: Added testStartTask to WorkflowServiceImplTests to test that the start task functionality works as required by the Workflow UI.
	22887: Added testStartTask to WorkflowServiceImplTests to test that the start task functionality works as required by the Workflow UI.
	22769: Added more functionality to ActivitiWorkflowComponent.startWorkflow.
	22759: Implemented more methods for getting WorkflowDefinitions on ActivitiWorkflowComponent. Also added more functionality to the startWorkflow method.
	22758: Implemented more methods for getting WorkflowDefinitions on ActivitiWorkflowComponent. Also added more functionality to the startWorkflow method.
	22672: Created ActivitiWorkflowComponent and implemented deployDefinition(), undeployDefinition() and isDefinitionDeployed() methods.
	22659: Replacing Activiti Jars
	22359: Added tests to check rollback of transactions in Activiti.
	22358: Got some simple transaction tests working. These test transaction visibility is working properly and also check that rollbacks work correctly.
	22342: Created a patch to add the Activiti tables in.
	22333: Added some simple tests to check if Activiti works using a DataSource and TransactionManager.
	22332: Updating Activiti to the beta release.
	22286: Added Activiti and its dependencies to 3rd Party libraries. Updated JUnit jar to 4.8. Created package org/alfresco/repo/workflow/activiti and added some simple tests to check Activiti integration.
	21879: Branch to develop support for Activiti workflow engine.
	23264: Creating branch ACTIVITI_INTEGRATION2 to merge HEAD back into the existing ACTIVITI_INTEGGRATION branch.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@25984 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-03-02 17:12:35 +00:00
parent 8a87e29067
commit 2980cf9f78
130 changed files with 15410 additions and 1988 deletions

View File

@@ -34,9 +34,12 @@ import org.alfresco.repo.forms.FormData.FieldData;
import org.alfresco.repo.forms.PropertyFieldDefinition.FieldConstraint;
import org.alfresco.repo.forms.processor.node.FormFieldConstants;
import org.alfresco.repo.forms.processor.node.TypeFormProcessor;
import org.alfresco.repo.forms.processor.workflow.TransitionFieldProcessor;
import org.alfresco.repo.jscript.ClasspathScriptLocation;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.security.person.TestPersonManager;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
@@ -46,6 +49,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.ScriptLocation;
import org.alfresco.service.cmr.repository.ScriptService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowInstance;
@@ -58,7 +62,6 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.BaseAlfrescoSpringTest;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.springframework.util.StringUtils;
/**
@@ -72,10 +75,10 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
private FormService formService;
private NamespaceService namespaceService;
private ScriptService scriptService;
private PersonService personService;
private ContentService contentService;
private WorkflowService workflowService;
private TestPersonManager personManager;
private NodeRef document;
private NodeRef associatedDoc;
private NodeRef childDoc;
@@ -134,16 +137,19 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
this.formService = (FormService)this.applicationContext.getBean("FormService");
this.namespaceService = (NamespaceService)this.applicationContext.getBean("NamespaceService");
this.scriptService = (ScriptService)this.applicationContext.getBean("ScriptService");
this.personService = (PersonService)this.applicationContext.getBean("PersonService");
PersonService personService = (PersonService)this.applicationContext.getBean("PersonService");
this.contentService = (ContentService)this.applicationContext.getBean("ContentService");
this.workflowService = (WorkflowService)this.applicationContext.getBean("WorkflowService");
MutableAuthenticationService mutableAuthenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
this.personManager = new TestPersonManager(mutableAuthenticationService, personService, nodeService);
// create users
createUser(USER_ONE);
createUser(USER_TWO);
personManager.createPerson(USER_ONE);
personManager.createPerson(USER_TWO);
// Do the tests as userOne
authenticationComponent.setCurrentUser(USER_ONE);
personManager.setUser(USER_ONE);
String guid = GUID.generate();
@@ -224,23 +230,6 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
this.nodeService.createAssociation(this.document, this.associatedDoc, ContentModel.ASSOC_REFERENCES);
}
private void createUser(String userName)
{
if (this.authenticationService.authenticationExists(userName) == false)
{
this.authenticationService.createAuthentication(userName, "PWD".toCharArray());
PropertyMap ppOne = new PropertyMap(4);
ppOne.put(ContentModel.PROP_USERNAME, userName);
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
this.personService.createPerson(ppOne);
}
}
@SuppressWarnings("unchecked")
public void testGetAllDocForm() throws Exception
{
@@ -775,7 +764,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
String updatedTitle = (String)updatedProps.get(ContentModel.PROP_TITLE);
String updatedAuthor = (String)updatedProps.get(ContentModel.PROP_AUTHOR);
String updatedOriginator = (String)updatedProps.get(ContentModel.PROP_ORIGINATOR);
List updatedAddressees = (List)updatedProps.get(ContentModel.PROP_ADDRESSEES);
List<String> updatedAddressees = (List<String>)updatedProps.get(ContentModel.PROP_ADDRESSEES);
String wrong = (String)updatedProps.get(QName.createQName("cm", "wrong", this.namespaceService));
Date sentDate = (Date)updatedProps.get(ContentModel.PROP_SENTDATE);
@@ -1085,7 +1074,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
assertEquals(expectedContent, content);
}
@SuppressWarnings({ "deprecation", "null", "unchecked" })
@SuppressWarnings({ "deprecation", "null" })
public void disabledTestFDKModel() throws Exception
{
// NOTE: The FDK is not loaded by default, for this test to work you must
@@ -1216,7 +1205,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
assertEquals(duplicateValue, values.getFieldData(duplicatePropField.getDataKeyName()).getValue());
FieldData fieldData = values.getFieldData(duplicateAssocField.getDataKeyName());
assertNotNull(fieldData);
List assocs = (List)fieldData.getValue();
List<?> assocs = (List<?>)fieldData.getValue();
assertNotNull(assocs);
assertEquals(0, assocs.size());
@@ -1264,10 +1253,20 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
assertEquals(1, assocs.size());
}
public void testGetFormForTask() throws Exception
public void testGetFormForJbpmTask() throws Exception
{
WorkflowTask task = getWorkflowTask();
Item item = new Item("task", task.id);
checkGetFormForTask("jbpm$wf:review");
}
public void testGetFormForActivitiTask() throws Exception
{
checkGetFormForTask("activiti$activitiReview");
}
private void checkGetFormForTask(String defName)
{
WorkflowTask task = getWorkflowTask(defName);
Item item = new Item("task", task.getId());
Form form = formService.getForm(item);
assertNotNull(form);
@@ -1276,34 +1275,112 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
List<String> fieldDefNames = form.getFieldDefinitionNames();
assertTrue(fieldDefNames.size() > 0);
// Check the correct field names are present.
List<String> expFields = getExpectedTaskFields();
assertTrue(fieldDefNames.containsAll(expFields));
// Check default value for priority is correct.
List<FieldDefinition> definitions = form.getFieldDefinitions();
String priorityName = WorkflowModel.PROP_PRIORITY.toPrefixString(namespaceService);
for (FieldDefinition definition : definitions)
{
if(priorityName.equals(definition.getName()))
{
assertEquals("2", definition.getDefaultValue());
break;
}
}
}
public void testSaveTask() throws Exception
public void testSaveJbpmTask() throws Exception
{
WorkflowTask task = getWorkflowTask();
checkSaveTask("jbpm$wf:review");
}
public void testSaveActivitiTask() throws Exception
{
checkSaveTask("activiti$activitiReview");
}
private void checkSaveTask(String defName)
{
WorkflowTask task = getWorkflowTask(defName);
QName descName = WorkflowModel.PROP_DESCRIPTION;
Serializable initialDesc = task.properties.get(descName);
Serializable initialDesc = task.getProperties().get(descName);
String testDesc = "Foo-Bar-Test-String";
assertFalse(testDesc.equals(initialDesc));
Item item = new Item("task", task.id);
Item item = new Item("task", task.getId());
FormData data = new FormData();
String descFieldName = FormFieldConstants.PROP_DATA_PREFIX
+ descName.toPrefixString(namespaceService).replace(":", "_");
data.addFieldData(descFieldName, testDesc, true);
formService.saveForm(item, data);
WorkflowTask newTask = workflowService.getTaskById(task.id);
assertEquals(testDesc, newTask.properties.get(descName));
WorkflowTask newTask = workflowService.getTaskById(task.getId());
assertEquals(testDesc, newTask.getProperties().get(descName));
}
public void testTransitionJbpmTask() throws Exception
{
checkTransitionTask("jbpm$wf:review", "approve", "approve");
}
public void testTransitionActivitiTask() throws Exception
{
checkTransitionTask("activiti$activitiReview", ActivitiConstants.DEFAULT_TRANSITION_NAME, "Approve");
}
private void checkTransitionTask(String defName, String transitionId, String expOutcome)
{
WorkflowTask task = getWorkflowTask(defName);
QName descName = WorkflowModel.PROP_DESCRIPTION;
Serializable initialDesc = task.getProperties().get(descName);
String testDesc = "Foo-Bar-Test-String";
assertFalse(testDesc.equals(initialDesc));
Item item = new Item("task", task.getId());
FormData data = new FormData();
String descFieldName = FormFieldConstants.PROP_DATA_PREFIX + descName.toPrefixString(namespaceService).replace(":", "_");
data.addFieldData(descFieldName, testDesc, true);
String reviewOutcomeFieldName = FormFieldConstants.PROP_DATA_PREFIX + "wf_reviewOutcome";
data.addFieldData(reviewOutcomeFieldName, "Approve", true);
String transitionDataKey = FormFieldConstants.PROP_DATA_PREFIX + TransitionFieldProcessor.KEY;
data.addFieldData(transitionDataKey, transitionId);
formService.saveForm(item, data);
WorkflowTask newTask = workflowService.getTaskById(task.getId());
assertEquals("The description should have been updated!", testDesc, newTask.getProperties().get(descName));
// Check the task is completed
assertEquals("The task should have been completed!", WorkflowTaskState.COMPLETED, newTask.getState());
Serializable outcome = newTask.getProperties().get(WorkflowModel.PROP_OUTCOME);
assertEquals("The transition is wrong!", expOutcome, outcome);
}
private WorkflowTask getWorkflowTask()
private WorkflowTask getWorkflowTask(String definitionName)
{
WorkflowDefinition reviewDef = workflowService.getDefinitionByName("jbpm$wf:review");
WorkflowPath path = workflowService.startWorkflow(reviewDef.id, null);
List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.id);
WorkflowDefinition reviewDef = workflowService.getDefinitionByName(definitionName);
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(WorkflowModel.ASSOC_ASSIGNEE, personManager.get(USER_ONE));
properties.put(WorkflowModel.ASSOC_PACKAGE, folder);
WorkflowPath path = workflowService.startWorkflow(reviewDef.getId(), properties);
WorkflowTask task = getTaskForPath(path);
String startTaskId = reviewDef.getStartTaskDefinition().getId();
if (startTaskId.equals(task.getDefinition().getId()))
{
workflowService.endTask(task.getId(), null);
task = getTaskForPath(path);
}
return task;
}
private WorkflowTask getTaskForPath(WorkflowPath path)
{
List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId());
assertNotNull(tasks);
assertTrue(tasks.size() > 0);
WorkflowTask task = tasks.get(0);
@@ -1321,18 +1398,32 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
return fields;
}
public void testWorkflowForms() throws Exception
public void testJbpmWorkflowForm() throws Exception
{
checkWorkflowForms("jbpm_wf_adhoc", "|Task Done");
}
public void testActivitiWorkflowForm() throws Exception
{
checkWorkflowForms("activiti_activitiAdhoc", "Next|Next");
}
private void checkWorkflowForms(String workflowDefName, String transitionLabels) throws Exception
{
// generate a form for a well known workflow-definition supplying
// a legitimate set of fields for the workflow
List<String> fields = new ArrayList<String>(8);
fields.add("bpm:taskId");
fields.add("bpm:workflowDescription");
fields.add("bpm:workflowDueDate");
fields.add("packageItems");
String taskIdName = WorkflowModel.PROP_TASK_ID.toPrefixString(namespaceService);
String workflowDescName = WorkflowModel.PROP_WORKFLOW_DESCRIPTION.toPrefixString(namespaceService);
String workflowDueDateName = WorkflowModel.PROP_WORKFLOW_DUE_DATE.toPrefixString(namespaceService);
String packageItemsName = "packageItems";
fields.add(taskIdName);
fields.add(workflowDescName);
fields.add(workflowDueDateName);
fields.add(packageItemsName);
// Use URL-friendly format.
String workflowDefName = "jbpm_wf_adhoc";
Form form = this.formService.getForm(new Item(WORKFLOW_FORM_ITEM_KIND, workflowDefName), fields);
// check a form got returned
@@ -1355,10 +1446,10 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
}
// find the fields
PropertyFieldDefinition idField = (PropertyFieldDefinition)fieldDefMap.get("bpm:taskId");
PropertyFieldDefinition descriptionField = (PropertyFieldDefinition)fieldDefMap.get("bpm:workflowDescription");
PropertyFieldDefinition dueDateField = (PropertyFieldDefinition)fieldDefMap.get("bpm:workflowDueDate");
AssociationFieldDefinition packageItemsField = (AssociationFieldDefinition)fieldDefMap.get("packageItems");
PropertyFieldDefinition idField = (PropertyFieldDefinition)fieldDefMap.get(taskIdName);
PropertyFieldDefinition descriptionField = (PropertyFieldDefinition)fieldDefMap.get(workflowDescName);
PropertyFieldDefinition dueDateField = (PropertyFieldDefinition)fieldDefMap.get(workflowDueDateName);
AssociationFieldDefinition packageItemsField = (AssociationFieldDefinition)fieldDefMap.get(packageItemsName);
// check fields are present
assertNotNull("Expecting to find the bpm:taskId field", idField);
@@ -1367,45 +1458,48 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
assertNotNull("Expecting to find the packageItems field", packageItemsField);
// get the number of tasks now
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(USER_ONE,
List<WorkflowTask> tasks = workflowService.getAssignedTasks(USER_ONE,
WorkflowTaskState.IN_PROGRESS);
int tasksBefore = tasks.size();
// persist the form
FormData data = new FormData();
data.addFieldData("prop_bpm_workflowDescription", "This is a new adhoc task");
data.addFieldData("assoc_bpm_assignee_added",
this.personService.getPerson(USER_ONE).toString());
data.addFieldData("assoc_packageItems_added", this.document.toString());
data.addFieldData("assoc_bpm_assignee_added", personManager.get(USER_ONE).toString());
data.addFieldData("assoc_packageItems_added", document.toString());
// data.addFieldData("prop_bpm_workflowDueDate", new Date());
// data.addFieldData("prop_bpm_workflowPriority", 1);
// persist the data
WorkflowInstance workflow = (WorkflowInstance)this.formService.saveForm(
WorkflowInstance workflow = (WorkflowInstance)formService.saveForm(
new Item(WORKFLOW_FORM_ITEM_KIND, workflowDefName), data);
// verify that the workflow was started by checking the user has one
// more task and the details on the workflow instance
tasks = this.workflowService.getAssignedTasks(USER_ONE,
WorkflowTaskState.IN_PROGRESS);
tasks = workflowService.getAssignedTasks(USER_ONE, WorkflowTaskState.IN_PROGRESS);
int tasksAfter = tasks.size();
assertTrue("Expecting there to be more tasks", tasksAfter > tasksBefore);
// check workflow instance details
assertEquals("jbpm$wf:adhoc", workflow.definition.name);
String actualWfName = workflow.getDefinition().getName();
assertEquals(workflowDefName, actualWfName.replace('$', '_').replace(':', '_'));
// get the task form and verify data
String taskId = tasks.get(0).getId();
fields.clear();
fields.add("bpm:taskId");
fields.add(taskIdName);
fields.add("transitions");
fields.add("message");
fields.add("taskOwner");
fields.add("packageItems");
form = this.formService.getForm(new Item(TASK_FORM_ITEM_KIND, taskId), fields);
fields.add(packageItemsName);
form = formService.getForm(new Item(TASK_FORM_ITEM_KIND, taskId), fields);
FormData taskData = form.getFormData();
assertEquals(taskId, "jbpm$" + taskData.getFieldData("prop_bpm_taskId").getValue().toString());
assertEquals("|Task Done", taskData.getFieldData("prop_transitions").getValue());
assertEquals("UserOne_FormServiceImplTest|firstName|lastName", taskData.getFieldData("prop_taskOwner").getValue());
assertEquals(taskId.substring(taskId.indexOf('$')+1), taskData.getFieldData("prop_bpm_taskId").getValue().toString());
assertEquals(transitionLabels, taskData.getFieldData("prop_transitions").getValue());
String expOwner = USER_ONE + "|" + personManager.getFirstName(USER_ONE) + "|" + personManager.getLastName(USER_ONE);
assertEquals(expOwner, taskData.getFieldData("prop_taskOwner").getValue());
assertEquals("This is a new adhoc task", taskData.getFieldData("prop_message").getValue());
assertNotNull(taskData.getFieldData("assoc_packageItems").getValue());
@@ -1413,7 +1507,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
String comment = "This is a comment";
data = new FormData();
data.addFieldData("prop_bpm_comment", comment);
this.formService.saveForm(new Item(TASK_FORM_ITEM_KIND, taskId), data);
formService.saveForm(new Item(TASK_FORM_ITEM_KIND, taskId), data);
// check the comment was updated
WorkflowTask task = workflowService.getTaskById(taskId);
@@ -1421,7 +1515,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
assertEquals(comment, taskComment);
// make sure unauthorized user can not update the task
authenticationComponent.setCurrentUser(USER_TWO);
personManager.setUser(USER_TWO);
try
{
@@ -1483,7 +1577,6 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
}
}
@SuppressWarnings("unchecked")
public void testFormData() throws Exception
{
FormData formData = new FormData();
@@ -1503,14 +1596,14 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
assertTrue("Expecting 'multipleValues' to be a List object", (value instanceof List));
formData.addFieldData("multipleValues", "three");
List list = (List)formData.getFieldData("multipleValues").getValue();
List<?> list = (List<?>)formData.getFieldData("multipleValues").getValue();
assertEquals("Expecting 'multipleValues' List to have 3 items", 3, list.size());
// add a List initially then add a value to it
formData.addFieldData("listValue", new ArrayList());
formData.addFieldData("listValue", new ArrayList<Object>());
formData.addFieldData("listValue", "one");
formData.addFieldData("listValue", "two");
list = (List)formData.getFieldData("listValue").getValue();
list = (List<?>)formData.getFieldData("listValue").getValue();
assertEquals("Expecting 'listValue' List to have 2 items", 2, list.size());
// test overwrite parameter

View File

@@ -67,8 +67,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
this.updater = new TaskUpdater(item.id, workflowService, nodeService);
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#addAssociation(org.alfresco.service.namespace.QName, java.util.List)
/**
* {@inheritDoc}
*/
@Override
protected boolean addAssociation(QName qName, List<NodeRef> values)
@@ -77,8 +77,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
return true;
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#removeAssociation(org.alfresco.service.namespace.QName, java.util.List)
/**
* {@inheritDoc}
*/
@Override
protected boolean removeAssociation(QName qName, List<NodeRef> values)
@@ -87,8 +87,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
return true;
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#updateProperty(org.alfresco.service.namespace.QName, java.io.Serializable)
/**
* {@inheritDoc}
*/
@Override
protected boolean updateProperty(QName qName, Serializable value)
@@ -97,8 +97,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
return true;
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#addTransientAssociation(java.lang.String, java.util.List)
/**
* {@inheritDoc}
*/
@Override
protected boolean addTransientAssociation(String fieldName, List<NodeRef> values)
@@ -112,8 +112,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
return false;
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#removeTransientAssociation(java.lang.String, java.util.List)
/**
* {@inheritDoc}
*/
@Override
protected boolean removeTransientAssociation(String fieldName, List<NodeRef> values)
@@ -127,8 +127,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
return false;
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#addTransientProperty(java.lang.String, org.alfresco.repo.forms.FormData.FieldData)
/**
* {@inheritDoc}
*/
@Override
protected boolean updateTransientProperty(String fieldName, FieldData fieldData)
@@ -148,8 +148,8 @@ public class TaskFormPersister extends ContentModelFormPersister<WorkflowTask>
return false;
}
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.workflow.ContentModelFormPersister#persist()
/**
* {@inheritDoc}
*/
@Override
public WorkflowTask persist()

View File

@@ -19,28 +19,10 @@
package org.alfresco.repo.forms.processor.workflow;
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DATA_ADDED_SUFFIX;
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DATA_PREFIX;
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.ASSOC_DATA_REMOVED_SUFFIX;
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DATA_PREFIX;
import static org.alfresco.repo.workflow.WorkflowModel.ASPECT_WORKFLOW_PACKAGE;
import static org.alfresco.repo.workflow.WorkflowModel.ASSOC_ASSIGNEE;
import static org.alfresco.repo.workflow.WorkflowModel.ASSOC_PACKAGE_CONTAINS;
import static org.alfresco.repo.workflow.WorkflowModel.ASSOC_POOLED_ACTORS;
import static org.alfresco.repo.workflow.WorkflowModel.PROP_DESCRIPTION;
import static org.alfresco.repo.workflow.WorkflowModel.PROP_HIDDEN_TRANSITIONS;
import static org.alfresco.repo.workflow.WorkflowModel.PROP_PACKAGE_ACTION_GROUP;
import static org.alfresco.repo.workflow.WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP;
import static org.alfresco.repo.workflow.WorkflowModel.PROP_STATUS;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.alfresco.repo.forms.processor.node.FormFieldConstants.*;
import static org.alfresco.repo.workflow.WorkflowModel.*;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.*;
import java.io.Serializable;
import java.util.ArrayList;
@@ -149,13 +131,13 @@ public class TaskFormProcessorTest extends TestCase
Item item = new Item("task", TASK_ID);
WorkflowTask result = processor.getTypedItem(item);
assertNotNull(result);
assertEquals(TASK_ID, result.id);
assertEquals(TASK_ID, result.getId());
// Check URI-encoded id.
item = new Item("task", TASK_ID.replace('$', '_'));
result = processor.getTypedItem(item);
assertNotNull(result);
assertEquals(TASK_ID, result.id);
assertEquals(TASK_ID, result.getId());
}
public void testGenerateSetsItemAndUrl() throws Exception
@@ -251,13 +233,11 @@ public class TaskFormProcessorTest extends TestCase
WorkflowTransition transition1 = makeTransition("id1", "title1");
WorkflowTransition transition2 = makeTransition("id2", "title2");
WorkflowTransition transition3 = makeTransition("id3", "title3");
WorkflowTransition[] transitions = new WorkflowTransition[] {transition1, transition2, transition3};
task.definition.node = new WorkflowNode();
task.definition.node.transitions = transitions;
task = makeTask(transition1, transition2, transition3);
// Hide transition with id3.
Serializable hiddenValue = (Serializable) Collections.singletonList("id3");
task.properties.put(PROP_HIDDEN_TRANSITIONS, hiddenValue );
task.getProperties().put(PROP_HIDDEN_TRANSITIONS, hiddenValue );
form = processForm(fieldName);
transitionValues = "id1|title1,id2|title2";
@@ -273,14 +253,14 @@ public class TaskFormProcessorTest extends TestCase
// add a description to the task and check it comes back
message = "This is some text the user may have entered";
this.task.properties.put(PROP_DESCRIPTION, message);
this.task.getProperties().put(PROP_DESCRIPTION, message);
form = processForm(fieldName);
checkSingleProperty(form, fieldName, message);
// set the description to the same as the task title
// and make sure the message comes back as null
this.task.properties.put(PROP_DESCRIPTION, this.task.title);
this.task.getProperties().put(PROP_DESCRIPTION, this.task.getTitle());
form = processForm(fieldName);
checkSingleProperty(form, fieldName, null);
}
@@ -322,10 +302,8 @@ public class TaskFormProcessorTest extends TestCase
private WorkflowTransition makeTransition(String id, String title)
{
WorkflowTransition transition = new WorkflowTransition();
transition.id = id;
transition.title = title;
return transition;
return new WorkflowTransition(
id, title, null, false);
}
public void testPersistPropertyChanged() throws Exception
@@ -610,22 +588,25 @@ public class TaskFormProcessorTest extends TestCase
return defaultProcessor;
}
private WorkflowTask makeTask()
private WorkflowTask makeTask(WorkflowTransition... transitions)
{
WorkflowTask result = new WorkflowTask();
result.id = TASK_ID;
result.state = WorkflowTaskState.IN_PROGRESS;
result.title = "Test";
result.definition = makeTaskDefinition();
result.properties = makeTaskProperties();
String id = TASK_ID;
String title = "Test";
WorkflowTaskState state = WorkflowTaskState.IN_PROGRESS;
WorkflowTaskDefinition taskDef = makeTaskDefinition(transitions);
Map<QName, Serializable> properties = makeTaskProperties();
result.path = new WorkflowPath();
result.path.node = new WorkflowNode();
result.path.node.transitions = new WorkflowTransition[0];
result.path.instance = new WorkflowInstance();
result.path.instance.definition = new WorkflowDefinition("42", "Test", "1.0", "Test", "Test", null);
result.path.instance.workflowPackage = PCKG_NODE;
return result;
WorkflowDefinition definition = new WorkflowDefinition("42", "Test", "1.0", "Test", "Test", null);
NodeRef wfPackage = PCKG_NODE;
WorkflowInstance instance = new WorkflowInstance(null,
definition, null,
null, wfPackage,
null, true, null, null);
WorkflowNode node = new WorkflowNode("", "", "", "", true, new WorkflowTransition[0]);
WorkflowPath path = new WorkflowPath(null, instance, node, true);
return new WorkflowTask(id,
taskDef, null, title, null, state, path, properties);
}
private HashMap<QName, Serializable> makeTaskProperties()
@@ -636,13 +617,13 @@ public class TaskFormProcessorTest extends TestCase
return properties;
}
private WorkflowTaskDefinition makeTaskDefinition()
private WorkflowTaskDefinition makeTaskDefinition(WorkflowTransition... transitions)
{
WorkflowTaskDefinition definition = new WorkflowTaskDefinition();
definition.id = "DefinitionId";
definition.metadata = makeTypeDef();
definition.node = mock(WorkflowNode.class);
return definition;
String id = "DefinitionId";
TypeDefinition metadata = makeTypeDef();
WorkflowNode node = new WorkflowNode("", "", "", "", true, transitions);
return new WorkflowTaskDefinition(id,
node, metadata);
}
private TypeDefinition makeTypeDef()
@@ -727,7 +708,7 @@ public class TaskFormProcessorTest extends TestCase
private DictionaryService makeDictionaryService()
{
DictionaryService mock = mock(DictionaryService.class);
when(mock.getAnonymousType((QName) any(), (Collection<QName>) any())).thenReturn(task.definition.metadata);
when(mock.getAnonymousType((QName) any(), (Collection<QName>) any())).thenReturn(task.getDefinition().getMetadata());
return mock;
}
@@ -761,8 +742,7 @@ public class TaskFormProcessorTest extends TestCase
}
});
this.newTask = new WorkflowTask();
newTask.id = TASK_ID;
this.newTask = new WorkflowTask(TASK_ID, null, null, null, null, null, null, null);
when(service.updateTask(anyString(), anyMap(), anyMap(), anyMap()))
.thenAnswer(new Answer<WorkflowTask>()

View File

@@ -482,11 +482,11 @@ public class WorkflowFormProcessorTest extends TestCase
private WorkflowTaskDefinition makeTaskDefinition()
{
WorkflowTaskDefinition taskDef = new WorkflowTaskDefinition();
taskDef.id = "foo$startTaskDefId";
taskDef.metadata = makeTypeDef();
taskDef.node = new WorkflowNode();
return taskDef;
String id = "foo$startTaskDefId";
TypeDefinition metadata = makeTypeDef();
WorkflowNode node = new WorkflowNode("", "", "", "", false);
return new WorkflowTaskDefinition(id,
node, metadata);
}
private TypeDefinition makeTypeDef()
@@ -587,13 +587,13 @@ public class WorkflowFormProcessorTest extends TestCase
WorkflowService service = mock(WorkflowService.class);
when(service.getDefinitionByName(WF_DEF_NAME)).thenReturn(definition);
newInstance = new WorkflowInstance();
newInstance.id = "foo$instanceId";
WorkflowTask startTask = new WorkflowTask();
startTask.id = "foo$taskId";
final WorkflowPath path = new WorkflowPath();
path.id = "foo$pathId";
path.instance = newInstance;
String instanceId = "foo$instanceId";
newInstance = new WorkflowInstance(instanceId,
definition, null, null, null,
null, true, null, null);
WorkflowTask startTask = new WorkflowTask("foo$taskId", null, null, null, null, null, null, null);
String pathId = "foo$pathId";
final WorkflowPath path = new WorkflowPath(pathId, newInstance, null, true);
when(service.startWorkflow(eq(definition.getId()), anyMap()))
.thenAnswer(new Answer<WorkflowPath>()