### Question:
DiffItemPresenter { public void toggleCollapsibleContainerState() { open = !open; handleContent(); } @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 toggleCollapsibleContainerStateWhenReadyOpenVisualTest() throws NoSuchFieldException { new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("diffMode")).set(DiffMode.VISUAL); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("ready")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("open")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("canClose")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("placeRequestCustomLeft")) .set(mock(PlaceRequest.class)); presenter.toggleCollapsibleContainerState(); verify(placeManager).closePlace(any(PlaceRequest.class)); }
@Test public void toggleCollapsibleContainerStateWhenReadyOpenTextualTest() 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("canClose")).set(true); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("open")).set(true); presenter.toggleCollapsibleContainerState(); verify(view).removeTextualContent(); }
@Test public void toggleCollapsibleContainerStateWhenReadyOpenCannotCloseTextualTest() 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("canClose")).set(false); new FieldSetter(presenter, DiffItemPresenter.class.getDeclaredField("open")).set(true); presenter.toggleCollapsibleContainerState(); verify(view, never()).removeTextualContent(); }