public class ModelDTO implements Serializable {
private Long id;
private String datasetName;
@JsonRawValue
private String json;
}
Post API is working fine from postman or swagger if I send the following body.
{
"id": 1,
"datasetName": "Insurance",
"json" : "[{\"ClassName\":\"AAAA\",\"Fields\":[[\"cdsa\",\"csa\"],[\"ca\"]]},{\"ClassName\":\"ca\",\"Fields\":[null]}]"
}
But MockMVC test case is giving follwing error in Spring boot project
Bad Request: JSON parse error: Unexpected character ('C' (code 67)): was expecting comma to separate Object entries; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('C' (code 67)): was expecting comma to separate Object entries at [Source: (PushbackInputStream); line: 1, column: 89]
mockMvc.perform(post(ENTITY_API_URL).contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValueAsString(ModelDTO))).andExpect(status().isCreated());