Search in sources :

Example 31 with BarCode

use of com.nytimes.android.external.store3.base.impl.BarCode in project Store by NYTimes.

the class ClearStoreMemoryTest method testClearSingleBarCode.

@Test
public void testClearSingleBarCode() {
    // one request should produce one call
    BarCode barcode = new BarCode("type", "key");
    store.get(barcode).test().awaitTerminalEvent();
    assertThat(networkCalls).isEqualTo(1);
    // after clearing the memory another call should be made
    store.clearMemory(barcode);
    store.get(barcode).test().awaitTerminalEvent();
    assertThat(networkCalls).isEqualTo(2);
}
Also used : BarCode(com.nytimes.android.external.store3.base.impl.BarCode) Test(org.junit.Test)

Example 32 with BarCode

use of com.nytimes.android.external.store3.base.impl.BarCode in project Store by NYTimes.

the class DontCacheErrorsTest method testStoreDoesntCacheErrors.

@Test
public void testStoreDoesntCacheErrors() throws InterruptedException {
    BarCode barcode = new BarCode("bar", "code");
    shouldThrow = true;
    store.get(barcode).test().assertTerminated().assertError(Exception.class).awaitTerminalEvent();
    shouldThrow = false;
    store.get(barcode).test().assertNoErrors().awaitTerminalEvent();
}
Also used : BarCode(com.nytimes.android.external.store3.base.impl.BarCode) Test(org.junit.Test)

Example 33 with BarCode

use of com.nytimes.android.external.store3.base.impl.BarCode in project Store by NYTimes.

the class DontCacheErrorsTest method testStoreDoesntCacheErrorsWithResult.

@Test
public void testStoreDoesntCacheErrorsWithResult() throws InterruptedException {
    BarCode barcode = new BarCode("bar", "code");
    shouldThrow = true;
    store.getWithResult(barcode).test().assertTerminated().assertError(Exception.class).awaitTerminalEvent();
    shouldThrow = false;
    store.get(barcode).test().assertNoErrors().awaitTerminalEvent();
}
Also used : BarCode(com.nytimes.android.external.store3.base.impl.BarCode) Test(org.junit.Test)

Aggregations

BarCode (com.nytimes.android.external.store3.base.impl.BarCode)33 Test (org.junit.Test)31 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 BufferedSource (okio.BufferedSource)7 Foo (com.nytimes.android.external.store3.middleware.jackson.data.Foo)6 Gson (com.google.gson.Gson)4 Single (io.reactivex.Single)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3 Store (com.nytimes.android.external.store3.base.impl.Store)3 StoreBuilder (com.nytimes.android.external.store3.base.impl.StoreBuilder)3 Maybe (io.reactivex.Maybe)3 Nonnull (javax.annotation.Nonnull)3 Before (org.junit.Before)3 RunWith (org.junit.runner.RunWith)3 Mock (org.mockito.Mock)3 Mockito.when (org.mockito.Mockito.when)3 MockitoJUnitRunner (org.mockito.runners.MockitoJUnitRunner)3 Clearable (com.nytimes.android.external.store3.base.Clearable)2 Persister (com.nytimes.android.external.store3.base.Persister)2