Compare commits

...

14 Commits

Author SHA1 Message Date
famille Thevenot
09a7279d52 Merge dt
# Conflicts:
#	src/Test.java
#	src/métiers/Commande.java
#	test/métiers/CommandeTest.java
2024-09-25 22:03:48 +02:00
famille Thevenot
c000fb78ee Merge origin/master
# Conflicts:
#	nbproject/project.properties
#	src/métiers/Commande.java
2024-09-25 18:22:52 +02:00
famille Thevenot
b109399da5 Merge origin/master
# Conflicts:
#	nbproject/project.properties
#	src/métiers/Commande.java
2024-09-25 18:18:10 +02:00
famille Thevenot
08e7254265 Merge origin/master
# Conflicts:
#	nbproject/project.properties
#	src/métiers/Commande.java
2024-09-25 18:15:29 +02:00
famille Thevenot
6472118666 ajout gestion entreprise 2024-09-24 11:54:50 +02:00
sio
6bcc94486f mise à jour Morgann 2024-09-19 11:55:10 +02:00
maissane.elmjidi
9e6a9cc867 ajout page maissane 2024-09-19 11:42:33 +02:00
sio
8dc9d9d385 mise à jour pour Commande et testCommande avec Ines et Ilona 2024-09-19 11:38:57 +02:00
e4956996d6 Merge pull request 'test cas 5' (#4) from morgann into master
Reviewed-on: #4
2024-09-19 10:39:59 +02:00
morgann.david
6ed7fb09f2 test cas 5 2024-09-19 10:26:18 +02:00
famille Thevenot
8b82fb5acd ajout CommandeTest 2024-09-19 08:29:56 +02:00
famille Thevenot
a8cd335fa6 commantaires dans ajouter de Commande 2024-09-18 18:36:04 +02:00
famille Thevenot
7136c719cc modif supprimer dans commande 2024-09-18 17:38:05 +02:00
ines.benalia
926b12ec55 test de la classe commande 2024-09-12 11:54:27 +02:00
6 changed files with 232 additions and 144 deletions

View File

@ -1,98 +1,99 @@
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processor.options= annotation.processing.processor.options=
annotation.processing.processors.list= annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
build.dir=build build.dir=build
build.generated.dir=${build.dir}/generated build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here: # Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport: # Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket #debug.transport=dt_socket
debug.classpath=\ debug.classpath=\
${run.classpath} ${run.classpath}
debug.modulepath=\ debug.modulepath=\
${run.modulepath} ${run.modulepath}
debug.test.classpath=\ debug.test.classpath=\
${run.test.classpath} ${run.test.classpath}
debug.test.modulepath=\ debug.test.modulepath=\
${run.test.modulepath} ${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar # Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes= dist.archive.excludes=
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
dist.dir=dist dist.dir=dist
dist.jar=${dist.dir}/MusicAndCo.jar dist.jar=${dist.dir}/MusicAndCo.jar
dist.javadoc.dir=${dist.dir}/javadoc dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/MusicAndCo dist.jlink.output=${dist.jlink.dir}/MusicAndCo
excludes= excludes=
includes=** includes=**
jar.compress=false jar.compress=false
javac.classpath= javac.classpath=
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs=\ --enable-preview --enable-preview javac.compilerargs=\ --enable-preview --enable-preview
javac.deprecation=false javac.deprecation=false
javac.external.vm=true javac.external.vm=true
javac.modulepath= javac.modulepath=
javac.processormodulepath= javac.processormodulepath=
javac.processorpath=\ javac.processorpath=\
${javac.classpath} ${javac.classpath}
javac.source=21 javac.source=21
javac.target=21 javac.target=21
javac.test.classpath=\ javac.test.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
${build.classes.dir}:\ ${build.classes.dir}:\
${libs.junit_5.classpath}:\ ${libs.testng.classpath}:\
${libs.junit_4.classpath}:\ ${libs.junit_5.classpath}:\
${libs.hamcrest.classpath} ${libs.junit_4.classpath}:\
javac.test.modulepath=\ ${libs.hamcrest.classpath}
${javac.modulepath} javac.test.modulepath=\
javac.test.processorpath=\ ${javac.modulepath}
${javac.test.classpath} javac.test.processorpath=\
javadoc.additionalparam= ${javac.test.classpath}
javadoc.author=false javadoc.additionalparam=
javadoc.encoding=${source.encoding} javadoc.author=false
javadoc.html5=false javadoc.encoding=${source.encoding}
javadoc.noindex=false javadoc.html5=false
javadoc.nonavbar=false javadoc.noindex=false
javadoc.notree=false javadoc.nonavbar=false
javadoc.private=false javadoc.notree=false
javadoc.splitindex=true javadoc.private=false
javadoc.use=true javadoc.splitindex=true
javadoc.version=false javadoc.use=true
javadoc.windowtitle= javadoc.version=false
# The jlink additional root modules to resolve javadoc.windowtitle=
jlink.additionalmodules= # The jlink additional root modules to resolve
# The jlink additional command line parameters jlink.additionalmodules=
jlink.additionalparam= # The jlink additional command line parameters
jlink.launcher=true jlink.additionalparam=
jlink.launcher.name=MusicAndCo jlink.launcher=true
main.class=Test jlink.launcher.name=MusicAndCo
manifest.file=manifest.mf main.class=Test
meta.inf.dir=${src.dir}/META-INF manifest.file=manifest.mf
mkdist.disabled=false meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform mkdist.disabled=false
run.classpath=\ platform.active=default_platform
${javac.classpath}:\ run.classpath=\
${build.classes.dir} ${javac.classpath}:\
# Space-separated list of JVM arguments used when running the project. ${build.classes.dir}
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # Space-separated list of JVM arguments used when running the project.
# To set system properties for unit tests define test-sys-prop.name=value: # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
run.jvmargs=\ --enable-preview # To set system properties for unit tests define test-sys-prop.name=value:
run.modulepath=\ run.jvmargs=\ --enable-preview
${javac.modulepath} run.modulepath=\
run.test.classpath=\ ${javac.modulepath}
${javac.test.classpath}:\ run.test.classpath=\
${build.test.classes.dir} ${javac.test.classpath}:\
run.test.modulepath=\ ${build.test.classes.dir}
${javac.test.modulepath} run.test.modulepath=\
source.encoding=UTF-8 ${javac.test.modulepath}
src.dir=src source.encoding=UTF-8
test.src.dir=test src.dir=src
test.src.dir=test

View File

@ -19,16 +19,20 @@ public class Test {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Entreprise lEntreprise=new Entreprise("MusicAndCo"); Entreprise lEntreprise=new Entreprise("MusicAndCo");
Instrument instr1=new Instrument(1,"Piano",10, 8300f); Commande laCommande1 = new Commande(1,1,"12/09/2024");
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);
//Test Cas0-Ajouter à la commande une ligne de 2 instr1 //ajouter des instruments de l'entreprise à la commande
System.out.println("Résultat de l'ajout de 2 instr1 à la commande :" + laCommande.ajouter(instr1, 2) );
System.out.println("Nouveau stock de instr1 : "+instr1.getQteStock()); //affecter la commande à l'entreprise si la comamnde est possible
System.out.println("Quantité de la ligne de commande de instr1 :"+laCommande.getLesLignes().get(instr1)); lEntreprise.ajouterCommande(laCommande1);
//créer une autre commande
//rechercher et afficher une commande
//supprimer une des 2 commande
} }
} }

