use of com.nytimes.android.external.store3.base.Persister 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).blockingGet();
validateFoo(result);
verify(fetcher, times(1)).fetch(barCode);
}
use of com.nytimes.android.external.store3.base.Persister 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).blockingGet();
validateFoo(result);
verify(fetcher, times(1)).fetch(barCode);
}
use of com.nytimes.android.external.store3.base.Persister in project Store by NYTimes.
the class JacksonSourceParserStoreTest method testDefaultJacksonSourceParser.
@Test
public void testDefaultJacksonSourceParser() {
Parser<BufferedSource, Foo> parser = JacksonParserFactory.createSourceParser(Foo.class);
Store<Foo, BarCode> store = StoreBuilder.<BarCode, BufferedSource, Foo>parsedWithKey().persister(persister).fetcher(fetcher).parser(parser).open();
Foo result = store.get(barCode).blockingGet();
validateFoo(result);
verify(fetcher, times(1)).fetch(barCode);
}
use of com.nytimes.android.external.store3.base.Persister 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).blockingGet();
validateFoo(result);
verify(fetcher, times(1)).fetch(barCode);
}
use of com.nytimes.android.external.store3.base.Persister in project Store by NYTimes.
the class MoshiSourceParserTest method testSourceParser.
@Test
public void testSourceParser() throws Exception {
Parser<BufferedSource, Foo> parser = MoshiParserFactory.createSourceParser(Foo.class);
Store<Foo, BarCode> store = ParsingStoreBuilder.<BufferedSource, Foo>builder().persister(persister).fetcher(fetcher).parser(parser).open();
Foo result = store.get(barCode).blockingGet();
assertEquals(result.number, 123);
assertEquals(result.string, "abc");
assertEquals(result.bars.size(), 2);
assertEquals(result.bars.get(0).string, "def");
assertEquals(result.bars.get(1).string, "ghi");
verify(fetcher, times(1)).fetch(barCode);
}
Aggregations