From 0c87631c850a1683712ae9db6dad9ffae4edf8a6 Mon Sep 17 00:00:00 2001 From: aubert Date: Tue, 9 Jun 2026 22:11:13 +0200 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20cr=C3=A9ation=20des=20?= =?UTF-8?q?test=20sur=20l'objet=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mylibrary/review/entity/ReviewTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/test/java/fr/iut_fbleau/but3/dev62/mylibrary/review/entity/ReviewTest.java diff --git a/src/test/java/fr/iut_fbleau/but3/dev62/mylibrary/review/entity/ReviewTest.java b/src/test/java/fr/iut_fbleau/but3/dev62/mylibrary/review/entity/ReviewTest.java new file mode 100644 index 0000000..8d70e33 --- /dev/null +++ b/src/test/java/fr/iut_fbleau/but3/dev62/mylibrary/review/entity/ReviewTest.java @@ -0,0 +1,51 @@ +package fr.iut_fbleau.but3.dev62.mylibrary.review.entity; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.time.LocalDate; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.*; + +public class ReviewTest { + + @Test + @DisplayName("Builder should create a valid review instance") + void testReviewBuilder() { + UUID customerId = UUID.randomUUID(); + UUID bookId = UUID.randomUUID(); + Integer note = 5; + String comment = "très bon livre"; + LocalDate purchaseDate = LocalDate.of(2026, 3, 24); + + Review review = Review.builder() + .customerId(customerId) + .bookId(bookId) + .note(note) + .comment(comment) + .purchaseDate(purchaseDate) + .build(); + + assertEquals(customerId, review.getCustomerId()); + assertEquals(bookId, review.getBookId()); + assertEquals(note, review.getNote()); + assertEquals(comment, review.getComment()); + assertEquals(purchaseDate, review.getPurchaseDate()); + } + + @Test + @DisplayName("setRandomUUID should change the ID to a new random UUID") + void testSetRandomUUID() { + Review review = Review.builder().build(); + UUID originalCustomerId = review.getCustomerId(); + UUID originalBookId = review.getCustomerId(); + + review.setRandomUUID(); + + assertNotNull(review.getCustomerId()); + assertNotNull(review.getBookId()); + assertNotEquals(originalCustomerId, review.getCustomerId()); + assertNotEquals(originalBookId, review.getBookId()); + } +}