View File

@ -40,36 +40,36 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
//il faut empêcher l'ajout d'une ligne avec une quantité à 0 //il faut empêcher l'ajout d'une ligne avec une quantité à 0
//bien s'assurer que le stock est suffisant //bien s'assurer que le stock est suffisant
boolean ajoutOK=false; boolean ajoutOK=false;
//ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne if(qte!=0){
if (lesLignes.containsKey(unInstrument))//l'instrument existe //ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne
{ if (lesLignes.containsKey(unInstrument))//l'instrument existe
//récupération de la quantité en stock {
int oldQte=unInstrument.getQteStock(); //récupération de la quantité en stock
//réaffectation dans le stock de la quantité commandée int oldQte=unInstrument.getQteStock();
int qteStock=oldQte+ this.getLesLignes().get(unInstrument); //réaffectation dans le stock de la quantité commandée
unInstrument.setQteStock(qteStock); int qteStock=oldQte+ this.getLesLignes().get(unInstrument);
//suppression ligne commande unInstrument.setQteStock(qteStock);
lesLignes.remove(unInstrument); //suppression ligne commande
//nouvel ajout lesLignes.remove(unInstrument);
this.ajouter(unInstrument,qte); //nouvel ajout
this.ajouter(unInstrument,qte);
}
else //nouvel instrument }
{ else //nouvel instrument
//on s'assure qu'il y a assez de stock pour la commande {
//on s'assure qu'il y a assez de stock pour la commande
int qteDisponible = unInstrument.getQteStock();
if (qteDisponible<qte){ int qteDisponible = unInstrument.getQteStock();
ajoutOK = false; if (qteDisponible<qte){
}else { ajoutOK = false;
ajoutOK = true; }else {
lesLignes.put(unInstrument,qte); ajoutOK = true;
//màj qté stock pour déduire la qté commandée lesLignes.put(unInstrument,qte);
unInstrument.setQteStock(qteDisponible-qte); //màj qté stock pour déduire la qté commandée
} unInstrument.setQteStock(qteDisponible-qte);
} }
}
}
return ajoutOK; return ajoutOK;
} }
/** /**

View File

@ -5,6 +5,8 @@
package métiers; package métiers;
import java.util.ArrayList; import java.util.ArrayList;
import métiers.Commande;
import métiers.Instrument;
/** /**
* *
@ -14,9 +16,16 @@ public class Entreprise {
private String raisonSociale; private String raisonSociale;
private ArrayList<Commande> lesCommandes = new ArrayList<>(); private ArrayList<Commande> lesCommandes = new ArrayList<>();
private ArrayList<Instrument> lesInstruments = new ArrayList<>(); private ArrayList<Instrument> lesInstruments = new ArrayList<>();
public Entreprise(String raisonSociale) { public Entreprise(String raisonSociale) {
this.raisonSociale = raisonSociale; this.raisonSociale = raisonSociale;
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() { public String getRaisonSociale() {
@ -38,6 +47,9 @@ public class Entreprise {
} }
public void supprimerCommande(Commande uneCommande){ public void supprimerCommande(Commande uneCommande){
//parcours pour supprimer les instruments de la commande
//suppression de la commande
lesCommandes.remove(uneCommande); lesCommandes.remove(uneCommande);
} }

View File

@ -5,9 +5,7 @@
package métiers; package métiers;
import java.util.HashMap; import java.util.HashMap;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/** /**
* *
@ -18,17 +16,18 @@ public class CommandeTest {
public CommandeTest() { public CommandeTest() {
} }
@Before
public void setUp() { public void setUp() {
} }
/** /**
* Test of ajouter method, of class Commande. * Test of ajouter method, of class Commande.
*/ */
@Test
public void testAjouter() { public void testAjouter() {
Instrument instr1=new Instrument(1,"Piano",10, 8300f); Instrument instr1=new Instrument(1,"Piano",10, 8300f);
Instrument instr2=new Instrument(2,"Violon",9, 105f); Instrument instr2=new Instrument(2,"Violon",9, 105f);
Instrument instr3=new Instrument(3,"piano",8, 105f);
Commande laCommande = new Commande(1,1,"12/09/2024"); Commande laCommande = new Commande(1,1,"12/09/2024");
System.out.println("ajouter"); System.out.println("ajouter");
//cas 0 //cas 0
@ -63,12 +62,57 @@ public class CommandeTest {
/*INES*/ /*INES*/
System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock"); System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock");
boolean test= laCommande.ajouter(instr3, 12);
stockRes=instr3.getQteStock();
stockAttendu=8;
boolean testResultExpected=false;
assertEquals("test3 stock",stockAttendu,stockRes );
assertEquals("La méthode ajouter retourne false",testResultExpected,test );
System.out.println("Nombre de ligne dans le dictionnaire: "+laCommande.getLesLignes().size());
System.out.println("Résultat de la méthode ajouter: " + test);
/*MAISSANE*/ /*MAISSANE*/
System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0"); System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0");
System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0");
boolean AjouterObtenu=laCommande.ajouter(instr3, 0);
boolean AjouterA= false;
assertEquals("Test4 ajout 0 instr3",AjouterA,AjouterObtenu);
int lignes=laCommande.getLesLignes().size();
int nbLigneAttendu = 2;
assertEquals("Test4 taille",nbLigneAttendu,lignes);
qteRes=laCommande.getLesLignes().get(instr3);
qteAttendu=0;
assertEquals("Test4 quantite", qteAttendu,qteRes);
/*MORGANN*/ /*MORGANN*/
System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante"); System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante");
/*INES*/ laCommande.ajouter(instr2, 0);
stockRes=instr2.getQteStock();
stockAttendu=9;
assertEquals("test5 stock",stockAttendu,stockRes );
tailleR=laCommande.getLesLignes().size();
tailleAttendue=2;
assertEquals("Test1 taille",tailleAttendue,tailleR);
/*ILONA*/
System.out.println("Cas6 : màj d'une ligne existante avec qté>stock"); System.out.println("Cas6 : màj d'une ligne existante avec qté>stock");
System.out.println("Cas6 : màj d'une ligne existante avec qté>stock");
boolean resultatMethode = laCommande.ajouter(instr1, 12);
boolean resultatMethodeAttendu=false;
assertEquals("test6 mise à jour",resultatMethodeAttendu,resultatMethode);
stockRes=instr1.getQteStock();
stockAttendu=2;
assertEquals("test6 stock",stockAttendu,stockRes );
}
private void assertEquals(String test1_taille, int tailleAttendue, int tailleR) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
private void assertEquals(String la_méthode_ajouter_retourne_false, boolean testResultExpected, boolean test) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
} }

View File

@ -0,0 +1,27 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MusicAndCo">
<!--
see examples at http://testng.org/doc/documentation-main.html#testng-xml
<suite-files>
<suite-file path="./junit-suite.xml" />
</suite-files>
<test name="TimeOut">
<classes>
<class name="test.timeout.TimeOutTest" />
<class name="test.timeout.TimeOutFromXmlTest"/>
<class name="test.timeout.TimeOutThreadLocalSampleTest"/>
</classes>
</test>
-->
<test name="métiers suite">
<packages>
<package name="métiers"/>
</packages>
</test>
</suite>