Package org.mockserver.web.controller.pageobjects

Source Code of org.mockserver.web.controller.pageobjects.BooksPage

package org.mockserver.web.controller.pageobjects;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.mockserver.model.Book;
import org.springframework.test.web.servlet.MvcResult;

import java.io.UnsupportedEncodingException;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

/**
* @author jamesdbloom
*/
public class BooksPage {
    private final Document html;

    public BooksPage(MvcResult response) throws UnsupportedEncodingException {
        html = Jsoup.parse(response.getResponse().getContentAsString());
    }

    public void containsListOfBooks(Collection<Book> books) {
        for (Book book : books) {
            Element bookRow = html.select("#" + book.getId()).first();
            assertEquals("" + book.getId(), bookRow.select(".id").text());
            assertEquals(book.getTitle(), bookRow.select(".title").text());
            assertEquals(book.getAuthor(), bookRow.select(".author").text());
        }
    }
}
TOP

Related Classes of org.mockserver.web.controller.pageobjects.BooksPage

TOP
Copyright © 2018 www.massapi.com. 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.