package org.demo.controller;

import static org.junit.Assert.*;
import static org.hamcrest.Matchers.equalTo;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.demo.Application;
import org.demo.service.PersonService;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

@RunWith(SpringJUnit4ClassRunner.class)
//@SpringApplicationConfiguration(classes = MockServletContext.class)
@SpringApplicationConfiguration(classes=Application.class)
@WebAppConfiguration
public class PersonControllerTest {

	private MockMvc mvc;

	@Autowired
	private PersonService personService;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		mvc = MockMvcBuilders.standaloneSetup(new PersonController(personService)).build();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testCreate() {
		fail("Not yet implemented");
	}

	@Test
	public void testDelete() {
		fail("Not yet implemented");
	}

	@Test
	public void testFindAll() throws Exception {
//		fail("Not yet implemented");
		mvc.perform(MockMvcRequestBuilders.get("/api/person").accept(MediaType.APPLICATION_JSON))
				.andExpect(status().isOk());
//				.andExpect(content().contentType(MediaType.APPLICATION_JSON));
//		.andExpect(content().string(equalTo("Hello World!")));
	}

	@Test
	public void testFindById() {
		fail("Not yet implemented");
	}

	@Test
	public void testUpdate() {
		fail("Not yet implemented");
	}

}

@@ -1876,42 +1876,8 @@
  %7B%0D%0A
-//%09%09fail(%22Not yet implemented%22);%0D%0A
 %09%09mv
@@ -1996,21 +1996,18 @@
 .isOk())
-;
 %0D%0A
-//
 %09%09%09%09.and
@@ -2065,68 +2065,31 @@
 JSON
-));%0D%0A//%09%09.andExpect(content().string(equalTo(%22Hello World!%22)
+_VALUE+%22;charset=UTF-8%22
 ));%0D

delete some comments