Feature/manage reviews #2

Merged
Patrick FELIX-VIMALARATNAM merged 20 commits from feature/manage_reviews into main 2026-06-12 20:48:07 +02:00
Showing only changes of commit 0c87631c85 - Show all commits
@@ -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());
}
}