package hello.controllers;

import static org.hamcrest.core.StringContains.containsString;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
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;

import hello.configuration.Application;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@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())
		.andExpect(content().string(containsString("Hello, World!")));
	}

	@Test
	public void getGreetingName() throws Exception {
		mvc.perform(MockMvcRequestBuilders.get("/greeting?name=Rob").accept(MediaType.TEXT_HTML))
		.andExpect(status().isOk()).andExpect(content().string(containsString("Hello, Rob!")));
	}

}

@@ -1231,134 +1231,633 @@
  get
-GreetingName() throws Exception %7B%0A%09%09mvc.perform(MockMvcRequestBuilders.get(%22/greeting?name=Rob%22).accept(MediaType.TEXT_HTML))%0A
+JsonGreeting() throws Exception %7B%0A%09%09mvc.perform(MockMvcRequestBuilders.get(%22/greeting%22).accept(MediaType.APPLICATION_JSON))%0A%09%09.andExpect(status().isOk()).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.andExpect(status().isOk()).andExpect(content().string(containsString(%22Hello, Rob!%22)));%0A%09%7D%0A%0A%09@Test%0A%09public void getJsonGreetingName() throws Exception %7B%0A%09%09mvc.perform(MockMvcRequestBuilders.get(%22/greeting?name=Rob%22).accept(MediaType.APPLICATION_JSON))%0A%09%09
 %09%09.a

Add tests for JSON responses.