use of rx.observers.TestSubscriber in project sqlbrite by square.
the class QueryTest method mapToListIgnoresNullCursor.
@Test
public void mapToListIgnoresNullCursor() {
Query nully = new Query() {
@Nullable
@Override
public Cursor run() {
return null;
}
};
TestSubscriber<List<Employee>> subscriber = new TestSubscriber<>();
Observable.just(nully).lift(Query.mapToList(Employee.MAPPER)).subscribe(subscriber);
subscriber.assertNoValues();
subscriber.assertCompleted();
}
use of rx.observers.TestSubscriber in project sqlbrite by square.
the class QueryTest method mapToOneOrDefaultReturnsDefaultWhenNullCursor.
@Test
public void mapToOneOrDefaultReturnsDefaultWhenNullCursor() {
Employee defaultEmployee = new Employee("bob", "Bob Bobberson");
Query nully = new Query() {
@Nullable
@Override
public Cursor run() {
return null;
}
};
TestSubscriber<Employee> subscriber = new TestSubscriber<>();
Observable.just(nully).lift(Query.mapToOneOrDefault(Employee.MAPPER, defaultEmployee)).subscribe(subscriber);
subscriber.assertValues(defaultEmployee);
subscriber.assertCompleted();
}
use of rx.observers.TestSubscriber in project reark by reark.
the class GitHubRepositoryStoreCoreTest method getStream_EmitsValuesForId_AndDoesNotComplete.
// GET STREAM
@Test
public void getStream_EmitsValuesForId_AndDoesNotComplete() {
final GitHubRepository value1 = create(100, "test name 1");
final GitHubRepository value2 = create(200, "test name 2");
TestSubscriber<GitHubRepository> testSubscriber1 = new TestSubscriber<>();
TestSubscriber<GitHubRepository> testSubscriber2 = new TestSubscriber<>();
gitHubRepositoryStoreCore.getStream(100).subscribe(testSubscriber1);
gitHubRepositoryStoreCore.getStream(200).subscribe(testSubscriber2);
gitHubRepositoryStoreCore.put(100, value1);
gitHubRepositoryStoreCore.put(200, value2);
testSubscriber1.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
testSubscriber1.assertNotCompleted();
testSubscriber1.assertNoErrors();
testSubscriber1.assertValue(value1);
testSubscriber2.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
testSubscriber2.assertNotCompleted();
testSubscriber2.assertNoErrors();
testSubscriber2.assertValue(value2);
}
use of rx.observers.TestSubscriber in project reark by reark.
the class GitHubRepositoryStoreCoreTest method getAllStream_ReturnsAllData_AndDoesNotComplete.
// GET ALL STREAM
@Test
public void getAllStream_ReturnsAllData_AndDoesNotComplete() 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<GitHubRepository> testSubscriber = new TestSubscriber<>();
// ACT
gitHubRepositoryStoreCore.put(100, value1);
Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
gitHubRepositoryStoreCore.getAllStream().subscribe(testSubscriber);
gitHubRepositoryStoreCore.put(200, value2);
Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
gitHubRepositoryStoreCore.put(300, value3);
// ASSERT
testSubscriber.awaitTerminalEvent(Constants.Tests.PROVIDER_WAIT_TIME, TimeUnit.MILLISECONDS);
testSubscriber.assertNotCompleted();
testSubscriber.assertNoErrors();
testSubscriber.assertReceivedOnNext(asList(value2, value3));
}
use of rx.observers.TestSubscriber in project reark by reark.
the class GitHubRepositoryStoreCoreTest method put_WithTwoDifferentIds_StoresTwoValues.
// PUT
@Test
public void put_WithTwoDifferentIds_StoresTwoValues() throws InterruptedException {
final GitHubRepository value1 = create(100, "test name 1");
final GitHubRepository value2 = create(200, "test name 2");
TestSubscriber<GitHubRepository> testSubscriber1 = new TestSubscriber<>();
TestSubscriber<GitHubRepository> testSubscriber2 = new TestSubscriber<>();
gitHubRepositoryStoreCore.put(100, value1);
gitHubRepositoryStoreCore.put(200, value2);
Thread.sleep(Constants.Tests.PROVIDER_WAIT_TIME);
gitHubRepositoryStoreCore.getCached(100).subscribe(testSubscriber1);
gitHubRepositoryStoreCore.getCached(200).subscribe(testSubscriber2);
testSubscriber1.awaitTerminalEvent();
testSubscriber1.assertCompleted();
testSubscriber1.assertNoErrors();
testSubscriber1.assertValue(value1);
testSubscriber2.awaitTerminalEvent();
testSubscriber2.assertCompleted();
testSubscriber2.assertNoErrors();
testSubscriber2.assertValue(value2);
}
Aggregations