@@ -0,0 +1,3276 @@
+package com.bubbles.server.web;%0A%0Aimport com.bubbles.server.BubblesApplication;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.SpringApplicationConfiguration;%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.test.context.jdbc.Sql;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.springframework.test.context.web.WebAppConfiguration;%0Aimport org.springframework.test.web.servlet.MockMvc;%0Aimport org.springframework.test.web.servlet.setup.MockMvcBuilders;%0Aimport org.springframework.transaction.annotation.Transactional;%0Aimport org.springframework.web.context.WebApplicationContext;%0A%0Aimport static org.hamcrest.Matchers.hasSize;%0Aimport static org.junit.Assert.*;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0A%0A/**%0A * Test for FeedbackController.%0A *%0A * @author Mingshan Lei%0A * @since 2016/3/7%0A */%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@SpringApplicationConfiguration(classes = BubblesApplication.class)%0A@WebAppConfiguration%0A@Transactional%0A@Sql(%7B%22/test-schema.sql%22, %22/test-user-data.sql%22%7D)%0Apublic class FeedbackControllerTest %7B%0A%0A    @Autowired%0A    private WebApplicationContext wac;%0A%0A    private MockMvc mockMvc;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();%0A    %7D%0A%0A    @Test%0A    public void testGetAdviceById() throws Exception %7B%0A        this.mockMvc.perform(get(%22/feedback/1%22)%0A            .accept(MediaType.APPLICATION_JSON))%0A            .andExpect(status().isOk())%0A            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))%0A            .andExpect(jsonPath(%22$.content%22).value(%22%E5%8F%8D%E9%A6%88%E5%92%8C%E5%BB%BA%E8%AE%AE%22));%0A    %7D%0A%0A    @Test%0A    public void testGetFeedbackByPage() throws Exception %7B%0A        this.mockMvc.perform(get(%22/feedback%22)%0A            .param(%22size%22, %223%22)%0A            .accept(MediaType.APPLICATION_JSON))%0A            .andExpect(status().isOk())%0A            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))%0A            .andExpect(jsonPath(%22$%22, hasSize(3)));%0A    %7D%0A%0A    @Test%0A    public void testSaveAdvice() throws Exception %7B%0A        this.mockMvc.perform(post(%22/feedback%22).contentType(MediaType.APPLICATION_JSON)%0A            .content(%22%7B%5C%22con%5C%22:%5C%22hello world%5C%22%7D%22)%0A            .accept(MediaType.APPLICATION_JSON))%0A            .andExpect(status().isUnprocessableEntity())%0A            .andExpect(content().contentType(MediaType.APPLICATION_JSON));%0A%0A        this.mockMvc.perform(post(%22/feedback%22).contentType(MediaType.APPLICATION_JSON)%0A            .content(%22%7B%5C%22content%5C%22:%5C%22advice%5C%22%7D%22)%0A            .accept(MediaType.APPLICATION_JSON))%0A            .andExpect(status().isOk())%0A            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8));%0A    %7D%0A%7D%0A

test for FeedbackController