Search in sources :

Example 61 with JsonMappingException

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());
}
Also used : RotationStrategy(org.graylog2.plugin.indexer.rotation.RotationStrategy) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) RotationStrategyConfig(org.graylog2.plugin.indexer.rotation.RotationStrategyConfig) NotFoundException(javax.ws.rs.NotFoundException) SchemaFactoryWrapper(com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper) InternalServerErrorException(javax.ws.rs.InternalServerErrorException)

Example 62 with JsonMappingException

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());
    }
}
Also used : RequestFailedException(com.cribbstechnologies.clients.mandrill.exception.RequestFailedException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) BaseMandrillRequest(com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) Test(org.junit.Test)

Example 63 with JsonMappingException

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);
    }
}
Also used : JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UnknownHostException(java.net.UnknownHostException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException)

Example 64 with JsonMappingException

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);
}
Also used : Response(javax.ws.rs.core.Response) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Test(org.junit.jupiter.api.Test)

Example 65 with JsonMappingException

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);
        }
    });
}
Also used : JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) IOException(java.io.IOException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) ResourceMetaDataWriter(org.alfresco.rest.framework.metadata.ResourceMetaDataWriter) Writer(org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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