use of 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");
}
}
use of 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");
}
}
use of 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");
}
}
use of 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);
}
use of com.fasterxml.jackson.databind.JsonMappingException in project candlepin by candlepin.
the class ReaderExceptionMapperTest method handleJsonMappingExceptionWithResponse.
@Test
public void handleJsonMappingExceptionWithResponse() {
Response mockr = mock(Response.class);
when(mockr.getStatus()).thenReturn(400);
ReaderException nfe = new ReaderException("kaboom", new JsonMappingException("nope"));
ReaderExceptionMapper nfem = injector.getInstance(ReaderExceptionMapper.class);
Response r = nfem.toResponse(nfe);
assertEquals(400, r.getStatus());
verifyMessage(r, rtmsg("kaboom"));
}
Aggregations