Unable to find a MessageBodyReader of content-type application/json

十年热恋 提交于 2019-12-07 22:18:02

问题


I have a RestEasy Client which gets the Data from rest endpoint. The test looks like

    @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());

    }

I had no idea how to validate ClientResponse so I got help here But when I run my Test I see a separate Issue, I am not sure how to resolve this, please help me with this

testGetAllVariablesWithoutQueryParamPass(com.myorg.project.market.integration.TestVariable): Unable to find a MessageBodyReader of content-type application/json and type java.util.List<com.myorg.project.service.presentation.VariablePresentation>

After adding the maven dependency

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson-provider</artifactId>
    <version>3.0-beta-2</version>
</dependency>

Tests in error:

testGetAllVariablesWithoutQueryParamPass(com.myorg.project.market.integration.TestVariable): org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token(..)

Tests run: 9, Failures: 0, Errors: 1, Skipped: 1

There is a follow up question RestEasy : org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token(..)

来源:https://stackoverflow.com/questions/14775572/unable-to-find-a-messagebodyreader-of-content-type-application-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!