Test point de fidelité convert

This commit is contained in:
2026-06-13 14:23:45 +02:00
parent 4552585ef9
commit 2161a0cf01
@@ -2,9 +2,10 @@ 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.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement; import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import fr.iut_fbleau.but3.dev62.mylibrary.customer.entity.Customer;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -67,13 +68,35 @@ public class CommandeTest {
Commande commande = Commande.builder().build(); Commande commande = Commande.builder().build();
UUID originalId = commande.getCommandeId(); UUID originalId = commande.getCommandeId();
commande.setRandomUUIDCommand(); commande.setRandomUUIDCommande();
assertNotNull(commande.getCommandeId()); assertNotNull(commande.getCommandeId());
assertNotEquals(originalId, commande.getCommandeId()); assertNotEquals(originalId, commande.getCommandeId());
} }
@Test
void testConvertPointsFideliteGagnes(){
Commande commande = Commande.builder()
.montantTotal(14.34)
.build();
Integer point = commande.convertPointsFidelite();
assertEquals(point,(int) Math.ceil(commande.getMontantTotal()));
}
@ParameterizedTest
@ValueSource(doubles = {-1.9,0.0})
void testConvertPointsFideliteGagnesWhenMontantTotalIsNotGood(){
Commande commande = Commande.builder()
.montantTotal(14.34)
.build();
Integer point = commande.convertPointsFidelite();
assertEquals(point,(int) Math.ceil(commande.getMontantTotal()));
}