use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project graylog2-server by Graylog2.
the class RotationStrategyResource method getRotationStrategyDescription.
private RotationStrategyDescription getRotationStrategyDescription(String strategyName) {
final Provider<RotationStrategy> provider = rotationStrategies.get(strategyName);
if (provider == null) {
throw new NotFoundException("Couldn't find rotation strategy for given type " + strategyName);
}
final RotationStrategy rotationStrategy = provider.get();
final RotationStrategyConfig defaultConfig = rotationStrategy.defaultConfiguration();
final SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
try {
objectMapper.acceptJsonFormatVisitor(objectMapper.constructType(rotationStrategy.configurationClass()), visitor);
} catch (JsonMappingException e) {
throw new InternalServerErrorException("Couldn't generate JSON schema for rotation strategy " + strategyName, e);
}
return RotationStrategyDescription.create(strategyName, defaultConfig, visitor.finalSchema());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project Java-Mandrill-Wrapper by cribbstechnologies.
the class MandrillRESTRequestTest method testPostRequestMapperExceptions.
@Test
public void testPostRequestMapperExceptions() throws ClientProtocolException, IOException {
this.request = new MandrillRESTRequest();
this.request.setHttpClient(this.client);
this.request.setConfig(this.config);
this.request.setObjectMapper(this.mapper);
doThrow(new JsonGenerationException("Mockito!")).when(this.mapper).writeValueAsString(isA(BaseMandrillRequest.class));
try {
this.request.postRequest(this.emptyBaseRequest, "test", null);
fail("Exception not thrown");
} catch (RequestFailedException e) {
assertEquals("Json Generation Exception", e.getMessage());
}
doThrow(new JsonMappingException("Mockito!")).when(this.mapper).writeValueAsString(isA(BaseMandrillRequest.class));
try {
this.request.postRequest(this.emptyBaseRequest, "test", null);
fail("Exception not thrown");
} catch (RequestFailedException e) {
assertEquals("Json Mapping Exception", e.getMessage());
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project oxTrust by GluuFederation.
the class UpdateChecker method processInt.
private void processInt() {
GluuVersionAvailability versionAvailability = new GluuVersionAvailability();
hasUpdate = false;
try {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
versionAvailability = objectMapper.readValue(getVersionAvailability(), GluuVersionAvailability.class);
this.hasUpdate = versionAvailability.isNewVersionAvailable();
if (this.hasUpdate) {
this.updateMessage = " Good news: Gluu version " + versionAvailability.getVersion().split("\\(")[0] + " is available.";
}
} catch (JsonMappingException e) {
log.error("JsonMappingException", e);
} catch (JsonProcessingException e) {
log.error("JsonProcessingException ", e);
} catch (Exception e) {
log.error("Exception ", e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project verify-hub by alphagov.
the class IdaJsonProcessingExceptionMapperTest method toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient.
@Test
public void toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient() {
String clientErrorMessage = "This is a client error";
Response response = mapper.toResponse(new JsonMappingException(null, clientErrorMessage));
ErrorStatusDto errorStatus = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(errorStatus.isAudited()).isEqualTo(false);
assertThat(errorStatus.getClientMessage()).isEqualTo(clientErrorMessage);
assertThat(errorStatus.getExceptionType()).isEqualTo(ExceptionType.JSON_PARSING);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project alfresco-remote-api by Alfresco.
the class WebScriptOptionsMetaData method writeMetaData.
@Override
public void writeMetaData(OutputStream out, ResourceWithMetadata resource, Map<String, ResourceWithMetadata> allApiResources) throws IOException {
final Object result = processResult(resource, allApiResources);
assistant.getJsonHelper().withWriter(out, new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
objectMapper.writeValue(generator, result);
}
});
}
Aggregations