forked from pierront/mylibrary-template
premier test valider
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
|
||||||
|
|
||||||
|
public record AdresseInfo(String rue, String ville, String codePostal, String pays) {}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public record ComandeInfo(UUID clientId, List<LigneCommande> lignesCommande) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public record LigneCommande(UUID livreId, Integer quantite) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
|
||||||
|
|
||||||
|
public enum ModePaiement {
|
||||||
|
CB,
|
||||||
|
PAYPAL,
|
||||||
|
POINTS_FIDELITE,
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
|
||||||
|
return Commande.builder()
|
||||||
|
.clientId(commandeInfo.clientId())
|
||||||
|
.lignesCommande(commandeInfo.lignesCommande())
|
||||||
|
.rue(adressInfo.rue())
|
||||||
|
.ville(adressInfo.ville())
|
||||||
|
.codePostal(adressInfo.codePostal())
|
||||||
|
.pays(adressInfo.pays())
|
||||||
|
.modePaiement(modePaiement)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
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.ModePaiement;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class Commande {
|
||||||
|
private UUID clientId;
|
||||||
|
private List<LigneCommande> lignesCommande;
|
||||||
|
private String rue;
|
||||||
|
private String ville;
|
||||||
|
private String codePostal;
|
||||||
|
private String pays;
|
||||||
|
private ModePaiement modePaiement;
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
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.converter.CommandeConverter;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
|
||||||
|
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.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
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);
|
||||||
|
listLigne.add(ligne);
|
||||||
|
ComandeInfo commandeInfo = new ComandeInfo(uuidClient,listLigne);
|
||||||
|
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(adressInfo.rue() , result.getRue());
|
||||||
|
assertEquals(adressInfo.ville() , result.getVille());
|
||||||
|
assertEquals(adressInfo.codePostal() , result.getCodePostal());
|
||||||
|
assertEquals(adressInfo.pays() , result.getPays());
|
||||||
|
assertEquals( modePaiement,result.getModePaiement());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package fr.iut_fbleau.but3.dev62.mylibrary.Orders.converter;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Orders;
|
|
||||||
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.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
|
|
||||||
public class OrdersConverterTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void TestConvertOrdersToDomain(){
|
|
||||||
UUID uuid = UUID.randomUUID();
|
|
||||||
List<LigneCommande> listLigne = new ArrayList<>();
|
|
||||||
LigneCommande ligne = new LigneCommande("hp ecole ",12);
|
|
||||||
listLigne.add(ligne);
|
|
||||||
Comandeinfo commandeInfo = new ComandeInfo(uuid,listLigne);
|
|
||||||
AdresseInfo adressInfo = new AdresseInfo("rue du cheval","La Rochette","77000","France");
|
|
||||||
ModePaiement modePaiement = ModePaiement.CB;
|
|
||||||
|
|
||||||
Orders result = OrdersConverter.toDomain(commandeInfo,adressInfo,modePaiement);
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
|
||||||
assertEquals(result.clientId ,commandeInfo.clientId);
|
|
||||||
assertEquals(commandeInfo.lignesCommande(), result.lignesCommande());
|
|
||||||
assertEquals(result.rue , AdresseInfo.rue);
|
|
||||||
assertEquals(result.ville , AdresseInfo.ville);
|
|
||||||
assertEquals(result.codePostal , AdresseInfo.codePostal);
|
|
||||||
assertEquals(result.pays , AdresseInfo.pays);
|
|
||||||
assertEquals(result.modePaiement , modePaiement);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user