Skip to content
Snippets Groups Projects
Commit 7d4dbce0 authored by BOUZAZI Firas's avatar BOUZAZI Firas
Browse files

first 3rd

parent 3d9df66c
No related branches found
No related tags found
No related merge requests found
...@@ -605,12 +605,100 @@ public class ReseauPetriTest { ...@@ -605,12 +605,100 @@ public class ReseauPetriTest {
assertEquals(0, Destruction.getArcs().size(), "SA1"); assertEquals(0, Destruction.getArcs().size(), "SA1");
} }
@Test
@DisplayName("ARC ZERO")
public void testArczero() {
// Initialize the Petri network
ReseauPetri petriNetwork = new ReseauPetri();
// Create places
Place place1 = new Place(3, petriNetwork.generateId(1));
Place place2 = new Place(0, petriNetwork.generateId(1));
// Add places to the network
petriNetwork.ajouterPlace(place1);
petriNetwork.ajouterPlace(place2);
// Create a transition
Transition transition1 = new Transition("T1", petriNetwork.generateId(2));
// Add the transition to the network
petriNetwork.ajouterTransition(transition1);
// Create arcs and add them to the network
// Incoming arc from place2 to transition1 with weight 1
Arc_zero incomingArc_zero = new Arc_zero(transition1, place2, 1, petriNetwork.generateId(0));
petriNetwork.ajouterArc(incomingArc_zero);
transition1.ajouterArc_ENTRANT(incomingArc_zero);
// Outgoing arc from transition1 to place1 with weight 1
Arc_SORTANT outgoingArc = new Arc_SORTANT(transition1, place1, 1, petriNetwork.generateId(0));
petriNetwork.ajouterArc(outgoingArc);
transition1.ajouterArc_SORTANT(outgoingArc);
// Display the initial state of the Petri network
System.out.println("Initial State of Petri Network:");
petriNetwork.afficherReseau();
// Activate the transition
System.out.println("\nActivating transition T1...");
petriNetwork.tirer_transition(String.valueOf(transition1.getId()));
// Display the state of the Petri network after activation
System.out.println("\nState of Petri Network after Transition T1 Activation:");
petriNetwork.afficherReseau();
// Assertions to verify the correct state of the Petri network
assertEquals(4, place1.get_nombre_jetons(), "Tokens in Place 1 should be 4");
assertEquals(0, place2.get_nombre_jetons(), "Tokens in Place 2 should be 0");
}
@Test
@DisplayName("ARC Videur")
public void testArcvideur() {
// Initialize the Petri network
ReseauPetri petriNetwork = new ReseauPetri();
// Create places
Place place1 = new Place(2, petriNetwork.generateId(1));
Place place2 = new Place(4, petriNetwork.generateId(1));
// Add places to the network
petriNetwork.ajouterPlace(place1);
petriNetwork.ajouterPlace(place2);
// Create a transition
Transition transition1 = new Transition("T1", petriNetwork.generateId(2));
// Add the transition to the network
petriNetwork.ajouterTransition(transition1);
// Create arcs and add them to the network
// Incoming arc from place2 to transition1 with weight 1
Arc_videur incomingArc_videur = new Arc_videur(transition1, place2, 1, petriNetwork.generateId(0));
petriNetwork.ajouterArc(incomingArc_videur);
transition1.ajouterArc_ENTRANT(incomingArc_videur);
// Outgoing arc from transition1 to place1 with weight 1
Arc_SORTANT outgoingArc = new Arc_SORTANT(transition1, place1, 1, petriNetwork.generateId(0));
petriNetwork.ajouterArc(outgoingArc);
transition1.ajouterArc_SORTANT(outgoingArc);
// Display the initial state of the Petri network
System.out.println("Initial State of Petri Network:");
petriNetwork.afficherReseau();
// Activate the transition
System.out.println("\nActivating transition T1...");
petriNetwork.tirer_transition(String.valueOf(transition1.getId()));
// Display the state of the Petri network after activation
System.out.println("\nState of Petri Network after Transition T1 Activation:");
petriNetwork.afficherReseau();
// Assertions to verify the correct state of the Petri network
assertEquals(3, place1.get_nombre_jetons(), "Tokens in Place 1 should be 3");
assertEquals(0, place2.get_nombre_jetons(), "Tokens in Place 2 should be 0");
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment