package equipo.once.elizabeth.richard.wilson.restapi;

import equipo.once.elizabeth.richard.wilson.SagloApplication;
import org.junit.Before;
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.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MockMvcBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SagloApplication.class)
@WebAppConfiguration
public class AreaComunControllerTest {

  @Autowired
  private WebApplicationContext wac ;
  private MockMvc mockMvc;


  @Before
  public void setUp() {
    mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
  }


  @Test
  public void buscaAreasTest() throws Exception{
    this.mockMvc
        .perform(get("/api/areacomun/buscar").param("palabra", "piscina"))
        .andDo(print())
        .andExpect(status().isOk());
  }
}

@@ -569,24 +569,79 @@
 MvcBuilder;%0A
+import org.springframework.test.web.servlet.MvcResult;%0A
 import org.s
@@ -1436,16 +1436,38 @@
 ion%7B%0A   
+ MvcResult mvcResult =
  this.mo
@@ -1606,16 +1606,106 @@
 .isOk())
+%0A        .andReturn();%0A%0A    String response = mvcResult.getResponse().getContentAsString()
 ;%0A  %7D%0A%7D%0A

test api area comun.