I have a rest endpoint which returns List<VariablePresentation>
. I am trying to test this rest endpoint as
@Test public void testGetAllVariablesWithoutQueryParamPass() throws Exception { final ClientRequest clientCreateRequest = new ClientRequest("http://localhost:9090/variables"); final MultivaluedMap<String, String> formParameters = clientCreateRequest.getFormParameters(); final String name = "testGetAllVariablesWithoutQueryParamPass"; formParameters.putSingle("name", name); formParameters.putSingle("type", "String"); formParameters.putSingle("units", "units"); formParameters.putSingle("description", "description"); formParameters.putSingle("core", "true"); final GenericType<List<VariablePresentation>> typeToken = new GenericType<List<VariablePresentation>>() { }; final ClientResponse<List<VariablePresentation>> clientCreateResponse = clientCreateRequest.post(typeToken); assertEquals(201, clientCreateResponse.getStatus()); final List<VariablePresentation> variables = clientCreateResponse.getEntity(); assertNotNull(variables); assertEquals(1, variables.size()); }
This test fails with error saying
org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token(..)
How can I fix this issue?