我想编写其余API方法的测试用例,请在这方面帮助我
@RequestMapping(value = "/v0.1/getFySectionDetails", method = RequestMethod.POST)
public ResponseEntity<?> getFySectionDetails(@RequestBody GstServicesRequestModel gstServicesRequestModel) {
String gstin = gstServicesRequestModel.getGstin();
BigInteger reportId = gstServicesRequestModel.getReportId();
logger.info("Gstin, ReportID : "+gstin+", "+reportId);
CalculationsVO calculationsVo = gstr1DataHandler.getFySectionDetails(gstin, reportId, null, null, null, null, null, null);
return new ResponseEntity<CalculationsVO>(calculationsVo, HttpStatus.OK);
}
我不清楚如何为它编写一个JUnit测试用例。
尝试过但是没用:
@Test
public void getFyMonthlyPurchases() throws Exception {
String requestBody = "{\"gstin\":\"03AAFFJ4844C1ZS\",\"reportId\":\"20190212122427308\"}";
mockMvc.perform(post("/gstr1dh/services/v0.1/getFySectionDetails")
.contentType(PageAttributes.MediaType.APPLICATION_JSON)
.content(requestBody))
.andExpect(status()
.isOk())
.andExpect(jsonPath("$", Matchers.hasSize(1)));
}