@Test public void removeNonContainedPart() { WorkbenchPartPresenter mockPresenter = mock(WorkbenchPartPresenter.class); WorkbenchPartPresenter.View mockPartView = mock(WorkbenchPartPresenter.View.class); PartDefinition mockPartDefinition = new PartDefinitionImpl(new DefaultPlaceRequest("mock1")); when(mockPartView.getPresenter()).thenReturn(mockPresenter); when(mockPresenter.getDefinition()).thenReturn(mockPartDefinition); WorkbenchPartPresenter mockPresenter2 = mock(WorkbenchPartPresenter.class); WorkbenchPartPresenter.View mockPartView2 = mock(WorkbenchPartPresenter.View.class); PartDefinition mockPartDefinition2 = new PartDefinitionImpl(new DefaultPlaceRequest("mock2")); when(mockPartView2.getPresenter()).thenReturn(mockPresenter2); when(mockPresenter2.getDefinition()).thenReturn(mockPartDefinition2); when(view.panel.getPartView()).thenReturn(null); view.addPart(mockPartView); when(view.panel.getPartView()).thenReturn(mockPartView); boolean removed = view.removePart(mockPartDefinition2); assertFalse(removed); verify(panel, never()).clear(); }
@Test public void addPartToPanelWhenPartViewIsNull() { WorkbenchPartPresenter.View viewWbPartPresenter = mock(WorkbenchPartPresenter.View.class); when(panel.getPartView()).thenReturn(null); view.addPart(viewWbPartPresenter); verify(panel).setPart(viewWbPartPresenter); }