Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Commit

Permalink
JAV-293 add test case for JAV-293
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyangyong committed Aug 22, 2017
1 parent e066437 commit 5550289
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ public void createPromotionAndGrabSuccessfully() throws Exception {

}

@Test
public void createANdPublishMutiPromotionAndGrabSuccessfully() throws Exception {
MvcResult result = mockMvc.perform(post("/admin/promotions/").contentType(APPLICATION_JSON)
.content(toJson(new PromotionDto(5, 0.7f, new Date()))))
.andExpect(status().isOk()).andReturn();
String promotionId1 = result.getResponse().getContentAsString();

result = mockMvc.perform(post("/admin/promotions/").contentType(APPLICATION_JSON)
.content(toJson(new PromotionDto(10, 0.8f, new Date()))))
.andExpect(status().isOk()).andReturn();
String promotionId2 = result.getResponse().getContentAsString();

Thread.sleep(2000);

mockMvc.perform(post("/command/coupons/").contentType(APPLICATION_JSON)
.content(toJson(new CouponDto<>(promotionId1, "zyy"))))
.andExpect(status().isOk()).andExpect(content().string("Request accepted"));

mockMvc.perform(post("/command/coupons/").contentType(APPLICATION_JSON)
.content(toJson(new CouponDto<>(promotionId2, "zyy"))))
.andExpect(status().isOk()).andExpect(content().string("Request accepted"));
}

@Test
public void failsUpdatePromotionWhenPromotionHadStarted() throws Exception {
MvcResult result = mockMvc.perform(post("/admin/promotions/").contentType(APPLICATION_JSON)
Expand Down

0 comments on commit 5550289

Please sign in to comment.