Anonymous avatar Anonymous committed 4a40b3d

Initial import from SourceForge

Comments (0)

Files changed (1)

src/test/com/opensymphony/workflow/AutoExecuteTestCase.java

+package com.opensymphony.workflow;
+
+import java.util.*;
+
+import junit.framework.TestCase;
+import com.opensymphony.workflow.spi.Step;
+
+/**
+ * @author Hani Suleiman (hani@formicary.net)
+ * Date: May 9, 2003
+ * Time: 10:26:48 PM
+ */
+public class AutoExecuteTestCase extends TestCase {
+
+    private AbstractWorkflow workflow;
+    //string used by propertyset-create.xml
+    public String myvar;
+
+    public AutoExecuteTestCase(String s) {
+        super(s);
+    }
+
+  protected void setUp() throws Exception
+  {
+    TestWorkflow.configFile = "osworkflow.xml";
+    workflow = new TestWorkflow("testuser");
+  }
+
+    public void testSimpleAuto() throws Exception {
+     long id = workflow.initialize("file:auto1.xml", 1, new HashMap());
+     List currentSteps = workflow.getCurrentSteps(id);
+      assertEquals("Unexpected number of current steps", 1, currentSteps.size());
+      assertEquals("Unexpected current step", 2, ((Step)currentSteps.get(0)).getStepId());
+    }
+
+  public void testExecOnlyOne() throws Exception {
+   long id = workflow.initialize("file:auto2.xml", 1, new HashMap());
+   List currentSteps = workflow.getCurrentSteps(id);
+    assertEquals("Unexpected number of current steps", 1, currentSteps.size());
+    assertEquals("Unexpected current step", 4, ((Step)currentSteps.get(0)).getStepId());
+    List history = workflow.getHistorySteps(id);
+    assertEquals("Expected to have one history step", 1, history.size());
+    assertEquals("Unexpected history step", 2, ((Step)history.get(0)).getStepId());
+  }
+
+  public void testExecTwoActions() throws Exception {
+   long id = workflow.initialize("file:auto3.xml", 1, new HashMap());
+   List currentSteps = workflow.getCurrentSteps(id);
+    assertEquals("Unexpected number of current steps", 1, currentSteps.size());
+    assertEquals("Unexpected current step", 3, ((Step)currentSteps.get(0)).getStepId());
+    List history = workflow.getHistorySteps(id);
+    assertEquals("Expected to have two history steps", 2, history.size());
+    assertEquals("Unexpected first history step", 1, ((Step)history.get(0)).getStepId());
+    assertEquals("Unexpected second history step", 2, ((Step)history.get(1)).getStepId());
+  }
+
+  public void testConditionCheck() throws Exception {
+    long id = workflow.initialize("file:auto4.xml", 1, new HashMap());
+    List currentSteps = workflow.getCurrentSteps(id);
+     assertEquals("Unexpected number of current steps", 1, currentSteps.size());
+     assertEquals("Unexpected current step", 3, ((Step)currentSteps.get(0)).getStepId());
+  }
+
+  public void testPropertySetCreated() throws Exception {
+    Map inputs = new HashMap();
+    List list = new ArrayList();
+    inputs.put("list", list);
+    long id = workflow.initialize("file:propertyset-create.xml", 1, inputs);
+    String value = (String)list.get(0);
+    assertEquals("Unexpected property set value for key myvar", "anything", value);
+    List currentSteps = workflow.getCurrentSteps(id);
+     assertEquals("Unexpected number of current steps", 1, currentSteps.size());
+     assertEquals("Unexpected current step", 1, ((Step)currentSteps.get(0)).getStepId());
+  }
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.