BookService implements Service { public BookRepresentaion getBookById(String id) { Book book = bookRepository.byId(id); return book.toRepresentation(); } BookService(BookFactory bookFactory, BookRepository bookRepository); @Transactional String createBook(CreateBookCommand command); List<BookRepresentaion> getBooksLists(); BookRepresentaion getBookById(String id); BookRepresentaion updateBook(String id, @Valid UpdateBookCommand command);  }
@Test void should_return_book_representation_when_get_by_id() { Book value = Book.create("123", "isbn", "name"); when(bookRepository.byId(anyString())).thenReturn(value); BookRepresentaion represention = applicationService.getBookById("123"); assertEquals(represention.getName(), "name"); }