### Question:
DiffItemPresenter { public void draw() { if (ready) { if (open) { openContent(); } } else { throw new IllegalStateException("Item not ready - setup first."); } } @Inject  DiffItemPresenter(final View view,
                             final ResourceTypeManagerCache resourceTypeManagerCache,
                             final PlaceManager placeManager,
                             final TranslationService ts); @PostConstruct void postConstruct(); @PreDestroy void preDestroy(); View getView(); void setup(final ChangeRequestDiff changeRequestDiff,
                      final boolean warnConflict); void draw(); void toggleCollapsibleContainerState();  }### Answer:
@Test public void drawWhenBinaryTextualDiffTest() throws NoSuchFieldException { new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("diffMode")).set(DiffMode.TEXTUAL); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("ready")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("open")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("diff")).set(diff); doReturn("Binary files differ").when(diff).getDiffText(); presenter.draw(); verify(view).drawBinaryContent(); }
@Test public void drawWhenUnmodifiedTextualDiffTest() throws NoSuchFieldException { new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("diffMode")).set(DiffMode.TEXTUAL); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("ready")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("open")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("diff")).set(diff); doReturn("Diff header only").when(diff).getDiffText(); presenter.draw(); verify(view).drawUnmodifiedContent(); }