コード例 #1
0
  @Test
  public void testShouldReturnGuitarsOfGivenType() {
    // given
    final int limit = 3;
    final GuitarType type = GuitarType.ACOUSTIC;

    // when
    BlockingObservable<Guitar> observable = provider.observeGuitars(type, limit).toBlocking();

    // then
    observable.forEach(
        new Action1<Guitar>() {
          @Override
          public void call(Guitar guitar) {
            assertThat(guitar.type).isEqualTo(type);
          }
        });
  }
コード例 #2
0
  @Test
  public void testShouldReturnLimitedGuitars() {
    // given
    final int limit = 2;
    final GuitarType type = GuitarType.ELECTRIC;
    final List<Guitar> guitars = new ArrayList<>();

    // when
    BlockingObservable<Guitar> observable = provider.observeGuitars(type, limit).toBlocking();
    observable.forEach(
        new Action1<Guitar>() {
          @Override
          public void call(Guitar guitar) {
            guitars.add(guitar);
          }
        });

    // then
    assertThat(guitars.size()).isEqualTo(limit);
  }