Example usage for com.fasterxml.jackson.core JsonGenerationException JsonGenerationException

List of usage examples for com.fasterxml.jackson.core JsonGenerationException JsonGenerationException

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerationException JsonGenerationException.

Prototype

public JsonGenerationException(String msg) 

Source Link

Usage

From source file:de.undercouch.bson4jackson.deserializers.BsonDeserializer.java

@Override
public T deserialize(JsonParser jsonParser, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    if (!(jsonParser instanceof BsonParser)) {
        throw new JsonGenerationException("BsonDeserializer can " + "only be used with BsonParser");
    }//  w w w  .  ja  v  a2s.  co  m
    return deserialize((BsonParser) jsonParser, ctxt);
}

From source file:de.undercouch.bson4jackson.serializers.BsonSerializer.java

@Override
public void serialize(T t, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
        throws IOException, JsonProcessingException {
    if (!(jsonGenerator instanceof BsonGenerator)) {
        throw new JsonGenerationException("BsonSerializer can " + "only be used with BsonGenerator");
    }/*from www .  java  2 s.  c om*/
    serialize(t, (BsonGenerator) jsonGenerator, serializerProvider);
}

From source file:com.servioticy.datamodel.sensorupdate.SUChannel.java

@JsonGetter("current-value")
public Object getNotNullCurrentValue() throws JsonGenerationException {
    if (currentValue == null) {
        throw new JsonGenerationException("'current-value' must be different from 'null'");
    }//  w  w  w. j  a v a2  s  . c  om
    return getCurrentValue();
}

From source file:com.servioticy.datamodel.serviceobject.SOStream.java

@JsonGetter("channels")
public LinkedHashMap<String, SOChannel> getNotNullOrEmptyChannels() throws JsonGenerationException {
    if (channels == null || channels.size() < 1) {
        throw new JsonGenerationException("At least one channel is required");
    }//from w ww.  j  a v a2  s.  c o m
    return getChannels();
}

From source file:org.gvnix.web.json.ConversionServicePropertySerializer.java

@Override
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    try {/*www .ja  va  2  s  . c o m*/
        jgen.writeObject(this.conversionService.convert(value, sourceType, targetType));
    } catch (ConversionException ex) {
        // conversion exception occurred
        throw new JsonGenerationException(ex);
    } catch (IllegalArgumentException ex) {
        // targetType is null
        throw new JsonGenerationException(ex);
    }
}

From source file:com.servioticy.datamodel.sensorupdate.SensorUpdate.java

@JsonGetter("channels")
public LinkedHashMap<String, SUChannel> getNotNullOrEmptyChannels() throws JsonGenerationException {
    if (channels == null || channels.size() < 1) {
        throw new JsonGenerationException("At least one channel is required");
    }//from  w ww  . ja v a 2 s  .  co m
    return getChannels();
}

From source file:com.flipkart.foxtrot.core.querystore.impl.DistributedCacheTest.java

@Test
public void testPutCacheException() throws Exception {
    doThrow(new JsonGenerationException("TEST_EXCEPTION")).when(mapper).writeValueAsString(any());
    ActionResponse returnResponse = distributedCache.put("DUMMY_KEY_PUT", null);
    verify(mapper, times(1)).writeValueAsString(any());
    assertNull(returnResponse);/*from  w  ww.  ja  v a  2  s.  co m*/
    assertNull(hazelcastInstance.getMap("TEST").get("DUMMY_KEY_PUT"));
}

From source file:com.servioticy.datamodel.serviceobject.SO.java

@JsonGetter("streams")
protected LinkedHashMap<String, Object> getCheckStreams() throws JsonGenerationException {
    if (this.streamsRaw == null || this.streamsRaw.size() < 1) {
        throw new JsonGenerationException("At least one stream is required");
    }//w w w  .  j av a2 s . co m
    return this.streamsRaw;
}

From source file:com.arpnetworking.logback.StenoEncoderTest.java

@Test
public void testEncodeObjectThrowsIOException() throws Exception {
    final LoggingEvent event = new LoggingEvent();
    event.setLevel(Level.INFO);/*from   w  w w. ja  va2  s  .c  om*/
    event.setMarker(StenoMarker.OBJECT_MARKER);
    event.setMessage("logEvent");
    event.setTimeStamp(0);
    event.setLoggerContextRemoteView(_context.getLoggerContextRemoteView());
    final Object[] argArray = new Object[1];
    argArray[0] = new Widget("foo");
    event.setArgumentArray(argArray);
    final ObjectMapper objectMapper = Mockito.mock(ObjectMapper.class);
    Mockito.doThrow(new JsonGenerationException("Mock Failure")).when(objectMapper)
            .writeValueAsString(Mockito.any(Object.class));
    final JsonFactory jsonFactory = Mockito.mock(JsonFactory.class);
    _encoder = new StenoEncoder(jsonFactory, objectMapper);
    _encoder.init(_baos);
    _encoder.doEncode(event);
    final String logOutput = _baos.toString(StandardCharsets.UTF_8.name());
    final String expected = "Unknown exception: Mock Failure";
    Assert.assertEquals(expected, logOutput);
}