在post api上执行mockmvc时出错。因为在这个post call中,我的服务层检查客户是否存在。所以这是给我的客户找不到的错误。我怎么能在这里嘲笑顾客?
final String PAYMENT_METHOD = "/customer/"+customerId+"/paymentMethod";
RequestBuilder request = MockMvcRequestBuilders.post(PAYMENT_METHOD).content(JsonUtils.toJson(paymentMethodDto))
.contentType(MediaType.APPLICATION_JSON)
.accept((MediaType.APPLICATION_JSON));
MvcResult result = mockMvc.perform(request).andExpect(status().isCreated()).andReturn();
Assert.assertEquals(result.getResponse().getStatus(), HttpStatus.CREATED.value());
ResponseEntity<PaymentMethodRes> responseEntity = paymentMethodController.addPaymentMethod(customerId, paymentMethodDto);
assertNotNull(responseEntity);
1条答案
按热度按时间dauxcl2d1#
这应该管用