From a8cd335fa6f417e1a84c507057f0c9ded7808695 Mon Sep 17 00:00:00 2001 From: famille Thevenot Date: Wed, 18 Sep 2024 18:36:04 +0200 Subject: [PATCH 1/3] commantaires dans ajouter de Commande --- src/métiers/Commande.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/métiers/Commande.java b/src/métiers/Commande.java index 40592b1..ef5631f 100644 --- a/src/métiers/Commande.java +++ b/src/métiers/Commande.java @@ -36,6 +36,9 @@ private final HashMap lesLignes = new HashMap<>(); * @return true si l'ajout est bon */ public boolean ajouter(Instrument unInstrument, int qte){ + //il faut gérer l'ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne + //il faut empêcher l'ajout d'une ligne avec une quantité à 0 + //bien s'assurer que le stock est suffisant boolean ajoutOK; int qteDisponible = unInstrument.getQteStock(); if (qteDisponible Date: Thu, 19 Sep 2024 08:29:56 +0200 Subject: [PATCH 2/3] ajout CommandeTest --- test/métiers/CommandeTest.java | 86 ++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 test/métiers/CommandeTest.java diff --git a/test/métiers/CommandeTest.java b/test/métiers/CommandeTest.java new file mode 100644 index 0000000..eb5d7fc --- /dev/null +++ b/test/métiers/CommandeTest.java @@ -0,0 +1,86 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template + */ +package métiers; + +import java.util.HashMap; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author famille Thevenot + */ +public class CommandeTest { + + public CommandeTest() { + } + + @Before + public void setUp() { + } + + /** + * Test of ajouter method, of class Commande. + */ + @Test + public void testAjouter() { + Instrument instr1=new Instrument(1,"Piano",10, 8300f); + Instrument instr2=new Instrument(2,"Violon",9, 105f); + Commande laCommande = new Commande(1,1,"12/09/2024"); + System.out.println("ajouter"); + boolean ajoutRes= laCommande.ajouter(instr1, 2); + boolean ajoutAttendu = true; + System.out.println("cas0 : cas normal, ajout une ligne de commande"); + assertEquals("Test0 ajout 2 instr1",ajoutAttendu,ajoutRes); + int stockRes=instr1.getQteStock(); + int stockAttendu=8; + assertEquals("Test0 stock",stockAttendu,stockRes); + int qteRes=laCommande.getLesLignes().get(instr1); + int qteAttendu=2; + assertEquals("Test0 quantite",qteRes, qteAttendu); + + System.out.println("Cas1 : ajout autre ligne de commande"); + laCommande.ajouter(instr2, 6); + int tailleR=laCommande.getLesLignes().size(); + int tailleAttendue=2; + assertEquals("Test1 taille",tailleAttendue,tailleR); + + System.out.println("Cas2 : màj quantité commandée d'une ligne existante"); + laCommande.ajouter(instr2, 5); + stockRes=instr2.getQteStock(); + stockAttendu=4; + assertEquals("test2 stock",stockAttendu,stockRes ); + + /*qteRes=laCommande.getLesLignes().get(instr2); + qteAttendu=5; + assertEquals("Test2 quantite", qteAttendu,qteRes);*/ + + /*INES*/ + System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock"); + /*MAISSANE*/ + System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0"); + /*MORGANN*/ + System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante"); + /*INES*/ + System.out.println("Cas6 : màj d'une ligne existante avec qté>stock"); + } + + /** + * Test of supprimer method, of class Commande. + + @Test + public void testSupprimer() { + System.out.println("supprimer"); + Instrument unInstrument = null; + Commande instance = null; + boolean expResult = false; + boolean result = instance.supprimer(unInstrument); + assertEquals("test supprimer",expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + }*/ + +} From 647211866633b084980121a94a2ac24a86d0bd2c Mon Sep 17 00:00:00 2001 From: famille Thevenot Date: Tue, 24 Sep 2024 11:54:50 +0200 Subject: [PATCH 3/3] ajout gestion entreprise --- nbproject/project.properties | 195 +++++++++++++++-------------- src/Test.java | 6 +- src/métiers/Entreprise.java | 14 ++- test/métiers/CommandeNGTest.java | 52 -------- test/métiers/EntrepriseNGTest.java | 82 ------------ test/métiers/InstrumentNGTest.java | 110 ---------------- 6 files changed, 113 insertions(+), 346 deletions(-) delete mode 100644 test/métiers/CommandeNGTest.java delete mode 100644 test/métiers/EntrepriseNGTest.java delete mode 100644 test/métiers/InstrumentNGTest.java diff --git a/nbproject/project.properties b/nbproject/project.properties index 6e3d27a..f35ff40 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,96 +1,99 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/MusicAndCo.jar -dist.javadoc.dir=${dist.dir}/javadoc -dist.jlink.dir=${dist.dir}/jlink -dist.jlink.output=${dist.jlink.dir}/MusicAndCo -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs=\ --enable-preview --enable-preview -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=21 -javac.target=21 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.testng.classpath} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -# The jlink additional root modules to resolve -jlink.additionalmodules= -# The jlink additional command line parameters -jlink.additionalparam= -jlink.launcher=true -jlink.launcher.name=MusicAndCo -main.class=Test -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs=\ --enable-preview -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/MusicAndCo.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/MusicAndCo +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs=\ --enable-preview --enable-preview +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=21 +javac.target=21 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.testng.classpath}:\ + ${libs.junit_5.classpath}:\ + ${libs.junit_4.classpath}:\ + ${libs.hamcrest.classpath} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=MusicAndCo +main.class=Test +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs=\ --enable-preview +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/src/Test.java b/src/Test.java index 6711609..0bc84af 100644 --- a/src/Test.java +++ b/src/Test.java @@ -19,14 +19,10 @@ public class Test { */ public static void main(String[] args) { Entreprise lEntreprise=new Entreprise("MusicAndCo"); - Instrument instr1=new Instrument(1,"Piano",10, 8300f); - Instrument instr2=new Instrument(2,"Violon",9, 105f); - Instrument instr3=new Instrument(3,"Guitare",8, 575f); Commande laCommande = new Commande(1,1,"12/09/2024"); lEntreprise.ajouterCommande(laCommande); - //Ajouter à la commande une ligne de 2 instr1 - laCommande.ajouter(instr1, 2); + //ajouter 3 piano droit et 2 violon alto dans la commande } } diff --git a/src/métiers/Entreprise.java b/src/métiers/Entreprise.java index 06d78a2..1802835 100644 --- a/src/métiers/Entreprise.java +++ b/src/métiers/Entreprise.java @@ -5,6 +5,8 @@ package métiers; import java.util.ArrayList; +import métiers.Commande; +import métiers.Instrument; /** * @@ -13,10 +15,17 @@ import java.util.ArrayList; public class Entreprise { private String raisonSociale; private ArrayList lesCommandes = new ArrayList<>(); - private ArrayList lesInstruments = new ArrayList<>(); public Entreprise(String raisonSociale) { this.raisonSociale = raisonSociale; + + ArrayList lesInstruments = new ArrayList<>(); + Instrument instr1=new Instrument(23,"Piano droit",3, 8300f); + Instrument instr2=new Instrument(54,"Violon Alto",5, 105f); + Instrument instr3=new Instrument(67,"Guitare Classique",8, 575f); + lesInstruments.add(instr3); + lesInstruments.add(instr2); + lesInstruments.add(instr1); } public String getRaisonSociale() { @@ -38,6 +47,9 @@ public class Entreprise { } public void supprimerCommande(Commande uneCommande){ + //parcours pour supprimer les instruments de la commande + + //suppression de la commande lesCommandes.remove(uneCommande); } diff --git a/test/métiers/CommandeNGTest.java b/test/métiers/CommandeNGTest.java deleted file mode 100644 index f198844..0000000 --- a/test/métiers/CommandeNGTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/EmptyTestNGTest.java to edit this template - */ -package métiers; - -import java.util.HashMap; -import static org.testng.Assert.*; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author ines.benalia - */ -public class CommandeNGTest { - - public CommandeNGTest() { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @Test - public void testAjouter() { - System.out.println("ajouter"); - Instrument instr2=new Instrument(2,"Violon",9, 105f); - // Instrument instr3=new Instrument(3,"Guitare",8, 575f); - Commande laCommande = new Commande(1,1,"12/09/2024"); - boolean expResult = true; - boolean result = laCommande.ajouter(instr2, 5); - - assertEquals(result, expResult); - - } - - - @Test - public void testSupprimer() { - System.out.println("supprimer"); - Instrument unInstrument = null; - Commande instance = null; - boolean expResult = false; - boolean result = instance.supprimer(unInstrument); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - - -} diff --git a/test/métiers/EntrepriseNGTest.java b/test/métiers/EntrepriseNGTest.java deleted file mode 100644 index 6dfb185..0000000 --- a/test/métiers/EntrepriseNGTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/EmptyTestNGTest.java to edit this template - */ -package métiers; - -import static org.testng.Assert.*; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author ines.benalia - */ -public class EntrepriseNGTest { - - public EntrepriseNGTest() { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @Test - public void testGetRaisonSociale() { - System.out.println("getRaisonSociale"); - Entreprise instance = null; - String expResult = ""; - String result = instance.getRaisonSociale(); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - @Test - public void testSetRaisonSociale() { - System.out.println("setRaisonSociale"); - String raisonSociale = ""; - Entreprise instance = null; - instance.setRaisonSociale(raisonSociale); - fail("The test case is a prototype."); - } - - @Test - public void testToString() { - System.out.println("toString"); - Entreprise instance = null; - String expResult = ""; - String result = instance.toString(); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - @Test - public void testAjouterCommande() { - System.out.println("ajouterCommande"); - Commande uneCommande = null; - Entreprise instance = null; - instance.ajouterCommande(uneCommande); - fail("The test case is a prototype."); - } - - @Test - public void testSupprimerCommande() { - System.out.println("supprimerCommande"); - Commande uneCommande = null; - Entreprise instance = null; - instance.supprimerCommande(uneCommande); - fail("The test case is a prototype."); - } - - @Test - public void testRechercherCommande() { - System.out.println("rechercherCommande"); - int noCom = 0; - Entreprise instance = null; - Commande expResult = null; - Commande result = instance.rechercherCommande(noCom); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - -} diff --git a/test/métiers/InstrumentNGTest.java b/test/métiers/InstrumentNGTest.java deleted file mode 100644 index f818899..0000000 --- a/test/métiers/InstrumentNGTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/EmptyTestNGTest.java to edit this template - */ -package métiers; - -import static org.testng.Assert.*; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author ines.benalia - */ -public class InstrumentNGTest { - - public InstrumentNGTest() { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @Test - public void testToString() { - System.out.println("toString"); - Instrument instance = null; - String expResult = ""; - String result = instance.toString(); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - @Test - public void testSetRef() { - System.out.println("setRef"); - int ref = 0; - Instrument instance = null; - instance.setRef(ref); - fail("The test case is a prototype."); - } - - @Test - public void testSetDesignation() { - System.out.println("setDesignation"); - String designation = ""; - Instrument instance = null; - instance.setDesignation(designation); - fail("The test case is a prototype."); - } - - @Test - public void testSetQteStock() { - System.out.println("setQteStock"); - int qteStock = 0; - Instrument instance = null; - instance.setQteStock(qteStock); - fail("The test case is a prototype."); - } - - @Test - public void testSetPrix() { - System.out.println("setPrix"); - float prix = 0.0F; - Instrument instance = null; - instance.setPrix(prix); - fail("The test case is a prototype."); - } - - @Test - public void testGetRef() { - System.out.println("getRef"); - Instrument instance = null; - int expResult = 0; - int result = instance.getRef(); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - @Test - public void testGetDesignation() { - System.out.println("getDesignation"); - Instrument instance = null; - String expResult = ""; - String result = instance.getDesignation(); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - @Test - public void testGetQteStock() { - System.out.println("getQteStock"); - Instrument instance = null; - int expResult = 0; - int result = instance.getQteStock(); - assertEquals(result, expResult); - fail("The test case is a prototype."); - } - - @Test - public void testGetPrix() { - System.out.println("getPrix"); - Instrument instance = null; - float expResult = 0.0F; - float result = instance.getPrix(); - assertEquals(result, expResult, 0.0); - fail("The test case is a prototype."); - } - -}