com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'code': was expecting ('true', 'false' or 'null') at [Source: [B@5ff2e84b; line: 1, column: 9]
I;m getting this error while running the mockito test case..
please find the below code for more info.
@Test
public void testFindLearningStandardItemCodeById() throws Exception{
String id = "2411";
String json = JsonUtil.getInstance().writeValueAsString(id);
String learningStandardItemCode = new String("code");
when(learningStandardItemManager.findCodeById(anyString())).thenReturn(learningStandardItemCode);
ResultActions resultActions = mockMvc.perform(post("/standards/jurisdiction/standard/item/findCodeById")
.accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON).content(json.getBytes())
);
resultActions.andExpect(status().isOk());
final MvcResult mvcResult = resultActions.andReturn();
String contents = mvcResult.getResponse().getContentAsString();
JsonResponse response = JsonUtil.getInstance().getObjectFromJsonResponse(contents, JsonResponse.class);
System.out.print(response);
assertNotNull(response);
}