my controller
PostMapping(path = REQUEST_URL, consumes = "application/bson;charset=UTF-8", produces = "application/bson")
public ResponseEntity<UnsubscribeFilterResponse> postFilterRequest(@RequestBody HelloFilterRequest filterRequest){
....}
in My test class
HelloFilterRequest test = new HelloFilterRequest();
this.mockMvc.perform(post("/rest/v1/hello/filter") .contentType(mediaType).content(objectMapper.writeValueAsString(request)))
.andDo(print())
.andExpect(status()
.is4xxClientError());
i got HttpMessageNotReadableException when i run my test case, it not surprise me, because it pass the json string but controller expects bson.... but i have no idea about solution here, is there bson objectMapper can be used here?
Aucun commentaire:
Enregistrer un commentaire