fr_b02 / petri / src / element / TransitionTest.java @ 4
Historique | Voir | Annoter | Télécharger (1,437 ko)
1 |
package element; |
---|---|
2 |
|
3 |
import static org.junit.Assert.assertEquals; |
4 |
import static org.junit.jupiter.api.Assertions.*; |
5 |
|
6 |
import org.junit.jupiter.api.Test; |
7 |
|
8 |
import arcElement.ArcEntering; |
9 |
import arcElement.ArcOutering; |
10 |
import element.Place.UndefinedToken; |
11 |
|
12 |
class TransitionTest { |
13 |
|
14 |
@Test
|
15 |
void testToString() throws UndefinedToken { |
16 |
Transition t = new Transition();
|
17 |
ArcOutering ao =new ArcOutering(new Place(3),5); |
18 |
t.getArcList().add(ao); |
19 |
assertEquals(" ["+ao.toString() +" // ] ",t.toString()); |
20 |
} |
21 |
|
22 |
@Test
|
23 |
void testTransition() {
|
24 |
Transition t = new Transition();
|
25 |
assertEquals(Transition.class, t.getClass()); |
26 |
} |
27 |
|
28 |
@Test
|
29 |
void testIsPullable() throws UndefinedToken { |
30 |
//case 1 is not pullable
|
31 |
Transition t = new Transition();
|
32 |
ArcOutering ao =new ArcOutering(new Place(3),5); |
33 |
t.getArcList().add(ao); |
34 |
assertFalse(t.isPullable()); |
35 |
//case 2 is pullable
|
36 |
Transition t1 = new Transition();
|
37 |
ArcEntering ae =new ArcEntering(new Place(3),5); |
38 |
t1.getArcList().add(ae); |
39 |
assertTrue(t1.isPullable()); |
40 |
} |
41 |
|
42 |
@Test
|
43 |
void testDoTransition() throws UndefinedToken { |
44 |
Transition t1 = new Transition();
|
45 |
Place p=new Place(3); |
46 |
ArcEntering ae =new ArcEntering(p,5); |
47 |
t1.getArcList().add(ae); |
48 |
t1.doTransition(); |
49 |
assertEquals(8,p.getToken());
|
50 |
} |
51 |
|
52 |
@Test
|
53 |
void testGetArcList() throws UndefinedToken { |
54 |
Transition t = new Transition();
|
55 |
ArcOutering ao =new ArcOutering(new Place(3),5); |
56 |
t.getArcList().add(ao); |
57 |
assertEquals(ao,t.getArcList().get(0));
|
58 |
|
59 |
} |
60 |
|
61 |
} |