Java Code Examples for io.reactivex.Observable.blockingFirst()

The following are Jave code examples for showing how to use blockingFirst() of the io.reactivex.Observable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: sqlbrite-sqlcipher   File: QueryTest.java   Source Code and License Vote up 5 votes
@Test public void mapToOneThrowsOnMultipleRows() {
  Observable<Employee> employees =
      db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES + " LIMIT 2") //
          .lift(Query.mapToOne(MAPPER));
  try {
    employees.blockingFirst();
    fail();
  } catch (IllegalStateException e) {
    assertThat(e).hasMessage("Cursor returned more than 1 row");
  }
}
 
Example 2
Project: sqlbrite-sqlcipher   File: QueryTest.java   Source Code and License Vote up 5 votes
@Test public void mapToOneOrDefaultThrowsOnMultipleRows() {
  Observable<Employee> employees =
      db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES + " LIMIT 2") //
          .lift(Query.mapToOneOrDefault(
              MAPPER, new Employee("fred", "Fred Frederson")));
  try {
    employees.blockingFirst();
    fail();
  } catch (IllegalStateException e) {
    assertThat(e).hasMessage("Cursor returned more than 1 row");
  }
}