Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8fa260fd23 | ||
|
9977862a27 | ||
|
85ab2c6bec |
@ -49,7 +49,6 @@ javac.target=21
|
|||||||
javac.test.classpath=\
|
javac.test.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}:\
|
${build.classes.dir}:\
|
||||||
${libs.testng.classpath}:\
|
|
||||||
${libs.junit_5.classpath}:\
|
${libs.junit_5.classpath}:\
|
||||||
${libs.junit_4.classpath}:\
|
${libs.junit_4.classpath}:\
|
||||||
${libs.hamcrest.classpath}
|
${libs.hamcrest.classpath}
|
||||||
|
@ -19,20 +19,16 @@ 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");
|
||||||
Commande laCommande1 = new Commande(1,1,"12/09/2024");
|
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 des instruments de l'entreprise à la commande
|
//Test Cas0-Ajouter à la commande une ligne de 2 instr1
|
||||||
|
System.out.println("Résultat de l'ajout de 2 instr1 à la commande :" + laCommande.ajouter(instr1, 2) );
|
||||||
//affecter la commande à l'entreprise si la comamnde est possible
|
System.out.println("Nouveau stock de instr1 : "+instr1.getQteStock());
|
||||||
lEntreprise.ajouterCommande(laCommande1);
|
System.out.println("Quantité de la ligne de commande de instr1 :"+laCommande.getLesLignes().get(instr1));
|
||||||
|
|
||||||
//créer une autre commande
|
|
||||||
|
|
||||||
|
|
||||||
//rechercher et afficher une commande
|
|
||||||
|
|
||||||
|
|
||||||
//supprimer une des 2 commande
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ 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;
|
||||||
if(qte!=0){
|
|
||||||
//ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne
|
//ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne
|
||||||
if (lesLignes.containsKey(unInstrument))//l'instrument existe
|
if (lesLignes.containsKey(unInstrument))//l'instrument existe
|
||||||
{
|
{
|
||||||
@ -69,7 +68,8 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
|||||||
unInstrument.setQteStock(qteDisponible-qte);
|
unInstrument.setQteStock(qteDisponible-qte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ajoutOK;
|
return ajoutOK;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
package métiers;
|
package métiers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import métiers.Commande;
|
|
||||||
import métiers.Instrument;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -19,13 +17,6 @@ public class Entreprise {
|
|||||||
|
|
||||||
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() {
|
||||||
@ -47,9 +38,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
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.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -16,14 +18,14 @@ 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);
|
||||||
@ -62,6 +64,7 @@ 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);
|
boolean test= laCommande.ajouter(instr3, 12);
|
||||||
stockRes=instr3.getQteStock();
|
stockRes=instr3.getQteStock();
|
||||||
stockAttendu=8;
|
stockAttendu=8;
|
||||||
@ -75,60 +78,35 @@ public class CommandeTest {
|
|||||||
|
|
||||||
/*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");
|
||||||
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*/
|
/*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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of supprimer method, of class Commande.
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSupprimer() {
|
public void testSupprimer() {
|
||||||
System.out.println("supprimer");
|
//instanciation
|
||||||
Instrument unInstrument = null;
|
|
||||||
Commande instance = null;
|
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
||||||
boolean expResult = false;
|
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
||||||
boolean result = instance.supprimer(unInstrument);
|
Commande laCommande = new Commande(1,1,"12/09/2024");
|
||||||
assertEquals("test supprimer",expResult, result);
|
laCommande.ajouter(instr1, 2);
|
||||||
// TODO review the generated test code and remove the default call to fail.
|
boolean expectedResult=false;
|
||||||
fail("The test case is a prototype.");
|
boolean expectedResult2=true;
|
||||||
}*/
|
|
||||||
|
// test
|
||||||
|
|
||||||
|
boolean test= laCommande.supprimer(instr2);
|
||||||
|
boolean test2= laCommande.supprimer(instr1);
|
||||||
|
|
||||||
|
assertEquals("suppression impossible",expectedResult,test);
|
||||||
|
assertEquals("suppression possible ",test2,expectedResult2 );
|
||||||
|
|
||||||
|
System.out.println("Nombre de ligne dans le dictionnaire: "+laCommande.getLesLignes().size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
<?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>
|
|
Loading…
x
Reference in New Issue
Block a user