création des test sur les entité

This commit is contained in:
2026-05-23 20:18:35 +02:00
parent 3bf4fcad07
commit e125a420a6
11 changed files with 125 additions and 22 deletions
+6
View File
@@ -40,6 +40,12 @@
"pointsFideliteGagnes": "integer"
}
},
"GererAvis": {
"input": {
"clientId": "uuid",
@@ -1,7 +1,6 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
import java.util.List;
import java.util.UUID;
public record ComandeInfo(UUID clientId, List<LigneCommande> lignesCommande) {
public record ComandeInfo(List<LigneCommandeInfo> listeLigne ,String modePayement) {
}
@@ -2,5 +2,5 @@ package fr.iut_fbleau.but3.dev62.mylibrary.commande;
import java.util.UUID;
public record LigneCommande(UUID livreId, Integer quantite) {
public record LigneCommandeInfo(int quantite) {
}
@@ -2,19 +2,15 @@ package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.AdresseInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ComandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommande;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
public final class CommandeConverter {
public static Commande toDomain(ComandeInfo commandeInfo, AdresseInfo adressInfo, ModePaiement modePaiement) {
public static Commande toDomain(ComandeInfo commandeInfo, AdresseInfo adressInfo, String modePaiement) {
return Commande.builder()
.clientId(commandeInfo.clientId())
.lignesCommande(commandeInfo.lignesCommande())
.lignesCommande(commandeInfo.listeLigne())
.rue(adressInfo.rue())
.ville(adressInfo.ville())
.codePostal(adressInfo.codePostal())
@@ -0,0 +1,14 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.LigneCommande;
public final class LigneCommandeConverter {
public static LigneCommande toDomain(LigneCommandeInfo ligneCommandeInfo) {
return LigneCommande.builder()
.quantite(ligneCommandeInfo.quantite())
.build();
}
}
@@ -1,6 +1,6 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommande;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import lombok.Builder;
import lombok.Getter;
@@ -12,10 +12,10 @@ import java.util.UUID;
@Builder
public class Commande {
private UUID clientId;
private List<LigneCommande> lignesCommande;
private List<LigneCommandeInfo> lignesCommande;
private String rue;
private String ville;
private String codePostal;
private String pays;
private ModePaiement modePaiement;
private String modePaiement;
}
@@ -0,0 +1,16 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import lombok.Builder;
import lombok.Getter;
import java.util.UUID;
@Getter
@Builder
public class LigneCommande {
int quantite;
UUID id;
}
@@ -2,9 +2,8 @@ package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.AdresseInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ComandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommande;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.converter.CommandeConverter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import org.junit.jupiter.api.Test;
@@ -20,21 +19,22 @@ public class CommandeConverterTest {
@Test
void TestConvertCommandeToDomain(){
UUID uuidClient = UUID.randomUUID();
UUID uuidLivre = UUID.randomUUID();
List<LigneCommande> listLigne = new ArrayList<>();
LigneCommande ligne = new LigneCommande(uuidLivre,12);
String modePaiement = ModePaiement.CB.name();
List<LigneCommandeInfo> listLigne = new ArrayList<>();
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
LigneCommandeInfo ligne2 = new LigneCommandeInfo(14);
listLigne.add(ligne);
ComandeInfo commandeInfo = new ComandeInfo(uuidClient,listLigne);
listLigne.add(ligne2);
ComandeInfo commandeInfo = new ComandeInfo(listLigne,modePaiement);
AdresseInfo adressInfo = new AdresseInfo("rue du cheval","La Rochette","77000","France");
ModePaiement modePaiement = ModePaiement.CB;
Commande result = CommandeConverter.toDomain(commandeInfo,adressInfo,modePaiement);
assertNotNull(result);
assertEquals(commandeInfo.clientId(),result.getClientId());
assertEquals(commandeInfo.lignesCommande(), result.getLignesCommande());
//assertEquals(commandeInfo.clientId(),result.getClientId());
assertEquals(commandeInfo.listeLigne(), result.getLignesCommande());
assertEquals(adressInfo.rue() , result.getRue());
assertEquals(adressInfo.ville() , result.getVille());
assertEquals(adressInfo.codePostal() , result.getCodePostal());
@@ -0,0 +1,23 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.LigneCommande;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class LigneCommandeConverterTest {
@Test
void TestConvertLigneCommandeToDomain(){
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
LigneCommande result = LigneCommandeConverter.toDomain(ligne);
assertEquals(ligne.quantite(),result.getQuantite());
}
}
@@ -0,0 +1,21 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class CommandeTest {
@Test
public void commandeTest(){
UUID clientId = UUID.randomUUID();
List<LigneCommandeInfo> lignesCommande = new ArrayList<>();
String rue = "rue du chien" ;
String ville = "LKa Rochette" ;
String codePostal = "7700" ;
String pays = "France" ;
}
}
@@ -0,0 +1,28 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class LigneCommandeTest {
@Test
@DisplayName("Builder should create a valid LigneCommande instance")
void TestLigneCommande() {
UUID id = UUID.randomUUID();
int quantite = 12;
LigneCommande ligneCommande = LigneCommande.builder()
.id(id)
.quantite(quantite)
.build();
assertEquals(id, ligneCommande.getId());
assertEquals(quantite, ligneCommande.getQuantite());
}
}