Passer commande #4

Merged
Marvin AUBERT merged 23 commits from PasserCommande into main 2026-06-14 21:46:25 +02:00
4 changed files with 70 additions and 4 deletions
Showing only changes of commit 82164689cf - Show all commits
@@ -18,4 +18,9 @@ public class Commande {
private String codePostal;
private String pays;
private String modePaiement;
public void setRandomUUID() {
this.clientId = UUID.randomUUID();
}
}
@@ -11,6 +11,10 @@ import java.util.UUID;
public class LigneCommande {
int quantite;
UUID id;
UUID livreId;
public void setRandomUUID() {
this.livreId = UUID.randomUUID();
}
}
@@ -1,21 +1,65 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.customer.entity.Customer;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
public class CommandeTest {
@Test
public void commandeTest(){
UUID clientId = UUID.randomUUID();
List<LigneCommandeInfo> lignesCommande = new ArrayList<>();
LigneCommandeInfo commande1 = new LigneCommandeInfo(12);
LigneCommandeInfo commande2 = new LigneCommandeInfo(13);
lignesCommande.add(commande1);
lignesCommande.add(commande2);
String rue = "rue du chien" ;
String ville = "LKa Rochette" ;
String codePostal = "7700" ;
String pays = "France" ;
Commande commande = Commande.builder()
.clientId(clientId)
.lignesCommande(lignesCommande)
.rue(rue)
.ville(ville)
.codePostal(codePostal)
.pays(pays)
.build();
assertEquals(clientId, commande.getClientId());
assertEquals(lignesCommande, commande.getLignesCommande());
assertEquals(rue, commande.getRue());
assertEquals(ville, commande.getVille());
assertEquals(codePostal, commande.getCodePostal());
assertEquals(pays, commande.getPays());
}
@Test
@DisplayName("setRandomUUID should change the ID to a new random UUID")
void testSetRandomUUID() {
Commande commande = Commande.builder().build();
UUID originalId = commande.getClientId();
commande.setRandomUUID();
assertNotNull(commande.getClientId());
assertNotEquals(originalId, commande.getClientId());
}
}
@@ -1,11 +1,12 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.customer.entity.Customer;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
public class LigneCommandeTest {
@@ -17,12 +18,24 @@ public class LigneCommandeTest {
LigneCommande ligneCommande = LigneCommande.builder()
.id(id)
.livreId(id)
.quantite(quantite)
.build();
assertEquals(id, ligneCommande.getId());
assertEquals(id, ligneCommande.getLivreId());
assertEquals(quantite, ligneCommande.getQuantite());
}
@Test
@DisplayName("setRandomUUID should change the ID to a new random UUID")
void testSetRandomUUID() {
LigneCommande ligneCommande = LigneCommande.builder().build();
UUID originalId = ligneCommande.getLivreId();
ligneCommande.setRandomUUID();
assertNotNull(ligneCommande.getLivreId());
assertNotEquals(originalId, ligneCommande.getLivreId());
}
}