Package process

Source Code of process.ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess

package process;

import java.util.Iterator;

import de.danet.an.workflow.omgcore.CannotStopException;

import junit.framework.Test;
import junit.framework.TestSuite;
import de.danet.an.util.junit.EJBClientTest;

/**
* Describe class
* <code>ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess</code> here.
*
* @author mao
* @version 1.0
*/
public class ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
    extends WfMOpenTestCase {
    /**
     * Constructor of this TestCase
     * @param name a <code>String</code> value
     */
    public ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
  (String name) {
  super (name);
    }

    /**
     * Construct this test suit.
     * @return a <code>Test</code> value
     */
    public static Test suite() {
        TestSuite suite = new TestSuite();
     suite. addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("importProcessDefinitions"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP0T1T01"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP1T3T3"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP1T4T4"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP0T5T5"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP0T7T7"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP2T8T6"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP1T0TnotExisting"));
     suite.addTest
      (new ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess
       ("checkP3T7CannotStopException"));
        return new EJBClientTest (plc, suite);
    }

    /**
     * Initialisation.
     * The <code>setUp</code> method defines the way a state change is
     * realized. Override this method to change this way.
     * @exception Exception if an error occurs
     */
    protected void setUp() throws Exception {
  xpdlFile = "/process/systestproc5.xml";
  super.setUp();
    }

    /**
     * The engine start a process and its first activity is started
     * automatically. The state of this activity and its implemented subflow
     * must be open.running.
     * @exception Exception if an error occurs.
     */
    public void checkP0T1T01() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P0");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);
  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A0.1SAA")) {
    assertState(activity, RUNNING);
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    assertState(subFlowProcess, RUNNING);
      }
  }
    }

    /**
     * The engine set the state of a activity from suspended to running. The
     * state of its implemented subflow must be also running.
     * @exception Exception if an error occurs
     */
    public void checkP1T3T3() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P1");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);

  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A1.1SAA")) {
    assertState(activity, SUSPENDED);
    activity.setupWaitForState (RUNNING);
    activity.resume();
    activity.waitForState();
    assertState(activity, RUNNING);
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    assertState(subFlowProcess, RUNNING);
      }
  }
    }

    /**
     * The engine set the state of a activity from running to suspended. The
     * state of its implemented subflow must be also suspended.
     * @exception Exception if an error occurs
     */
    public void checkP1T4T4() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P0");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);
  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A0.1SAA")) {
    Thread.sleep(1000);
    assertState(activity, RUNNING);
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    assertState(subFlowProcess, RUNNING);
    // set the state of a activity from running to suspended
    subFlowProcess.setupWaitForState (SUSPENDED);
    activity.setupWaitForState (SUSPENDED);
    activity.suspend();
    activity.waitForState();
    assertState(activity, SUSPENDED);
    // its subflow must have a state of suspended
    subFlowProcess.waitForState();
    assertState(subFlowProcess, SUSPENDED);
      }
  }
    }

    /**
     * The engine set the state of a activity from suspended to aborted. The
     * state of its implemented subflow must be also aborted.
     * @exception Exception if an error occurs
     */
    public void checkP0T5T5() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P0");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);

  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A0.1SAA")) {
    Thread.sleep(1000);
    assertState(activity, RUNNING);
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    assertState(subFlowProcess, RUNNING);
    // set the activity to suspended
    activity.setupWaitForState (SUSPENDED);
    activity.suspend();
    activity.waitForState();
    assertState(activity, SUSPENDED);
    assertState(subFlowProcess, SUSPENDED);
    // set the activity to closed
    activity.setupWaitForState (ABORTED);
    activity.abort();
    activity.waitForState();
    assertState(activity, ABORTED);
    assertState(subFlowProcess, ABORTED);
      }
  }
    }

    /**
     * The engine set the state of a activity from running to terminated. The
     * state of its implemented subflow must be also terminated.
     * @exception Exception if an error occurs
     */
    public void checkP0T7T7() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P0");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);

  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A0.1SAA")) {
    assertState(activity, RUNNING);
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    assertState(subFlowProcess, RUNNING);
    subFlowProcess.setupWaitForState (TERMINATED);
    // set the activity to terminated
    activity.setupWaitForState (TERMINATED);
    activity.terminate();
    activity.waitForState();
    assertState(activity, TERMINATED);
    subFlowProcess.waitForState();
    assertState(subFlowProcess, TERMINATED);
      }
  }
    }

    /**
     * The engine starts a process. It runs automatically. At the end the state
     * of a activity must be terminated. The same is for its implemented
     * subflow.
     * @exception Exception if an error occurs
     */
    public void checkP2T8T6() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P2");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);

  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A2.1SAA")) {
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    if (!subFlowProcess.hasState(COMPLETED)) {
        subFlowProcess.setupWaitForState (COMPLETED);
        subFlowProcess.waitForState();
        assertState(subFlowProcess, COMPLETED);
    }
    if (!activity.hasState(COMPLETED)) {
        activity.setupWaitForState (COMPLETED);
        activity.waitForState();
        assertState(activity, COMPLETED);
    }
      }
  }
  if (!process.hasState(COMPLETED)) {
      process.setupWaitForState (COMPLETED);
      process.waitForState();
      assertState(process, COMPLETED);
  }
    }

    /**
     * The engine starts the process, the start mode of its first activity is
     * manual and the state of this activity is then suspended. Its implemented
     * subflow process is not existing.
     * @exception Exception if an error occurs
     */
    public void checkP1T0TnotExisting() throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P1");
  assertState(process, NOT_STARTED);

  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A1.1SAA")) {
    assertState(activity, NOT_STARTED);
    Thread.sleep(1000);
    // the subflow process is not existing
    assertTrue(activity.performers().size() == 0);
      }
  }
    }

    /**
     * As the subprocess Delayer runs, complete the activity. Exception will
     * be thrown.
     * @exception Exception if an error occurs
     */
    public void checkP3T7CannotStopException () throws Exception {
  // create the process
  SmartWfProcess process = createProcess("st-process5", "P3");
  assertState(process, NOT_STARTED);
  process.start();
  assertState(process, RUNNING);

  Iterator activitiesIt = process.steps().iterator();
  while (activitiesIt.hasNext()) {
      SmartWfActivity activity = (SmartWfActivity)activitiesIt.next();
      if (activity.name().equals("A3.1SAA")) {
    Thread.sleep(1000);
    assertState(activity, RUNNING);
    Thread.sleep(1000);
    Iterator performersIt = activity.performers().iterator();
    SmartWfProcess subFlowProcess
        = (SmartWfProcess)performersIt.next();
    boolean canBeStop = true;
    try {
        assertState(subFlowProcess, RUNNING);
        activity.terminate();
    } catch(CannotStopException cce) {
        canBeStop = false;
    }
    assertTrue(!canBeStop);
      }
  }
    }
}
TOP

Related Classes of process.ProcLifeCycleEngineTriggeredActivityTriggeringSubProcess

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.