001: package org.emforge.test;
002:
003: import static org.junit.Assert.assertNotNull;
004: import static org.junit.Assert.fail;
005:
006: import java.util.Collection;
007: import java.util.List;
008:
009: import org.apache.commons.logging.Log;
010: import org.apache.commons.logging.LogFactory;
011: import org.emforge.BpmService;
012: import org.emforge.EmForgeException;
013: import org.emforge.xfer.CommentTO;
014: import org.emforge.xfer.StepTO;
015: import org.emforge.xfer.TaskStatus;
016: import org.emforge.xfer.TaskTO;
017: import org.emforge.xfer.WorkflowTO;
018: import org.junit.Test;
019: import org.springframework.beans.factory.annotation.Autowired;
020:
021: /** Unit-test for checking Web-Services
022: * later should be moved into separate project
023: *
024: */
025: public class BpmServiceTest extends BaseWsUnitTest {
026: private final Log log = LogFactory.getLog(getClass());
027:
028: @Autowired
029: private BpmService bpmServiceClient;
030:
031: @Test
032: public void testGetActiveSteps() throws EmForgeException {
033: List<StepTO> steps = bpmServiceClient.getActiveSteps(null);
034: assertNotNull(steps);
035:
036: // list all tasks
037: for (int i = 0; i < steps.size(); i++) {
038: StepTO step = steps.get(i);
039: log.info("Step #" + step.getId() + " : " + step.getTitle());
040: }
041: }
042:
043: @Test
044: public void testForIncorrectProject() {
045: try {
046: bpmServiceClient
047: .getActiveSteps("some dummy project what is not exists");
048: } catch (EmForgeException ex) {
049: // it is ok - exception should be thrown
050: return;
051: }
052:
053: fail("Exception about unknown project should be thrown");
054: }
055:
056: @Test
057: public void testGetStep() throws EmForgeException {
058: // get step with hardcoded id:
059: StepTO step = bpmServiceClient.getStep(10);
060: assertNotNull(step);
061:
062: log.info("Step #" + step.getId() + " : " + step.getTitle());
063: }
064:
065: @Test
066: public void testGetTask() throws EmForgeException {
067: TaskTO task = bpmServiceClient.getTask(6);
068: assertNotNull(task);
069:
070: log.info("Task #" + task.getId() + " : " + task.getTitle());
071: }
072:
073: @Test
074: public void testGetWorkflows() throws EmForgeException {
075: WorkflowTO[] workflows = bpmServiceClient.getWorkflows();
076:
077: for (WorkflowTO workflow : workflows) {
078: log.info("Workflow #" + workflow.getId() + " : "
079: + workflow.getName() + "(" + workflow.getVersion()
080: + ") - " + workflow.getStartName());
081: }
082: }
083:
084: // this test is disabled since milestone is not exists in test-database
085: public void testFindTasks() throws EmForgeException {
086: Collection<TaskTO> tasks = bpmServiceClient.findTasks(
087: "EmForge0.21", TaskStatus.CLOSED, false);
088: assertNotNull(tasks);
089:
090: log.info("Number of tasks: " + tasks.size());
091: for (TaskTO task : tasks) {
092: log.info("Task #" + task.getId() + " : " + task.getTitle());
093: }
094:
095: }
096:
097: public void testGetComment() throws EmForgeException {
098: CommentTO[] comments = bpmServiceClient.getTaskComments(6);
099: assertNotNull(comments);
100:
101: log.info("Number of comments for task 6 : " + comments.length);
102: for (CommentTO comment : comments) {
103: log.info("Task #" + comment.getAuthor() + " : "
104: + comment.getMessage());
105: }
106: }
107:
108: public void testAddComment() throws EmForgeException {
109: assert (bpmServiceClient.addComment(6, "test comment"));
110: }
111: }
|