From 7d4dbce0aeb5139e9098ce8fb6f5aebd59539340 Mon Sep 17 00:00:00 2001 From: Firas Bouzazi <firas.bouzazi@imt-atlantique.net> Date: Sun, 17 Nov 2024 14:16:15 +0100 Subject: [PATCH] first 3rd --- .../java/org/petriNet/ReseauPetriTest.java | 100 ++++++++++++++++-- 1 file changed, 94 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/petriNet/ReseauPetriTest.java b/src/test/java/org/petriNet/ReseauPetriTest.java index 1f4c30c..f5a8ac1 100644 --- a/src/test/java/org/petriNet/ReseauPetriTest.java +++ b/src/test/java/org/petriNet/ReseauPetriTest.java @@ -605,12 +605,100 @@ public class ReseauPetriTest { 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"); + } } -- GitLab