NavigationIconResolver { public void resolve(Button button, Task<Drawable> onSuccess) { if (button.icon.hasValue()) { imageLoader.loadIcon(context, button.icon.get(), new ImageLoadingListenerAdapter() { @Override public void onComplete(@NonNull Drawable icon) { onSuccess.run(icon); } @Override public void onError(Throwable error) { throw new RuntimeException(error); } }); } else if (Constants.BACK_BUTTON_ID.equals(button.id)) { onSuccess.run(ContextCompat.getDrawable(context, R.drawable.ic_arrow_back_black_24dp)); } else { Log.w("RNN", "Left button needs to have an icon"); } } NavigationIconResolver(Context context, ImageLoader imageLoader); void resolve(Button button, Task<Drawable> onSuccess);  }
@Test public void create_iconButton() { @SuppressWarnings("Convert2Lambda") Task<Drawable> onSuccess = spy(new Task<Drawable>() { @Override public void run(Drawable icon) { } }); uut.resolve(iconButton(), onSuccess); verify(imageLoader).loadIcon(eq(context), eq(ICON_URI), any()); verify(onSuccess).run(any(Drawable.class)); }
@Test public void create_backButton() { @SuppressWarnings("Convert2Lambda") Task<Drawable> onSuccess = spy(new Task<Drawable>() { @Override public void run(Drawable param) { } }); uut.resolve(backButton(), onSuccess); verifyZeroInteractions(imageLoader); verify(onSuccess).run(any()); }