forked from pierront/mylibrary-template
Compare commits
2 Commits
50dd02423d
...
77d79de12a
| Author | SHA1 | Date | |
|---|---|---|---|
| 77d79de12a | |||
| 0c87631c85 |
@@ -15,4 +15,10 @@ public class Review {
|
|||||||
private Integer note;
|
private Integer note;
|
||||||
private String comment;
|
private String comment;
|
||||||
private LocalDate purchaseDate;
|
private LocalDate purchaseDate;
|
||||||
|
|
||||||
|
public void setRandomUUID() {
|
||||||
|
|
||||||
|
this.customerId = UUID.randomUUID();
|
||||||
|
this.bookId = UUID.randomUUID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user