json 序列化的时候。忽略不存在的字段。
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.gzzn.omms.msgexchangeapi.controller;
|
||||
|
||||
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.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
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;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest()
|
||||
@AutoConfigureMockMvc
|
||||
public class FlightsControllerTest {
|
||||
@Autowired
|
||||
private MockMvc mvc;
|
||||
|
||||
/**
|
||||
* 测试获取所有航班信息接口
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllFilghts() throws Exception
|
||||
{
|
||||
mvc.
|
||||
perform(get("/all/flights"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(jsonPath("$.is_success").value(true))
|
||||
.andDo(print());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user