use of okio.BufferedSource in project Store by NYTimes.
the class FilePersisterTest method writeThenRead.
@Test
public void writeThenRead() throws IOException {
when(fileSystem.read(resolvedPath)).thenReturn(bufferedSource);
when(fileSystem.exists(resolvedPath)).thenReturn(true);
fileSystemPersister.write(simple, bufferedSource).toBlocking().single();
BufferedSource source = fileSystemPersister.read(simple).toBlocking().first();
InOrder inOrder = inOrder(fileSystem);
inOrder.verify(fileSystem).write(resolvedPath, bufferedSource);
inOrder.verify(fileSystem).exists(resolvedPath);
inOrder.verify(fileSystem).read(resolvedPath);
assertThat(source).isEqualTo(bufferedSource);
}
use of okio.BufferedSource in project Store by NYTimes.
the class FileSystemRecordPersisterTest method readExists.
@Test
public void readExists() throws FileNotFoundException {
when(fileSystem.exists(resolvedPath)).thenReturn(true);
when(fileSystem.read(resolvedPath)).thenReturn(bufferedSource);
BufferedSource returnedValue = fileSystemPersister.read(simple).toBlocking().single();
assertThat(returnedValue).isEqualTo(bufferedSource);
}
use of okio.BufferedSource in project Store by NYTimes.
the class FileSystemRecordPersisterTest method writeThenRead.
@Test
public void writeThenRead() throws IOException {
when(fileSystem.read(resolvedPath)).thenReturn(bufferedSource);
when(fileSystem.exists(resolvedPath)).thenReturn(true);
fileSystemPersister.write(simple, bufferedSource).toBlocking().single();
BufferedSource source = fileSystemPersister.read(simple).toBlocking().first();
InOrder inOrder = inOrder(fileSystem);
inOrder.verify(fileSystem).write(resolvedPath, bufferedSource);
inOrder.verify(fileSystem).exists(resolvedPath);
inOrder.verify(fileSystem).read(resolvedPath);
assertThat(source).isEqualTo(bufferedSource);
}
use of okio.BufferedSource 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).toBlocking().first();
validateFoo(result);
verify(fetcher, times(1)).fetch(barCode);
}
use of okio.BufferedSource in project Store by NYTimes.
the class JacksonSourceParserStoreTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
BufferedSource bufferedSource = source(sourceString);
assertNotNull(bufferedSource);
when(fetcher.fetch(barCode)).thenReturn(Observable.just(bufferedSource));
when(persister.read(barCode)).thenReturn(Observable.<BufferedSource>empty()).thenReturn(Observable.just(bufferedSource));
when(persister.write(barCode, bufferedSource)).thenReturn(Observable.just(true));
}
Aggregations