1   /*
2    * $Id: EdgeTest.java 1227 2008-12-03 10:33:55Z andreas.hoheisel@first.fraunhofer.de $
3    *
4    * Copyright (c) 2005, The K-Wf Grid Consortium
5    * Fraunhofer Institute for Computer Architecture and Software Technology
6    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
7    */
8   package net.kwfgrid.gworkflowdl;
9   
10  
11  import junit.framework.Assert;
12  import junit.framework.Test;
13  import junit.framework.TestSuite;
14  import net.kwfgrid.gworkflowdl.structure.Edge;
15  import net.kwfgrid.gworkflowdl.structure.Factory;
16  import net.kwfgrid.gworkflowdl.structure.Place;
17  
18  /***
19   * Edge test.
20   */
21  public final class EdgeTest extends AbstractTestCase {
22      /***
23       * Create the test case.
24       *
25       * @param testName name of the test case
26       */
27      public EdgeTest(String testName) {
28          super(testName);
29      }
30  
31      /***
32       * @return the suite of tests being tested
33       */
34      public static Test suite() {
35          return new TestSuite(EdgeTest.class);
36      }
37  
38      /***
39       * generation of Edge test createDataToken
40       *
41       * @param expression  expression of Edge
42       * @param id          Place ID
43       * @param tokenNumber number of tokens the Place has
44       * @return createDataToken Edge
45       */
46      public static Edge example(String expression, String id, int tokenNumber) {
47          Edge e = Factory.newEdge();
48          e.setPlace(PlaceTest.exampleWithDataTokens(id, tokenNumber));
49          e.setExpression(expression);
50          return e;
51      }
52  
53      public static Edge example(String expression, Place place) {
54          Edge edge = Factory.newEdge();
55          edge.setExpression(expression);
56          edge.setPlace(place);
57          return edge;
58      }
59  
60      /***
61       * Rigourous Test :-).
62       */
63      public void testApp() {
64          Edge edge = Factory.newEdge();
65          Assert.assertEquals(edge.getPlace(), Edge.DEFAULT_PLACE);
66          Assert.assertEquals(edge.getExpression(), Edge.DEFAULT_EXPRESSION);
67  
68          edge.setPlace(PlaceTest.exampleWithDataTokens("anton", 2));
69          Assert.assertEquals("anton", edge.getPlace().getID());
70  
71          edge.setExpression("berta");
72          Assert.assertEquals("berta", edge.getExpression());
73      }
74  }