Début de la feature avec des tests de base sur les variables
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
"langue": "string"
|
"langue": "string"
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
|
"_comment": "c'est ce qui affiche quand tu crée avec la usecase (regarde register de customer)",
|
||||||
"isbn": "string(13)"
|
"isbn": "string(13)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.book;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class BookDetails {
|
||||||
|
private ArrayList<String> categories = new ArrayList<>();
|
||||||
|
private String description ;
|
||||||
|
private String language;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.book;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public record BookInfo(String title, String author, String editor, LocalDate date) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.book.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class Book {
|
||||||
|
private ArrayList<String> categories = new ArrayList<>();
|
||||||
|
private String description ;
|
||||||
|
private String language;
|
||||||
|
private String title;
|
||||||
|
private String author;
|
||||||
|
private String editor;
|
||||||
|
private LocalDate date;
|
||||||
|
|
||||||
|
}
|
||||||
+73
@@ -0,0 +1,73 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.book.converter;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.BookDTO;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.BookInfo;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.BookDetails;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.entity.Book;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
@DisplayName("BookConverterTest Unit Tests")
|
||||||
|
public class BookConverterTest {
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@DisplayName("toDomain() method tests")
|
||||||
|
class ToDomainTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ShouldConvertBookToDomain(){
|
||||||
|
LocalDate date = LocalDate.of(2026, 3, 24);
|
||||||
|
BookInfo bookinfo = new BookInfo("La vie de Maxime", "Marvin Aubert", "Kioon", date);
|
||||||
|
ArrayList<String> categories = new ArrayList<>();
|
||||||
|
categories.add("Thriller");
|
||||||
|
categories.add("Biographie");
|
||||||
|
BookDetails.builder()
|
||||||
|
.categories(categories)
|
||||||
|
.description("C'était un brave partit trop tôt")
|
||||||
|
.language("Français")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Book result = BookConvert.ToDomain(bookinfo,bookdetails);
|
||||||
|
|
||||||
|
//assertNotNull(result);
|
||||||
|
assertEquals(bookinfo.title(), result.getTitle());
|
||||||
|
assertEquals(bookinfo.author(), result.getAuthor());
|
||||||
|
assertEquals(bookinfo.editor(), result.getEditor());
|
||||||
|
assertEquals(bookinfo.date(), result.getDate());
|
||||||
|
assertEquals(categories, result.getCategories());
|
||||||
|
assertEquals(bookdetails.getDescription(), result.getDescription());
|
||||||
|
assertEquals(bookdetails.getLanguage(), result.getLanguage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
@Nested
|
||||||
|
@DisplayName("toDTO() method tests")
|
||||||
|
class ToDTOTests {
|
||||||
|
LocalDate date = LocalDate.of(2026, 3, 24);
|
||||||
|
ArrayList<String> categories = new ArrayList<String>();
|
||||||
|
categories.add("Thriller");
|
||||||
|
categories.add("Biographie");
|
||||||
|
Book book = Book.builder()
|
||||||
|
.isbn(1234567891012)
|
||||||
|
.title("La vie de Maxime")
|
||||||
|
.author("Marvin Aubert")
|
||||||
|
.editor("Kioon")
|
||||||
|
.date(date)
|
||||||
|
.price()
|
||||||
|
.stock()
|
||||||
|
.categories(categories)
|
||||||
|
.Description()
|
||||||
|
.language()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
BookDTO result = BookConvert.ToDTO(book);
|
||||||
|
|
||||||
|
}**/
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user