Révision 4

Voir les différences:

petri/src/arc/ArcCleaner.java
1
package arc;
2

  
3
import element.Place;
4

  
5
public class ArcCleaner extends Arc{
6
	
7

  
8
	public ArcCleaner(Place place) {
9
		super(place);
10
	
11
	}
12
	
13
	public void doTransition() {
14
		if (this.isActive()==true) {
15
			this.getPlace().changeToken(-this.getPlace().getToken());
16
		}
17
	}
18
	
19
	public boolean isActive() {
20
		return (this.getPlace().getToken()>0);
21
	}
22
	
23
	public boolean isPullable() {
24
		return this.isActive();
25
	}
26
	public String toString() {
27
		return "ArcCleaner,"+this.getPlace();
28
	}
29
	public static void main(String[] args) {
30
		System.out.println("TEST METHODS ARCCLEANER");
31
		
32
		System.out.println(" => method isActive()");
33
		Place emptyPlace = new Place(0);
34
		ArcCleaner arcc1 = new ArcCleaner(emptyPlace);
35
		Place place3 = new Place(3);
36
		ArcCleaner arcc2 = new ArcCleaner(place3);
37
		System.out.println("false : "+arcc1.isActive());
38
		System.out.println("true : "+arcc2.isActive());
39

  
40
	
41
		System.out.println(" => method isPullable()");
42
		System.out.println(arcc1);
43
		System.out.println("false : "+arcc1.isPullable());
44
		System.out.println(arcc2);
45
		System.out.println("true : "+arcc2.isPullable());
46

  
47
		System.out.println(" => method doTranstion()");
48
		System.out.println("before : "+arcc2);
49
		arcc2.doTransition();
50
		System.out.println("after  : "+arcc2);
51

  
52
	}
53
	
54
	
55

  
56
}
petri/src/arc/ArcEntering.java
1
package arc;
2

  
3
import element.Place;
4

  
5
public class ArcEntering extends Arc{
6
	
7
	private int value;
8

  
9
	public ArcEntering(Place place, int value) {
10
		super(place);
11
		// TODO Auto-generated constructor stub
12
		this.value=value;
13
	}
14
	
15
	public void doTransition() {
16
		this.getPlace().changeToken(this.value);
17
	}
18
	
19
	public boolean isActive() {
20
		return true;
21
	}
22
	
23
	public boolean isPullable() {
24
		return true;
25
	}
26
	public String toString() {
27
		return "ArcEntering value:"+value+", "+this.getPlace();
28
	}
29
	public static void main(String[] args) {
30
		System.out.println("TEST METHODS ARCENTERING");
31
		
32
		System.out.println(" => method isActive()");
33
		Place emptyPlace = new Place(0);
34
		ArcEntering arce = new ArcEntering(emptyPlace, 3);
35
		System.out.println("true : "+arce.isActive());
36

  
37
	
38
		System.out.println(" => method isPullable()");
39
		Place place3 = new Place(3);
40
		ArcEntering arce2 = new ArcEntering(place3, 2);
41
		ArcEntering arce4 = new ArcEntering(place3, 4);
42
		System.out.println(arce2);
43
		System.out.println("true : "+arce2.isPullable());
44
		System.out.println(arce4);
45
		System.out.println("true : "+arce4.isPullable());
46
		
47
		System.out.println(" => method doTranstion()");
48
		System.out.println("before : "+arce2);
49
		arce2.doTransition();
50
		System.out.println("after  : "+arce2);
51
		System.out.println(" => method equals()");
52
		// the method equals is test here because arc is an abstract method
53
		System.out.println("true : "+arce2.equals(arce2));
54
		System.out.println("false : "+arce2.equals(arce4));
55
	}
56
	
57

  
58
}
petri/src/arc/ArcOutering.java
1
package arc;
2

  
3
import element.Place;
4

  
5
public class ArcOutering extends Arc{
6
	
7
	private int value;
8

  
9
	public ArcOutering(Place place, int value) {
10
		super(place);
11
		this.value=value;
12
	}
13
	public String toString() {
14
		return "ArcOutering value:"+value+", "+this.getPlace();
15
	}
16
	
17
	public void doTransition() {
18
		this.getPlace().changeToken(this.value*(-1));
19
	}
20
	
21
	public boolean isActive() {
22
		return true;
23
	}
24
	
25
	public boolean isPullable() {
26
		return (this.getPlace().getToken()>=value);
27
	}
28
	public static void main(String[] args) {
29
		System.out.println("TEST METHODS ARCOUTERING");
30
		
31
		System.out.println(" => method isActive()");
32
		Place emptyPlace = new Place(0);
33
		ArcOutering arco = new ArcOutering(emptyPlace, 3);
34
		System.out.println("true : "+arco.isActive());
35

  
36
	
37
		System.out.println(" => method isPullable()");
38
		Place place3 = new Place(3);
39
		ArcOutering arco2 = new ArcOutering(place3, 2);
40
		ArcOutering arco4 = new ArcOutering(place3, 4);
41
		System.out.println(arco2);
42
		System.out.println("true : "+arco2.isPullable());
43
		System.out.println(arco4);
44
		System.out.println("false : "+arco4.isPullable());
45
		
46
		System.out.println(" => method doTranstion()");
47
		System.out.println("before : "+arco2);
48
		arco2.doTransition();
49
		System.out.println("after  : "+arco2);
50
		System.out.println(" => method equals()");
51
		// the method equals is test here because arc is an abstract method
52
		System.out.println("true : "+arco2.equals(arco2));
53
		System.out.println("false : "+arco2.equals(arco4));
54
	}
55

  
56

  
57
}
petri/src/arc/Arc.java
1
package arc;
2

  
3
import element.Place;
4

  
5
public abstract class Arc implements ArcInterface {
6
	
7
	private Place place;
8
	
9
	public Arc(Place place) {
10
		this.place=place;
11
	}
12
	
13
	public Place getPlace() {
14
		return this.place;
15
	}
16
	public boolean equals(Object o) {
17
		if((o instanceof Arc) &&(System.identityHashCode(((Arc)o))==System.identityHashCode(this))) {
18
			return true;
19
		}
20
		else {
21
			return false;
22
		}
23
		
24
	}
25

  
26
}
petri/src/arc/ArcZero.java
1
package arc;
2

  
3
import element.Place;
4

  
5
public class ArcZero extends ArcOutering {
6
	
7
	public ArcZero(Place place, int value) {
8
		super(place, value);
9
		// TODO Auto-generated constructor stub
10
	}
11
	
12
	public void doTransition() {
13
	}
14
	public boolean isActive() {
15
		return (this.getPlace().getToken()==0);
16
	}
17
	public boolean isPullable() {
18
		return this.isActive();
19
	}
20
	public String toString() {
21
		return "ArcZero, "+this.getPlace(); 
22
	}
23
	public static void main(String[] args) {
24
		System.out.println("TEST METHODS ARCZERO");
25
		
26
		System.out.println(" => method isActive()");
27
		Place emptyPlace = new Place(0);
28
		ArcZero arcc1 = new ArcZero(emptyPlace,2);
29
		Place place3 = new Place(3);
30
		ArcZero arcc2 = new ArcZero(place3,2);
31
		System.out.println(arcc1);
32
		System.out.println("true : "+arcc1.isActive());
33
		System.out.println(arcc2);
34
		System.out.println("false : "+arcc2.isActive());
35

  
36
	
37
		System.out.println(" => method isPullable()");
38
		System.out.println(arcc1);
39
		System.out.println("false : "+arcc1.isPullable());
40
		System.out.println(arcc2);
41
		System.out.println("true : "+arcc2.isPullable());
42

  
43
		System.out.println(" => method doTranstion()");
44
		System.out.println("before : "+arcc2);
45
		arcc2.doTransition();
46
		System.out.println("after  : "+arcc2);
47

  
48
	}
49

  
50
}
petri/src/arc/ArcInterface.java
1
package arc;
2

  
3
public interface ArcInterface {
4
	
5
	public void doTransition();
6
	public boolean isPullable();
7
	public boolean isActive();
8

  
9
}
petri/src/element/Place.java
1 1
package element;
2 2

  
3

  
4

  
3 5
public class Place {
4 6
	
5 7
	private int token;
6 8
	
7
	public Place(int token) {
9
	@SuppressWarnings("serial")
10
	public class UndefinedToken extends Exception{
11
		public UndefinedToken() {
12
			super("the token cannot take a value <0");
13
		}
14
		
15
	}
16

  
17
	public Place(int token) throws UndefinedToken{
18
		if(token<0) {
19
			throw new UndefinedToken();
20
		}
8 21
		this.token=token;
9 22
	}
10 23
	
......
31 44
			return false;
32 45
		}
33 46
	}
