ResultActions result = mvc
.perform(get("/"))
.andExpect(status().isOk())
// 적절한 model을 가지고 있는가?
.andExpect(model().attributeExists("investPopularCardList"))
.andExpect(
model().attribute("investPopularCardList", hasSize(3)))
.andExpect(model().attributeExists("investMainCardList"))
.andExpect(model().attributeExists("cardListCount"));
result.andDo(print());
ResultActions results2 = mvc.perform(post("/")
.content(objectMapper.writeValueAsString(param))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
// Response가 Json타입인가?
.andExpect(jsonPath("$.code",isA(String.class))); // campaignId가 있는가?
results2.andDo(print());
ResultActions result = mvc
.perform(
get("/"))
.andExpect(status().isOk()) // 200 인가?
.andExpect(
content().contentType("application/json;charset=UTF-8"))
// Response가 Json타입인가?
.andExpect(
MockMvcResultMatchers.jsonPath("$[0].campaignId",
isA(Integer.class))); // campaignId가 있는가
ResultActions result = mvc
.perform(
get("/"))
.andExpect(status().isOk())
// 200 인가?
.andExpect(
content().contentType("application/json;charset=UTF-8"))
// Response가 Json타입인가?
.andExpect(
MockMvcResultMatchers.jsonPath("$.count",
isA(Integer.class)));
ResultActions result = mvc.perform(get("/")).andExpect(status().isOk())
//적절한 model을 가지고 있는가?
.andExpect(model().attributeExists("investPopularCardList"))
.andExpect(model().attribute("investPopularCardList", hasSize(3)))
.andExpect(model().attributeExists("rewardPopularCardList"))
.andExpect(model().attribute("rewardPopularCardList", hasSize(3)));
ResultActions result = mvc
.perform(get("/"))
.andExpect(status().isOk()) // 200 인가?
.andExpect(
content().contentType("application/json;charset=UTF-8")) // Response가 Json타입인가?
.andExpect(MockMvcResultMatchers.jsonPath("$", hasSize(6)));