forked from pierront/mylibrary-template
Passer commande #4
@@ -0,0 +1,19 @@
|
||||
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class CommandeDTO {
|
||||
private UUID clientId;
|
||||
private List<LigneCommandeInfo> lignesCommande;
|
||||
private String rue;
|
||||
private String ville;
|
||||
private String codePostal;
|
||||
private String pays;
|
||||
private String modePaiement;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class LigneCommandeDTO {
|
||||
|
||||
int quantite;
|
||||
UUID id;
|
||||
}
|
||||
+13
@@ -2,6 +2,7 @@ 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.CommandeDTO;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
|
||||
|
||||
@@ -18,4 +19,16 @@ public final class CommandeConverter {
|
||||
.modePaiement(modePaiement)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandeDTO toDTO(ComandeInfo commandeInfo, AdresseInfo adressInfo, String modePaiement) {
|
||||
return CommandeDTO.builder()
|
||||
.lignesCommande(commandeInfo.listeLigne())
|
||||
.rue(adressInfo.rue())
|
||||
.ville(adressInfo.ville())
|
||||
.codePostal(adressInfo.codePostal())
|
||||
.pays(adressInfo.pays())
|
||||
.modePaiement(modePaiement)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
@@ -1,5 +1,6 @@
|
||||
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
|
||||
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeDTO;
|
||||
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;
|
||||
@@ -11,4 +12,11 @@ public final class LigneCommandeConverter {
|
||||
.quantite(ligneCommandeInfo.quantite())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static LigneCommandeDTO toDTO(LigneCommandeInfo ligneCommandeInfo) {
|
||||
return LigneCommandeDTO.builder()
|
||||
.quantite(ligneCommandeInfo.quantite())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-5
@@ -1,9 +1,6 @@
|
||||
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.LigneCommandeInfo;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.*;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -33,7 +30,30 @@ public class CommandeConverterTest {
|
||||
|
||||
|
||||
assertNotNull(result);
|
||||
//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());
|
||||
assertEquals(adressInfo.pays() , result.getPays());
|
||||
assertEquals( modePaiement,result.getModePaiement());
|
||||
}
|
||||
|
||||
@Test
|
||||
void TestConvertCommandeToDTO(){
|
||||
String modePaiement = ModePaiement.CB.name();
|
||||
List<LigneCommandeInfo> listLigne = new ArrayList<>();
|
||||
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
|
||||
LigneCommandeInfo ligne2 = new LigneCommandeInfo(14);
|
||||
listLigne.add(ligne);
|
||||
listLigne.add(ligne2);
|
||||
ComandeInfo commandeInfo = new ComandeInfo(listLigne,modePaiement);
|
||||
AdresseInfo adressInfo = new AdresseInfo("rue du cheval","La Rochette","77000","France");
|
||||
|
||||
|
||||
CommandeDTO result = CommandeConverter.toDTO(commandeInfo,adressInfo,modePaiement);
|
||||
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(commandeInfo.listeLigne(), result.getLignesCommande());
|
||||
assertEquals(adressInfo.rue() , result.getRue());
|
||||
assertEquals(adressInfo.ville() , result.getVille());
|
||||
|
||||
+12
@@ -1,5 +1,6 @@
|
||||
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
|
||||
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeDTO;
|
||||
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;
|
||||
@@ -16,6 +17,17 @@ public class LigneCommandeConverterTest {
|
||||
LigneCommande result = LigneCommandeConverter.toDomain(ligne);
|
||||
|
||||
|
||||
assertEquals(ligne.quantite(),result.getQuantite());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void TestConvertLigneCommandeToDTO(){
|
||||
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
|
||||
|
||||
LigneCommandeDTO result = LigneCommandeConverter.toDTO(ligne);
|
||||
|
||||
|
||||
assertEquals(ligne.quantite(),result.getQuantite());
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user