Search in sources :

Example 11 with GitHubRepository

use of io.reark.rxgithubapp.shared.pojo.GitHubRepository in project reark by reark.

the class GitHubRepositoryStoreTest method getOne_WithData_ReturnsData_AndCompletes.

@Test
public void getOne_WithData_ReturnsData_AndCompletes() throws InterruptedException {
    final GitHubRepository value = create(100, "repository1");
    // TODO synchronous init with contentProvider
    gitHubRepositoryStore.put(value);
    Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
    // getOnce is expected to return a observable that emits the value and then completes.
    gitHubRepositoryStore.getOnce(100).subscribe(testSubscriber);
    testSubscriber.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
    testSubscriber.assertCompleted();
    testSubscriber.assertNoErrors();
    testSubscriber.assertReceivedOnNext(singletonList(value));
}
Also used : GitHubRepository(io.reark.rxgithubapp.shared.pojo.GitHubRepository) Test(org.junit.Test)

Example 12 with GitHubRepository

use of io.reark.rxgithubapp.shared.pojo.GitHubRepository in project reark by reark.

the class GitHubRepositoryStoreTest method getOnceAndStream_ReturnsAllValuesForSubscribedId_AndDoesNotComplete.

@Test
public void getOnceAndStream_ReturnsAllValuesForSubscribedId_AndDoesNotComplete() throws InterruptedException {
    final GitHubRepository value1 = create(100, "repository-1");
    final GitHubRepository value2 = create(100, "repository-2");
    final GitHubRepository value3 = create(100, "repository-3");
    gitHubRepositoryStore.getOnceAndStream(100).subscribe(testSubscriber);
    Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
    gitHubRepositoryStore.put(value1);
    Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
    gitHubRepositoryStore.put(value2);
    Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
    gitHubRepositoryStore.put(value3);
    testSubscriber.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
    testSubscriber.assertNotCompleted();
    testSubscriber.assertNoErrors();
    testSubscriber.assertReceivedOnNext(asList(none(), value1, value2, value3));
}
Also used : GitHubRepository(io.reark.rxgithubapp.shared.pojo.GitHubRepository) Test(org.junit.Test)

Example 13 with GitHubRepository

use of io.reark.rxgithubapp.shared.pojo.GitHubRepository in project reark by reark.

the class GitHubRepositoryStoreCoreTest method getStream_DoesNotEmitInitialValue.

@Test
public void getStream_DoesNotEmitInitialValue() {
    final GitHubRepository value = create(100, "test name");
    TestSubscriber<GitHubRepository> testSubscriber = new TestSubscriber<>();
    gitHubRepositoryStoreCore.put(100, value);
    gitHubRepositoryStoreCore.getStream(100).subscribe(testSubscriber);
    gitHubRepositoryStoreCore.put(100, value);
    testSubscriber.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
    testSubscriber.assertNotCompleted();
    testSubscriber.assertNoErrors();
    testSubscriber.assertValue(value);
}
Also used : TestSubscriber(rx.observers.TestSubscriber) GitHubRepository(io.reark.rxgithubapp.shared.pojo.GitHubRepository) Test(org.junit.Test)

Example 14 with GitHubRepository

use of io.reark.rxgithubapp.shared.pojo.GitHubRepository in project reark by reark.

the class GitHubRepositoryStoreCoreTest method getAllCached_ReturnsAllData_AndCompletes.

// GET ALL CACHED
@Test
public void getAllCached_ReturnsAllData_AndCompletes() throws InterruptedException {
    // ARRANGE
    final GitHubRepository value1 = create(100, "test name 1");
    final GitHubRepository value2 = create(200, "test name 2");
    final GitHubRepository value3 = create(300, "test name 3");
    TestSubscriber<List<GitHubRepository>> testSubscriber = new TestSubscriber<>();
    // ACT
    gitHubRepositoryStoreCore.put(100, value1);
    gitHubRepositoryStoreCore.put(200, value2);
    Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
    gitHubRepositoryStoreCore.getAllCached().subscribe(testSubscriber);
    gitHubRepositoryStoreCore.put(300, value3);
    // ASSERT
    testSubscriber.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
    testSubscriber.assertCompleted();
    testSubscriber.assertNoErrors();
    testSubscriber.assertValue(asList(value1, value2));
}
Also used : TestSubscriber(rx.observers.TestSubscriber) List(java.util.List) Arrays.asList(java.util.Arrays.asList) GitHubRepository(io.reark.rxgithubapp.shared.pojo.GitHubRepository) Test(org.junit.Test)

Aggregations

GitHubRepository (io.reark.rxgithubapp.shared.pojo.GitHubRepository)14 Test (org.junit.Test)12 TestSubscriber (rx.observers.TestSubscriber)6 NonNull (android.support.annotation.NonNull)1 GitHubOwner (io.reark.rxgithubapp.shared.pojo.GitHubOwner)1 GitHubRepositorySearch (io.reark.rxgithubapp.shared.pojo.GitHubRepositorySearch)1 UserSettings (io.reark.rxgithubapp.shared.pojo.UserSettings)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Subscription (rx.Subscription)1