forked from pierront/mylibrary-template
Passer commande #4
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+16
-3
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user