1   package net.kwfgrid.gworkflowdl;
2   
3   import junit.framework.Assert;
4   import junit.framework.Test;
5   import junit.framework.TestSuite;
6   import net.kwfgrid.gworkflowdl.analysis.Analyzer;
7   import net.kwfgrid.gworkflowdl.analysis.Decision;
8   import net.kwfgrid.gworkflowdl.analysis.Net;
9   import net.kwfgrid.gworkflowdl.analysis.WorkflowAnalyzer;
10  import net.kwfgrid.gworkflowdl.structure.Factory;
11  import net.kwfgrid.gworkflowdl.structure.Place;
12  import net.kwfgrid.gworkflowdl.structure.Transition;
13  import net.kwfgrid.gworkflowdl.structure.Workflow;
14  
15  /***
16   * Created by IntelliJ IDEA.
17   * User: hans
18   * Date: 03.11.2005
19   * Time: 11:30:51
20   * To change this template use File | Settings | File Templates.
21   */
22  public class BackTest extends AbstractTestCase {
23      public BackTest(String testName) {
24              super(testName);
25          }
26  
27          /***
28           * @return the suite of tests being tested
29           */
30          public static Test suite() {
31              return new TestSuite(BackTest.class);
32          }
33  
34  
35          /***
36           * Rigourous Test :-).
37           */
38          public void testApp() {
39  
40              Place a1 = Factory.newPlace();
41              a1.setID("a1");
42              PlaceTest.addToken(a1);
43  
44              Place a2 = Factory.newPlace();
45              a2.setID("a2");
46              PlaceTest.addToken(a2);
47  
48              Place b = Factory.newPlace();
49              b.setID("b");
50  
51              Place c = Factory.newPlace();
52              c.setID("c");
53  
54              Place d = Factory.newPlace();
55              d.setID("d");
56  
57  
58              //PlaceTest.setCapacity(b, 1);
59  
60              Transition t1 = Factory.newTransition();
61              t1.setID("t1");
62              TransitionTest.addInPlace(t1, a1);
63              TransitionTest.addOutPlace(t1, b);
64  
65              Transition t2 = Factory.newTransition();
66              t2.setID("t2");
67              TransitionTest.addInPlace(t2, a2);
68              TransitionTest.addOutPlace(t2, b);
69  
70              Transition t = Factory.newTransition();
71              t.setID("t");
72              TransitionTest.addInPlace(t, b);
73              TransitionTest.addOutPlace(t, c);
74  
75              Transition q = Factory.newTransition();
76              q.setID("q");
77              TransitionTest.addInPlace(q, c);
78              TransitionTest.addOutPlace(q, d);
79  
80  
81  
82              Workflow wf = Factory.newWorkflow();
83              wf.addPlace(a1);
84              wf.addPlace(a2);
85              wf.addPlace(b);
86              wf.addPlace(c);
87              wf.addPlace(d);
88              wf.addTransition(t1);
89              wf.addTransition(t2);
90              wf.addTransition(t);
91              wf.addTransition(q);
92  
93              Analyzer aa = new Analyzer(wf, Net.FINITE_STATE_MACHINE);
94              aa.showAnalysis();
95  
96              WorkflowAnalyzer wfa = new WorkflowAnalyzer(wf);
97              //wfa.kmTree1.show();
98              wfa.showAnalysis();
99  
100 
101             /*
102             ContactFree.makeContactFree(wf);
103             System.out.println("after ContactFree.makeContactFree(workflow)");
104             System.out.println("-------------------------------------------");
105             wfa = new KarpMillerAnalyzer(wf);
106             //wfa.kmTree1.show();
107             wfa.showAnalysis();
108             */
109             Decision[] ds = aa.getDecisions();
110             for (int i = 0; i < ds.length; i++) {
111                 String s = ds[i].toString();
112                 Decision dd = Decision.fromString(wf,s);
113                 Assert.assertTrue(ds[i].equals(dd));
114             }
115 
116         }
117 
118 }