use of org.alfresco.service.cmr.workflow.WorkflowTask in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method testBuildWorkflowTask.
@SuppressWarnings("unchecked")
public void testBuildWorkflowTask() throws Exception {
Date date = new Date();
WorkflowTask task = makeTask(date);
Map<String, Object> model = builder.buildSimple(task, null);
Object id = model.get(WorkflowModelBuilder.TASK_ID);
assertEquals(task.getId(), id);
Object url = model.get(WorkflowModelBuilder.TASK_URL);
assertEquals("api/task-instances/" + task.getId(), url);
assertEquals(task.getName(), model.get(WorkflowModelBuilder.TASK_NAME));
assertEquals(task.getTitle(), model.get(WorkflowModelBuilder.TASK_TITLE));
assertEquals(task.getDescription(), model.get(WorkflowModelBuilder.TASK_DESCRIPTION));
assertEquals(task.getState().name(), model.get(WorkflowModelBuilder.TASK_STATE));
assertNull(model.get(WorkflowModelBuilder.TASK_OUTCOME));
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_POOLED));
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_EDITABLE));
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_REASSIGNABLE));
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_CLAIMABLE));
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_RELEASABLE));
Map<String, Object> owner = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_OWNER);
assertEquals(userName, owner.get(WorkflowModelBuilder.PERSON_USER_NAME));
assertEquals(firstName, owner.get(WorkflowModelBuilder.PERSON_FIRST_NAME));
assertEquals(lastName, owner.get(WorkflowModelBuilder.PERSON_LAST_NAME));
Map<String, Object> props = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_PROPERTIES);
assertEquals(task.getProperties().size() + 1, props.size());
assertEquals(5, props.get("test_int"));
assertEquals(false, props.get("test_boolean"));
assertEquals("foo bar", props.get("test_string"));
String dateStr = (String) props.get("test_date");
assertEquals(date, ISO8601DateFormat.parse(dateStr));
Map<String, Object> workflowInstance = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE);
assertNotNull(workflowInstance);
WorkflowInstance instance = task.getPath().getInstance();
assertEquals(instance.getId(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_ID));
assertEquals(instance.isActive(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_IS_ACTIVE));
String startDateStr = ISO8601DateFormat.format(instance.getStartDate());
String workFlowStartDateStr = (String) workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_START_DATE);
assertEquals(startDateStr, ISO8601DateFormat.formatToZulu(workFlowStartDateStr));
task.getProperties().put(WorkflowModel.ASSOC_POOLED_ACTORS, new ArrayList<NodeRef>(0));
model = builder.buildSimple(task, null);
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_POOLED));
ArrayList<NodeRef> actors = new ArrayList<NodeRef>(1);
actors.add(person);
task.getProperties().put(WorkflowModel.ASSOC_POOLED_ACTORS, actors);
model = builder.buildSimple(task, null);
assertEquals(true, model.get(WorkflowModelBuilder.TASK_IS_POOLED));
model = builder.buildSimple(task, Arrays.asList("test_int", "test_string"));
// Check task owner still created properly.
owner = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_OWNER);
assertEquals(userName, owner.get(WorkflowModelBuilder.PERSON_USER_NAME));
// Check properties populated correctly
props = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_PROPERTIES);
assertEquals(2, props.size());
assertEquals(5, props.get("test_int"));
assertEquals("foo bar", props.get("test_string"));
}
use of org.alfresco.service.cmr.workflow.WorkflowTask in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method makeTask.
private WorkflowTask makeTask(Date date) {
String description = "Task Desc";
String id = "testId$1";
String name = "Task Name";
WorkflowTaskState state = WorkflowTaskState.IN_PROGRESS;
String title = "Task Title";
WorkflowPath path = makePath();
WorkflowTaskDefinition definition = makeTaskDefinition();
HashMap<QName, Serializable> properties = makeTaskProperties(date);
return new WorkflowTask(id, definition, name, title, description, state, path, properties);
}
Aggregations