SimpleNoExpandWorkbenchPanelPresenter extends AbstractDockingWorkbenchPanelPresenter<SimpleNoExpandWorkbenchPanelPresenter> { @Override public void addPart(WorkbenchPartPresenter part) { SinglePartPanelHelper h = createSinglePartPanelHelper(); if (h.hasNoParts()) { super.addPart(part); } else { h.closeFirstPartAndAddNewOne(() -> super.addPart(part)); } } @Inject  SimpleNoExpandWorkbenchPanelPresenter(@Named("SimpleNoExpandWorkbenchPanelView") final WorkbenchPanelView<SimpleNoExpandWorkbenchPanelPresenter> view,
                                                 final PerspectiveManager perspectiveManager,
                                                 final PlaceManager placeManager); @Override void addPart(WorkbenchPartPresenter part); @Override void addPart(WorkbenchPartPresenter part,
                        String contextId); @Override DockingWorkbenchPanelView<SimpleNoExpandWorkbenchPanelPresenter> getPanelView();  }
@Test public void addPartTest() { WorkbenchPartPresenter workbenchPartPresenter = Mockito.mock(WorkbenchPartPresenter.class); PartDefinition partDefinition = mock(PartDefinition.class); Mockito.when(workbenchPartPresenter.getDefinition()).thenReturn(partDefinition); presenter.addPart(workbenchPartPresenter); boolean hasPart = panelPresenterPanelDefinition.getParts().stream() .filter(part -> part.equals(partDefinition)) .findFirst().isPresent(); assertTrue(hasPart); verify(placeManager, times(0)).tryClosePlace(any(), any()); Mockito.when(view.getParts()).thenReturn(Arrays.asList(partDefinition)); presenter.addPart(workbenchPartPresenter); verify(placeManager).tryClosePlace(any(), any()); }