public void testSearchByPlatform_List() {
    final ArrayList<Platform> platformArrayList = new ArrayList<>();
    platformArrayList.add(PlatformBuilder.aPlatform().build());
    doAnswer(
            new Answer() {
              @Override
              public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
                doAnswer(
                        new Answer() {
                          @Override
                          public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
                            apiResultListenerArgumentCaptor.getValue().onResult(platformArrayList);
                            return null;
                          }
                        })
                    .when(platformApi)
                    .searchByName(anyString());
                return null;
              }
            })
        .when(platformApi)
        .setServiceResultListener(apiResultListenerArgumentCaptor.capture());

    presenter.searchByName(PlatformBuilder.DEFAULT_NAME);

    verify(view, times(1)).showPlatforms(platformArrayList);
    verify(view, never()).warnAnyPlatformFound();
    verify(view, never()).warnFailuredToListPlatforms();
    verify(view, times(1)).showLoading();
    verify(view, times(1)).dismissLoading();
  }
Ejemplo n.º 2
0
  public void testInit_WithPlatform() {
    Float rating = 2f;
    Game game = GameBuilder.aGame().withPlatform(PlatformBuilder.aPlatform().build()).build();
    when(gameRatingDao.getRatingOf(any(Game.class))).thenReturn(rating);

    presenter.init(game);

    verify(view, times(1)).showGame(game);
    verify(view, times(1)).showRating(rating);
    verify(gameRatingDao, times(1)).getRatingOf(game);
    verify(view, times(1)).showPlataforms(game.getPlatforms());
    verify(view, never()).warnNoPlatform();
  }