Search in sources :

Example 31 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project underlx by underlx.

the class API method postPairRequest.

public Pair postPairRequest(PairRequest request) throws APIException {
    try {
        byte[] content = mapper.writeValueAsBytes(request);
        InputStream is = postRequest(endpoint.resolve("pair"), content, false);
        return mapper.readValue(is, Pair.class);
    } catch (JsonParseException e) {
        throw new APIException(e).addInfo("Parse exception");
    } catch (JsonMappingException e) {
        throw new APIException(e).addInfo("Mapping exception");
    } catch (IOException e) {
        throw new APIException(e).addInfo("IOException");
    }
}
Also used : APIException(im.tny.segvault.disturbances.exception.APIException) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException)

Example 32 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project underlx by underlx.

the class API method postFeedback.

public Feedback postFeedback(Feedback request) throws APIException {
    try {
        byte[] content = mapper.writeValueAsBytes(request);
        InputStream is = postRequest(endpoint.resolve("feedback"), content, true);
        return mapper.readValue(is, Feedback.class);
    } catch (JsonParseException e) {
        throw new APIException(e).addInfo("Parse exception");
    } catch (JsonMappingException e) {
        throw new APIException(e).addInfo("Mapping exception");
    } catch (IOException e) {
        throw new APIException(e).addInfo("IOException");
    }
}
Also used : APIException(im.tny.segvault.disturbances.exception.APIException) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException)

Example 33 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project underlx by underlx.

the class API method putTrip.

public Trip putTrip(TripRequest request) throws APIException {
    try {
        byte[] content = mapper.writeValueAsBytes(request);
        InputStream is = putRequest(endpoint.resolve("trips"), content, true);
        return mapper.readValue(is, Trip.class);
    } catch (JsonParseException e) {
        throw new APIException(e).addInfo("Parse exception");
    } catch (JsonMappingException e) {
        throw new APIException(e).addInfo("Mapping exception");
    } catch (IOException e) {
        throw new APIException(e).addInfo("IOException");
    }
}
Also used : APIException(im.tny.segvault.disturbances.exception.APIException) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException)

Example 34 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project underlx by underlx.

the class API method postTrip.

public Trip postTrip(TripRequest request) throws APIException {
    try {
        byte[] content = mapper.writeValueAsBytes(request);
        InputStream is = postRequest(endpoint.resolve("trips"), content, true);
        return mapper.readValue(is, Trip.class);
    } catch (JsonParseException e) {
        throw new APIException(e).addInfo("Parse exception");
    } catch (JsonMappingException e) {
        throw new APIException(e).addInfo("Mapping exception");
    } catch (IOException e) {
        throw new APIException(e).addInfo("IOException");
    }
}
Also used : APIException(im.tny.segvault.disturbances.exception.APIException) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException)

Example 35 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project candlepin by candlepin.

the class ListenerWrapperTest method whenMapperReadThrowsExceptionThenOnMessageShouldFail.

@Test(expected = RuntimeException.class)
public void whenMapperReadThrowsExceptionThenOnMessageShouldFail() throws Exception {
    doReturn("test123").when(activeMQBuffer).readString();
    doThrow(new JsonMappingException("Induced exception")).when(mapper).readValue(anyString(), eq(Event.class));
    this.listenerWrapper.onMessage(mockClientMessage);
}
Also used : JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Test(org.junit.Test)

Aggregations

JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)185 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)93 IOException (java.io.IOException)80 JsonParseException (com.fasterxml.jackson.core.JsonParseException)57 Test (org.junit.Test)45 ATTest (org.jboss.eap.additional.testsuite.annotations.ATTest)33 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)24 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 File (java.io.File)15 HashMap (java.util.HashMap)15 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 InputStream (java.io.InputStream)11 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 List (java.util.List)8 Writer (org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer)7 Test (org.junit.jupiter.api.Test)6