class BookService implements Service {

    public BookRepresentaion getBookById(String id) {
        Book book = bookRepository.byId(id);
        return book.toRepresentation();
    }

}

class BookServiceTest {

    @InjectMocks
    private BookService applicationService;
    @Mock BookRepository bookRepository;

    @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");
    }

}