forked from pierront/mylibrary-template
✅ réussite des test des de conversions
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.review;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
|
||||||
|
public class ReviewDTO {
|
||||||
|
private UUID customerId;
|
||||||
|
private UUID bookId;
|
||||||
|
private Integer note;
|
||||||
|
private String comment;
|
||||||
|
private LocalDate purchaseDate;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.review;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public record ReviewInfo(Integer note, String comment, LocalDate purchaseDate) {
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.review.converter;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.review.ReviewDTO;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.review.ReviewInfo;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.review.entity.Review;
|
||||||
|
|
||||||
|
public class ReviewConverter {
|
||||||
|
private ReviewConverter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Review toDomain(ReviewInfo newReview) {
|
||||||
|
return Review.builder()
|
||||||
|
.note(newReview.note())
|
||||||
|
.comment(newReview.comment())
|
||||||
|
.purchaseDate(newReview.purchaseDate())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReviewDTO toDTO(Review review) {
|
||||||
|
return ReviewDTO.builder()
|
||||||
|
.customerId(review.getCustomerId())
|
||||||
|
.bookId(review.getBookId())
|
||||||
|
.note(review.getNote())
|
||||||
|
.comment(review.getComment())
|
||||||
|
.purchaseDate(review.getPurchaseDate())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.review.entity;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
|
||||||
|
public class Review {
|
||||||
|
private UUID customerId;
|
||||||
|
private UUID bookId;
|
||||||
|
private Integer note;
|
||||||
|
private String comment;
|
||||||
|
private LocalDate purchaseDate;
|
||||||
|
}
|
||||||
+3
-4
@@ -3,16 +3,15 @@ package fr.iut_fbleau.but3.dev62.mylibrary.review.converter;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import fr.iut_fbleau.but3.dev62.mylibrary.customer.CustomerDTO;
|
import fr.iut_fbleau.but3.dev62.mylibrary.review.ReviewDTO;
|
||||||
import fr.iut_fbleau.but3.dev62.mylibrary.customer.converter.CustomerConverter;
|
import fr.iut_fbleau.but3.dev62.mylibrary.review.ReviewInfo;
|
||||||
import fr.iut_fbleau.but3.dev62.mylibrary.customer.entity.Customer;
|
import fr.iut_fbleau.but3.dev62.mylibrary.review.entity.Review;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
|
|
||||||
@DisplayName("ReviewConverterTest Unit Tests")
|
@DisplayName("ReviewConverterTest Unit Tests")
|
||||||
public class ReviewConverterTest {
|
public class ReviewConverterTest {
|
||||||
|
|||||||
Reference in New Issue
Block a user