Package sagan.guides.support

Source Code of sagan.guides.support.UnderstandingDocIntegrationTests

package sagan.guides.support;

import sagan.support.Fixtures;
import saganx.AbstractIntegrationTests;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test;

import org.springframework.test.web.servlet.MvcResult;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

public class UnderstandingDocIntegrationTests extends AbstractIntegrationTests {

    @Test
    public void getExistingGuide() throws Exception {
        String readmeHtml = Fixtures.load("/fixtures/understanding/amqp/README.html");
        stubRestClient.putResponse("/repos/spring-guides/understanding/contents/amqp/README.md", readmeHtml);

        String sidebarHtml = Fixtures.load("/fixtures/understanding/amqp/SIDEBAR.html");
        stubRestClient.putResponse("/repos/spring-guides/understanding/contents/amqp/SIDEBAR.md", sidebarHtml);

        MvcResult response = mockMvc.perform(get("/understanding/AMqp"))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("text/html"))
                .andReturn();

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("title").text(), containsString("Understanding AMqp"));
        assertThat(html.select("h1").text(), containsString("Understanding: AMQP"));
        assertThat(html.select("aside").text(), containsString("Messaging with RabbitMQ"));
    }

    @Test
    public void nonExistentGuideReturns404() throws Exception {
        mockMvc.perform(get("/understanding/non_existent"))
                .andExpect(status().isNotFound())
                .andReturn();
    }

}
TOP

Related Classes of sagan.guides.support.UnderstandingDocIntegrationTests

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.