package hello;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class GreetingControllerTest {

	@Autowired
	private MockMvc mvc;

	@Test
	public void getGreeting() throws Exception {
		mvc.perform(MockMvcRequestBuilders.get("/greeting").accept(MediaType.TEXT_HTML)).andExpect(status().isOk());
	}

}

@@ -9,16 +9,168 @@
 hello;%0A%0A
+import static org.hamcrest.core.StringContains.containsString;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;%0A
 import s
@@ -1052,16 +1052,325 @@
 .isOk())
+%0A%09%09.andExpect(content().string(containsString(%22Hello, World!%22)));%0A%09%7D%0A%0A%09@Test%0A%09public void getGreetingName() throws Exception %7B%0A%09%09mvc.perform(MockMvcRequestBuilders.get(%22/greeting?name=Rob%22).accept(MediaType.TEXT_HTML))%0A%09%09%09%09.andExpect(status().isOk()).andExpect(content().string(containsString(%22Hello, Rob!%22)))
 ;%0A%09%7D%0A%0A%7D%0A

Test view content in greetings test.