use of com.example.demo.entity.Book in project spring-boot-backend-template by paakmau.
the class BookServiceTests method initAll.
@BeforeAll
static void initAll() {
ModelMapper modelMapper = new ModelMapper();
books = Arrays.asList(new Book(1L, "Book 1", "Author 1"), new Book(2L, "Book 2", "Author 2"), new Book(3L, "Book 3", "Author 3"));
bookDtos = books.stream().map(b -> modelMapper.map(b, BookDto.class)).collect(Collectors.toList());
}
use of com.example.demo.entity.Book in project spring-boot-backend-template by paakmau.
the class BookRepoTests method testGetByTitle.
@Test
void testGetByTitle() {
for (Book book : bookMap.values()) {
List<Book> actualBooks = repo.findByTitle(book.getTitle());
assertEquals(1, actualBooks.size());
assertEquals(book, actualBooks.get(0));
}
}
use of com.example.demo.entity.Book in project spring-boot-backend-template by paakmau.
the class BookServiceTests method testGetByTitle.
@Test
void testGetByTitle() {
for (Book book : books) {
Mockito.when(repo.findByTitle(book.getTitle())).thenReturn(Arrays.asList(book));
}
for (BookDto dto : bookDtos) {
List<BookDto> vos = service.getByTitle(dto.getTitle());
assertEquals(1, vos.size());
assertEquals(dto, vos.get(0));
}
}
Aggregations