[jbpm-commits] JBoss JBPM SVN: r1561 - in api/trunk/modules/testsuite/src/test/java/org/jboss/bpm: model and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jul 9 14:27:25 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-07-09 14:27:25 -0400 (Wed, 09 Jul 2008)
New Revision: 1561

Added:
   api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/
   api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java
Removed:
   api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/
Log:
Align API with BPMN

Copied: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java (from rev 1559, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessTest.java)
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java	                        (rev 0)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java	2008-07-09 18:27:25 UTC (rev 1561)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+// $Id$
+
+import java.util.Set;
+
+import org.jboss.bpm.InvalidProcessException;
+import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.model.EndEvent;
+import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.NamedFlowObject;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.StartEvent;
+import org.jboss.bpm.model.Task;
+import org.jboss.bpm.test.DefaultEngineTestCase;
+
+public class ProcessTest extends DefaultEngineTestCase
+{
+  public void testBasicSequence() throws Exception
+  {
+    String jpdl = 
+      "<process-definition>" +
+      "  <start-state>" +
+      "    <transition to='stateA' />" +
+      "  </start-state>" +
+      "  <state name='stateA'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <end-state name='end' />" +
+      "</process-definition>";
+    
+    // Create a Process through the ProcessManager
+    ProcessManager pm = ProcessManager.locateProcessManager();
+    Process proc = pm.createProcess(jpdl);
+    assertEquals("AnonymousProcess#0", proc.getName());
+    
+    StartEvent start = proc.getStartEvent();
+    assertNotNull("Start expected", start);
+
+    Set<FlowObject> fos = proc.getFlowObjects();
+    assertEquals(3, fos.size());
+    
+    NamedFlowObject nfo = proc.findFlowObject("stateA");
+    assertNotNull("FlowObject expected", nfo);
+    assertTrue("Task expected", nfo instanceof Task);
+    
+    Set<EndEvent> ends = proc.getEndEvents();
+    assertEquals(1, ends.size());
+  }
+  
+  public void testNoStartState() throws Exception
+  {
+    String jpdl = 
+      "<process-definition>" +
+      "  <state>" +
+      "    <transition to='stateA' />" +
+      "  </state>" +
+      "  <state name='stateA'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <end-state name='end' />" +
+      "</process-definition>";
+
+    ProcessManager pm = ProcessManager.locateProcessManager();
+    try
+    {
+      pm.createProcess(jpdl);
+      fail("InvalidProcessException expected");
+    }
+    catch (InvalidProcessException ex)
+    {
+      assertTrue("Unexpected message: " + ex.getMessage(), ex.getMessage().indexOf("start event") > 0);
+    }
+  }
+  
+  public void testNoEndState() throws Exception
+  {
+    String jpdl = 
+      "<process-definition>" +
+      "  <start-state>" +
+      "    <transition to='stateA' />" +
+      "  </start-state>" +
+      "  <state name='stateA'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <state name='end' />" +
+      "</process-definition>";
+
+    ProcessManager pm = ProcessManager.locateProcessManager();
+    try
+    {
+      pm.createProcess(jpdl);
+      fail("InvalidProcessException expected");
+    }
+    catch (InvalidProcessException ex)
+    {
+      assertTrue("Unexpected message: " + ex.getMessage(), ex.getMessage().indexOf("end event") > 0);
+    }
+  }
+  
+  public void testNodeNameUniqueness() throws Exception
+  {
+    String jpdl = 
+      "<process-definition>" +
+      "  <start-state>" +
+      "    <transition to='stateA' />" +
+      "  </start-state>" +
+      "  <state name='stateA'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <state name='stateA'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <end-state name='end' />" +
+      "</process-definition>";
+
+    ProcessManager pm = ProcessManager.locateProcessManager();
+    try
+    {
+      pm.createProcess(jpdl);
+      fail("InvalidProcessException expected");
+    }
+    catch (InvalidProcessException ex)
+    {
+      // expected;
+    }
+  }
+}




More information about the jbpm-commits mailing list