@Test
public void appFormSubmissionTest() throws Exception {
AppFormSubmissionBOResponse resonse = new ObjectMapper().readValue(
AppFormSubmissionBOResponse.class.getResourceAsStream("/appFormSubmission_BO_Resp.json"),
new TypeReference<AppFormSubmissionBOResponse>() {});
Mockito.when(apiCallImpl.invokeSubmitApplicationForm(any(String.class),any(HttpEntity.class))).thenReturn(resonse);
this.mockMvc.perform(MockMvcRequestBuilders.post("/appformsubmission")
.accept(MediaType.APPLICATION_JSON_VALUE)
.content(new ObjectMapper().readValue(ChanelRequest.class.getResourceAsStream("/appFormSubmissionChanelRequest.json"),
new TypeReference<ChanelRequest<AppFormDetails>>() {}).toString())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.payload.dataEntity.pdfUrl", is("")));
}
对于此代码,我得到以下错误。 java.lang.AssertionError:状态应为:<200>,但为:<400>
这是控制器类
@PostMapping(path = "/appformsubmission")
public ChanelResponse<AppFormSubmissionResponse> saveAppForm(
@RequestBody ChanelRequest<AppFormDetails> requestObject) throws JsonProcessingException {
logger.info("MwController -saveAppForm ");
if (logger.isDebugEnabled()) {
logger.debug("Entering MwController() method");
logger.debug("requestObject : {}", Utility.toJsonString(requestObject));
}
return appFormService.submitApplicationForm(requestObject);
}
请帮助我解决这个问题。