Search in sources :

Example 66 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project Store by NYTimes.

the class JacksonReaderParserStoreTest method testCustomJsonFactoryReaderParser.

@Test
public void testCustomJsonFactoryReaderParser() {
    JsonFactory jsonFactory = new JsonFactory();
    Parser<Reader, Foo> parser = JacksonParserFactory.createReaderParser(jsonFactory, Foo.class);
    Store<Foo, BarCode> store = StoreBuilder.<BarCode, Reader, Foo>parsedWithKey().persister(persister).fetcher(fetcher).parser(parser).open();
    Foo result = store.get(barCode).toBlocking().first();
    validateFoo(result);
    verify(fetcher, times(1)).fetch(barCode);
}
Also used : Foo(com.nytimes.android.external.store.middleware.jackson.data.Foo) BarCode(com.nytimes.android.external.store.base.impl.BarCode) JsonFactory(com.fasterxml.jackson.core.JsonFactory) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 67 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project Store by NYTimes.

the class JacksonSourceParserStoreTest method testCustomJsonFactorySourceParser.

@Test
public void testCustomJsonFactorySourceParser() {
    JsonFactory jsonFactory = new JsonFactory();
    Parser<BufferedSource, Foo> parser = JacksonParserFactory.createSourceParser(jsonFactory, Foo.class);
    Store<Foo, BarCode> store = StoreBuilder.<BarCode, BufferedSource, Foo>parsedWithKey().persister(persister).fetcher(fetcher).parser(parser).open();
    Foo result = store.get(barCode).toBlocking().first();
    validateFoo(result);
    verify(fetcher, times(1)).fetch(barCode);
}
Also used : Foo(com.nytimes.android.external.store.middleware.jackson.data.Foo) BarCode(com.nytimes.android.external.store.base.impl.BarCode) JsonFactory(com.fasterxml.jackson.core.JsonFactory) BufferedSource(okio.BufferedSource) Test(org.junit.Test)

Example 68 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project Store by NYTimes.

the class JacksonSourceParserStoreTest method testNullTypeWithValidJsonFactory.

@Test
public void testNullTypeWithValidJsonFactory() {
    expectedException.expect(NullPointerException.class);
    JacksonParserFactory.createStringParser(new JsonFactory(), null);
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) Test(org.junit.Test)

Example 69 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project Store by NYTimes.

the class JacksonStringParserStoreTest method testCustomJsonFactoryStringParser.

@Test
public void testCustomJsonFactoryStringParser() {
    JsonFactory jsonFactory = new JsonFactory();
    Parser<String, Foo> parser = JacksonParserFactory.createStringParser(jsonFactory, Foo.class);
    Store<Foo, BarCode> store = StoreBuilder.<BarCode, String, Foo>parsedWithKey().persister(persister).fetcher(fetcher).parser(parser).open();
    Foo result = store.get(barCode).toBlocking().first();
    validateFoo(result);
    verify(fetcher, times(1)).fetch(barCode);
}
Also used : Foo(com.nytimes.android.external.store.middleware.jackson.data.Foo) BarCode(com.nytimes.android.external.store.base.impl.BarCode) JsonFactory(com.fasterxml.jackson.core.JsonFactory) Test(org.junit.Test)

Example 70 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project Store by NYTimes.

the class JacksonStringParserStoreTest method testNullTypeWithValidJsonFactory.

@Test
public void testNullTypeWithValidJsonFactory() {
    expectedException.expect(NullPointerException.class);
    JacksonParserFactory.createStringParser(new JsonFactory(), null);
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) Test(org.junit.Test)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)115 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)45 Test (org.junit.Test)37 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)35 StringWriter (java.io.StringWriter)34 JsonParser (com.fasterxml.jackson.core.JsonParser)26 IOException (java.io.IOException)16 ExtensibleJSONWriter (com.instagram.common.json.annotation.processor.support.ExtensibleJSONWriter)15 Map (java.util.Map)14 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)9 SimpleParseUUT (com.instagram.common.json.annotation.processor.uut.SimpleParseUUT)8 List (java.util.List)8 Reader (java.io.Reader)6 ServletOutputStream (javax.servlet.ServletOutputStream)6 RemoteSession (org.apache.jackrabbit.oak.remote.RemoteSession)5 FileInputStream (java.io.FileInputStream)4 JSONWriter (org.json.JSONWriter)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 BaseJsonHttpResponseHandler (com.loopj.android.http.BaseJsonHttpResponseHandler)3