suite test

This commit is contained in:
2026-06-14 03:02:52 +02:00
parent 98d41ea409
commit 2ed99a901a
@@ -150,7 +150,7 @@ public class CommandeRepositoryTest {
assertEquals("rue", savedCommande.getRue());
assertEquals("moi", savedCommande.getVille());
assertEquals("1", savedCommande.getCodePostal());
assertEquals("1", savedCommande.getPays());
assertEquals("Russie", savedCommande.getPays());
assertEquals(ModePaiement.POINTS_FIDELITE.name(), savedCommande.getModePaiement());
}
@@ -158,16 +158,14 @@ public class CommandeRepositoryTest {
@DisplayName("Save multiple customers should add all of them")
void testSaveMultipleCommande() {
repository.save(commandeN1);
repository.save(commandeN1);
repository.save(commandeN2);
List<Commande> commande = repository.findAll();
assertEquals(2, commande.size());
assertTrue(commande.contains(commandeN1));
assertTrue(commande.contains(commandeN1));
assertTrue(commande.contains(commandeN2));
}
}
@Nested
@@ -196,10 +194,38 @@ public class CommandeRepositoryTest {
Optional<Commande> foundCommande = repository.findById(commandeN1.getCommandeId());
assertTrue(foundCommande.isPresent());
assertEquals(commandeN1.getCommandeId(), foundCommande.getCommandeId());
assertEquals(commandeN1.getClientId(), foundCommande.getClientId());
assertEquals(commandeN1.getCommandeId(), foundCommande.get().getCommandeId());
assertEquals(commandeN1.getClientId(), foundCommande.get().getClientId());
}
@Test
void testFindByIdNotFound(){
UUID nonExistentId = UUID.randomUUID();
Optional<Commande> foundCommande = repository.findById(nonExistentId);
assertTrue(foundCommande.isEmpty());
}
@Test
void testExistsByIdExists(){
boolean exists = repository.existsById(commandeN1.getCommandeId());
assertTrue(exists);
}
@Test
void testExistsByIdNotExists(){
UUID nonExistentId = UUID.randomUUID();
boolean exists = repository.existsById(nonExistentId);
assertTrue(exists);
}
}