34
	public static void main(String[] args) {
35
		System.out.println("TEST METHODS PLACE");
36
		
37
		System.out.println(" => method isEmpty()");
38
		Place emptyPlace = new Place(0);
39
		System.out.println("true : "+emptyPlace.isEmpty());
40
		Place notEmptyPlace = new Place(2);
41
		System.out.println("true : "+notEmptyPlace.isEmpty());
42
	
43
		System.out.println(" => method changeToken(int i)");
44
		Place place3 = new Place(3);
45
		place3.changeToken(5);
46
		System.out.println("3 + 5 = "+place3.getToken());
47
		place3.changeToken(-4);
48
		System.out.println("8 - 4 = "+place3.getToken());
49
		
50
		System.out.println(" => method equals()");
51
		Place place1 = new Place(0);
52
		Place place2 = new Place(0);
53
		System.out.println("true : "+place1.equals(place1));
54
		System.out.println("false : "+place1.equals(place2));
55
	}
56 47

  
57 48
}
petri/src/element/PlaceTest.java
1
package element;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import element.Place.UndefinedToken;
8

  
9
class PlaceTest {
10
	
11
	@Test
12
	void testPlace() {
13
		try {
14
			new Place(-3);
15
			fail("the place can't have a value <0 for the token");
16
		} catch (UndefinedToken e) {
17
		}
18

  
19
	}
20

  
21
	@Test
22
	void testGetToken() {
23
		
24
		try {
25
			Place p = new Place(3);
26
			assertEquals(3, p.getToken());
27
		} catch (UndefinedToken e) {
28

  
29
		}
30
	}
31

  
32
	@Test
33
	void testToString() {
34
		try {
35
			Place p = new Place(3);
36
			assertEquals("Place Token : 3", p.toString());
37
		} catch (UndefinedToken e) {
38
			
39
		}
40
		
41
	}
42

  
43
	@Test
44
	void testIsEmpty() throws UndefinedToken{
45
		Place p1 = new Place(3);
46
		Place p2 = new Place(0);
47
		assertTrue(p2.isEmpty());
48
		assertFalse(p1.isEmpty());
49
	}
50

  
51
	@Test
52
	void testChangeToken() throws UndefinedToken{
53
		Place p1 = new Place(3);
54
		p1.changeToken(2);
55
		assertEquals(5,p1.getToken());
56
	}
57

  
58
	@Test
59
	void testEqualsObject() throws UndefinedToken {
60
		Place p1 = new Place(3);
61
		Place p3 = new Place(3);
62
		
63
		assertTrue(p1.equals(p1));
64
		assertFalse(p1.equals(p3));
65
	}
66

  
67
}
0 68

  
petri/src/element/Transition.java
3 3
import java.util.ArrayList;
4 4
import java.util.List;
5 5

  
6
import arc.Arc;
7
import arc.ArcEntering;
8
import arc.ArcOutering;
6
import arcElement.Arc;
9 7

  
8

  
10 9
public class Transition {
11 10
	
12 11
	
......
46 45
	public List<Arc> getArcList(){
47 46
		return this.arcList;
48 47
	}
49
	public static void main(String[] args) {
50
		System.out.println("TEST METHODS TRANSITION");
51
		
52
		Transition t1=new Transition();
53
		t1.arcList.add(new ArcOutering(new Place(4), 2));
54
		t1.arcList.add(new ArcEntering(new Place(4), 1));
55 48

  
56
		Transition t2=new Transition();
57
		t2.arcList.add(new ArcOutering(new Place(2), 3));
58
		t2.arcList.add(new ArcEntering(new Place(2), 3));
59
	
60
		System.out.println(" => method isPullable()");
61 49

  
62
		System.out.println(t1);
63
		System.out.println("true : "+t1.isPullable());
64
		System.out.println(t2);
65
		System.out.println("false : "+t2.isPullable());
66
		
67
		System.out.println(" => method doTranstion()");
68
		System.out.println("before : "+t1);
69
		t1.doTransition();
70
		System.out.println("after  : "+t1);
71

  
72

  
73
	}
74 50
}
petri/src/element/TransitionTest.java
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
}
0 62

  
petri/src/arcElement/ArcCleaner.java
1
package arcElement;
2

  
3
import element.Place;
4

  
5
public class ArcCleaner extends Arc{
6
	
7

  
8
	public ArcCleaner(Place place) {
9
		super(place);
10
	
11
	}
12
	
13
	public void doTransition() {
14
		if (this.isActive()==true) {
15
			this.getPlace().changeToken(-this.getPlace().getToken());
16
		}
17
	}
18
	
19
	public boolean isActive() {
20
		return (this.getPlace().getToken()>0);
21
	}
22
	
23
	public boolean isPullable() {
24
		return this.isActive();
25
	}
26
	public String toString() {
27
		return "ArcCleaner, "+this.getPlace();
28
	}
29
	
30
	
31
	
32

  
33
}
0 34

  
petri/src/arcElement/ArcCleanerTest.java
1
package arcElement;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import element.Place;
8
import element.Place.UndefinedToken;
9

  
10
class ArcCleanerTest {
11

  
12
	@Test
13
	void testArcCleaner() throws UndefinedToken {
14
		ArcCleaner ae = new ArcCleaner(new Place(3));
15
		assertEquals(ArcCleaner.class, ae.getClass());
16
	}
17

  
18
	@Test
19
	void testDoTransition() throws UndefinedToken {
20
		Place p=new Place(3);
21
		ArcCleaner ae1 = new ArcCleaner(p);
22
		ae1.doTransition();
23
		assertEquals(0, p.getToken());
24
		
25
	}
26

  
27
	@Test
28
	void testIsActive() throws UndefinedToken {
29
		ArcCleaner ae1 = new ArcCleaner(new Place(3));
30
		assertTrue(ae1.isActive());
31
		ArcCleaner ae2 = new ArcCleaner(new Place(0));
32
		assertFalse(ae2.isActive());
33
	}
34

  
35
	@Test
36
	void testIsPullable()  throws UndefinedToken {
37
		ArcCleaner ae1 = new ArcCleaner(new Place(3));
38
		assertTrue(ae1.isPullable());
39
		ArcCleaner ae2 = new ArcCleaner(new Place(0));
40
		assertFalse(ae2.isPullable());
41
	}
42

  
43
	@Test
44
	void testToString() throws UndefinedToken {
45
		ArcCleaner ae1 = new ArcCleaner(new Place(3));
46
		Place p = new Place(3);
47
		assertEquals("ArcCleaner, "+p.toString(), ae1.toString());	}
48

  
49
}
0 50

  
petri/src/arcElement/ArcEntering.java
1
package arcElement;
2

  
3
import element.Place;
4

  
5
public class ArcEntering extends Arc{
6
	
7
	private int value;
8

  
9
	public ArcEntering(Place place, int value) {
10
		super(place);
11

  
12
		this.value=value;
13
	}
14
	
15
	public void doTransition() {
16
		this.getPlace().changeToken(this.value);
17
	}
18
	
19
	public boolean isActive() {
20
		return true;
21
	}
22
	
23
	public boolean isPullable() {
24
		return true;
25
	}
26
	public String toString() {
27
		return "ArcEntering value:"+value+", "+this.getPlace();
28
	}
29

  
30

  
31
	
32

  
33
}
0 34

  
petri/src/arcElement/ArcEnteringTest.java
1
package arcElement;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import element.Place;
8
import element.Place.UndefinedToken;
9

  
10
class ArcEnteringTest {
11

  
12
	@Test
13
	void testArcEntering() throws UndefinedToken {
14
		ArcEntering ae = new ArcEntering(new Place(3), 2);
15
		assertEquals(ArcEntering.class, ae.getClass());
16
	}
17

  
18
	@Test
19
	void testDoTransition() throws UndefinedToken {
20
		Place p= new Place(3);
21
		ArcEntering ae = new ArcEntering(p, 2);
22
		ae.doTransition();
23
		assertEquals(5, p.getToken());
24

  
25
	}
26

  
27
	@Test
28
	void testIsActive()  throws UndefinedToken {
29
		ArcEntering ae = new ArcEntering(new Place(3), 2);
30
		assertTrue(ae.isActive());
31
	}
32

  
33
	@Test
34
	void testIsPullable()  throws UndefinedToken {
35
		ArcEntering ae = new ArcEntering(new Place(3), 2);
36
		assertTrue(ae.isPullable());
37
	}
38

  
39
	@Test
40
	void testToString() throws UndefinedToken {
41
		ArcEntering ao = new ArcEntering(new Place(3), 2);
42
		Place p = new Place(3);
43
		assertEquals("ArcEntering value:2, "+p.toString(), ao.toString());
44
	}
45

  
46
}
0 47

  
petri/src/arcElement/ArcOutering.java
1
package arcElement;
2

  
3
import element.Place;
4

  
5
public class ArcOutering extends Arc{
6
	
7
	private int value;
8

  
9
	public ArcOutering(Place place, int value) {
10
		super(place);
11
		this.value=value;
12
	}
13
	public String toString() {
14
		return "ArcOutering value:"+value+", "+this.getPlace();
15
	}
16
	
17
	public void doTransition() {
18
		this.getPlace().changeToken(this.value*(-1));
19
	}
20
	
21
	public boolean isActive() {
22
		return true;
23
	}
24
	
25
	public boolean isPullable() {
26
		return (this.getPlace().getToken()>=value);
27
	}
28

  
29

  
30

  
31
}
0 32

  
petri/src/arcElement/ArcOuteringTest.java
1
package arcElement;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import element.Place;
8
import element.Place.UndefinedToken;
9

  
10
class ArcOuteringTest {
11

  
12
	@Test
13
	void testArcOutering() throws UndefinedToken {
14
		ArcOutering ao = new ArcOutering(new Place(3), 2);
15
		assertEquals(ArcOutering.class, ao.getClass());
16
	}
17

  
18
	@Test
19
	void testToString() throws UndefinedToken {
20
		ArcOutering ao = new ArcOutering(new Place(3), 2);
21
		Place p = new Place(3);
22
		assertEquals("ArcOutering value:2, " + p.toString(), ao.toString());
23

  
24
	}
25

  
26
	@Test
27
	void testDoTransition() throws UndefinedToken {
28
		Place p = new Place(3);
29
		ArcOutering ao = new ArcOutering(p, 2);
30
		ao.doTransition();
31
		assertEquals(1, p.getToken());
32
	}
33

  
34
	@Test
35
	void testIsActive() throws UndefinedToken {
36
		ArcOutering ao = new ArcOutering(new Place(3), 2);
37
		assertTrue(ao.isActive());
38
	}
39

  
40
	@Test
41
	void testIsPullable() throws UndefinedToken {
42
		ArcOutering ao = new ArcOutering(new Place(3), 2);
43
		assertTrue(ao.isPullable());
44
		ArcOutering ao1 = new ArcOutering(new Place(3), 4);
45
		assertFalse(ao1.isPullable());
46
	}
47

  
48
}
0 49

  
petri/src/arcElement/Arc.java
1
package arcElement;
2

  
3
import element.Place;
4
import junit.framework.TestCase;
5

  
6
public abstract class Arc extends TestCase implements ArcInterface  {
7
	
8
	private Place place;
9
	
10
	public Arc(Place place) {
11
		this.place=place;
12
	}
13
	
14
	public Place getPlace() {
15
		return this.place;
16
	}
17
	public boolean equals(Object o) {
18
		if((o instanceof Arc) &&(System.identityHashCode(((Arc)o))==System.identityHashCode(this))) {
19
			return true;
20
		}
21
		else {
22
			return false;
23
		}
24
		
25
	}
26

  
27
}
0 28

  
petri/src/arcElement/ArcTest.java
1
package arcElement;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import element.Place;
8
import element.Place.UndefinedToken;
9

  
10
class ArcTest {
11

  
12
	@Test
13
	void testEqualsObject() throws UndefinedToken {
14
		//test realized with ArcOutering because Arc is abstract
15
		ArcOutering ao1=new ArcOutering(new Place(3), 2);
16
		ArcOutering ao2=new ArcOutering(new Place(3), 2);
17
		assertTrue(ao1.equals(ao1));
18
		assertFalse(ao1.equals(ao2));
19
	}
20

  
21
}
0 22

  
petri/src/arcElement/ArcZero.java
1
package arcElement;
2

  
3

  
4

  
5
import element.Place;
6

  
7

  
8

  
9
public class ArcZero extends ArcOutering {
10
	
11
	public ArcZero(Place place, int value) {
12
		super(place, value);
13
	}
14
	
15
	public void doTransition() {
16
	}
17
	public boolean isActive() {
18
		return (this.getPlace().getToken()==0);
19
	}
20
	public boolean isPullable() {
21
		return this.isActive();
22
	}
23
	public String toString() {
24
		return "ArcZero, "+this.getPlace(); 
25
	}
26

  
27

  
28
}
0 29

  
petri/src/arcElement/ArcZeroTest.java
1
package arcElement;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import element.Place;
8
import element.Place.UndefinedToken;
9

  
10
class ArcZeroTest {
11

  
12
	@Test
13
	void testToString() throws UndefinedToken {
14
		ArcZero ao = new ArcZero (new Place(3), 2);
15
		Place p = new Place(3);
16
		assertEquals("ArcZero, "+p.toString(), ao.toString());
17
	}
18

  
19
	@Test
20
	void testDoTransition() {
21
		
22
	}
23

  
24
	@Test
25
	void testIsActive() throws UndefinedToken {
26
		ArcZero ao1 = new ArcZero (new Place(3), 2);
27
		assertFalse(ao1.isActive());
28
		ArcZero ao2 = new ArcZero (new Place(0), 2);
29
		assertTrue(ao2.isActive());
30
	}
31

  
32
	@Test
33
	void testIsPullable() throws UndefinedToken {
34
		ArcZero ao1 = new ArcZero (new Place(3), 2);
35
		assertFalse(ao1.isPullable());
36
		ArcZero ao2 = new ArcZero (new Place(0), 2);
37
		assertTrue(ao2.isPullable());
38
	}
39

  
40
	@Test
41
	void testArcZero() throws UndefinedToken {
42
		ArcZero ao = new ArcZero(new Place(3), 2);
43
		assertEquals(ArcZero.class, ao.getClass());
44
	}
45

  
46
}
0 47

  
petri/src/arcElement/ArcInterface.java
1
package arcElement;
2

  
3
public interface ArcInterface {
4
	
5
	public void doTransition();
6
	public boolean isPullable();
7
	public boolean isActive();
8

  
9
}
0 10

  
petri/src/main/Network.java
4 4
import java.util.ArrayList;
5 5
import java.util.List;
6 6

  
7
import arc.Arc;
8
import arc.ArcCleaner;
9
import arc.ArcEntering;
10
import arc.ArcOutering;
11
import arc.ArcZero;
7
import arcElement.Arc;
8
import arcElement.ArcCleaner;
9
import arcElement.ArcEntering;
10
import arcElement.ArcOutering;
11
import arcElement.ArcZero;
12 12
import element.Place;
13
import element.Place.UndefinedToken;
13 14
import element.Transition;
14 15

  
15 16
public class Network {
......
31 32
		Transition transition = new Transition();
32 33
		listTransition.add(transition);
33 34
	}
