Package org.mockserver.model

Examples of org.mockserver.model.Book


    @Test
    public void shouldLoadSingleBook() {
        // given
        Model mockModel = mock(Model.class);
        Book book = new Book(1, "title", "author", "isbn", "publicationDate");
        when(bookService.getBook("1")).thenReturn(book);

        // when
        String viewName = booksPageController.getBook("1", mockModel);
View Full Code Here


                .andReturn();

        // then
        BooksPage booksPage = new BooksPage(response);
        booksPage.containsListOfBooks(Arrays.asList(
                new Book(1, "Xenophon's imperial fiction : on the education of Cyrus", "James Tatum", "0691067570", "1989"),
                new Book(2, "You are here : personal geographies and other maps of the imagination", "Katharine A. Harmon", "1568984308", "2004"),
                new Book(3, "You just don't understand : women and men in conversation", "Deborah Tannen", "0345372050", "1990")
        ));
        proxy.verify(
                request()
                        .withPath("/get_books"),
                Times.exactly(1)
View Full Code Here

                .andExpect(status().isOk())
                .andExpect(content().contentType("text/html;charset=UTF-8"))
                .andReturn();

        BookPage bookPage = new BookPage(response);
        bookPage.containsBook(new Book(1, "Xenophon's imperial fiction : on the education of Cyrus", "James Tatum", "0691067570", "1989"));
        proxy.verify(
                request()
                        .withPath("/get_book")
                        .withQueryStringParameter(
                                new Parameter("id", "1")
View Full Code Here

        return objectMapper;
    }

    private Map<String, Book> createBookData() {
        Map<String, Book> booksDB = new HashMap<String, Book>();
        booksDB.put("1", new Book(1, "Xenophon's imperial fiction : on the education of Cyrus", "James Tatum", "0691067570", "1989"));
        booksDB.put("2", new Book(2, "You are here : personal geographies and other maps of the imagination", "Katharine A. Harmon", "1568984308", "2004"));
        booksDB.put("3", new Book(3, "You just don't understand : women and men in conversation", "Deborah Tannen", "0345372050", "1990"));
        booksDB.put("4", new Book(4, "XML for dummies", "Ed Tittel", "0764506927", "2000"));
        booksDB.put("5", new Book(5, "Your Safari Dragons: In Search of the Real Komodo Dragon", "Daniel White", "1595940146", "2005"));
        booksDB.put("6", new Book(6, "Zeus: A Journey Through Greece in the Footsteps of a God", "Tom Stone", "158234518X", "2008"));
        booksDB.put("7", new Book(7, "Zarafa: a giraffe's true story, from deep in Africa to the heart of Paris", "Michael Allin", "0802713394", "1998"));
        booksDB.put("8", new Book(8, "You Are Not a Gadget: A Manifesto", "Jaron Lanier", "0307269647", "2010"));
        return booksDB;
    }
View Full Code Here

                    response.headers().set(CONTENT_TYPE, "application/json");
                    response.headers().set(CONTENT_LENGTH, response.content().readableBytes());
                } else if (req.getUri().startsWith("/get_book")) {
                    List<String> id = new QueryStringDecoder(req.getUri()).parameters().get("id");
                    if (id != null && !id.isEmpty()) {
                        Book book = booksDB.get(id.get(0));
                        if (book != null) {
                            response = new DefaultFullHttpResponse(HTTP_1_1, OK,
                                    Unpooled.wrappedBuffer(
                                            objectMapper
                                                    .writerWithDefaultPrettyPrinter()
View Full Code Here

TOP

Related Classes of org.mockserver.model.Book

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.