34
	public void addPlace(int value) {
35
	public void addPlace(int value) throws UndefinedToken {
35 36
		Place place = new Place(value);
36 37
		placeList.add(place);
37 38
	}
......
94 95
		res=res+"]";
95 96
		return res;
96 97
	}
97
	public static void main(String[] args) {
98
	public static void main(String[] args) throws UndefinedToken {
98 99
		
99 100
		Network n0=new Network();
100 101
		n0.addPlace(5);
......
178 179

  
179 180
	}
180 181

  
182

  
183
	public List<Place> getPlaceList() {
184
		return placeList;
185
	}
186

  
187

  
188
	public List<Transition> getListTransition() {
189
		return listTransition;
190
	}
191

  
181 192
}
petri/src/main/NetworkTest.java
1
package main;
2

  
3
import static org.junit.jupiter.api.Assertions.*;
4

  
5
import org.junit.jupiter.api.Test;
6

  
7
import arcElement.ArcOutering;
8
import element.Place;
9
import element.Place.UndefinedToken;
10
import element.Transition;
11

  
12
class NetworkTest {
13

  
14
	@Test
15
	void testNetwork() {
16
		Network n= new Network();
17
		assertEquals(Network.class, n.getClass());
18
	}
19

  
20
	@Test
21
	void testAddTransition() throws UndefinedToken {
22
		Network n= new Network();
23
		n.addTransition();
24
		assertEquals(1,n.getListTransition().size());
25
		assertEquals(Transition.class, n.getListTransition().get(0).getClass());
26
	}
27

  
28
	@Test
29
	void testAddPlace() throws UndefinedToken {
30
		Network n= new Network();
31
		n.addPlace(3);
32
		assertEquals(1,n.getPlaceList().size());
33
		assertEquals(Place.class, n.getPlaceList().get(0).getClass());	}
34

  
35
	@Test
36
	void testAddArc() throws UndefinedToken {
37
		Network n= new Network();
38
		ArcOutering ao =new ArcOutering(new Place(3), 4);
39
		n.addTransition();
40
		n.addPlace(3);
41
		n.addArc(n.getListTransition().get(0), n.getPlaceList().get(0), 4, Network.ArcOutering);
42
		assertEquals(n.getListTransition().get(0).getArcList().get(0).toString(), ao.toString());
43
	}
44

  
45
	@Test
46
	void testDeleteArc() {
47
		
48
	}
49

  
50
	@Test
51
	void testDeletePlace() {
52
		
53
	}
54

  
55
	@Test
56
	void testDeleteTransition() {
57
		
58
	}
59

  
60
	@Test
61
	void testFire() {
62
		
63
	}
64

  
65
	@Test
66
	void testToString() {
67
		
68
	}
69

  
70

  
71
}
0 72

  
petri/.classpath
2 2
<classpath>
3 3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4 4
	<classpathentry kind="src" path="src"/>
5
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
5 6
	<classpathentry kind="output" path="bin"/>
6 7
</classpath>

Formats disponibles : Unified diff