@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();
  }
  /**
   * Adds the given part to the view returned by {@link #getPanelView()}, ignoring the given {@code
   * contextId}. Subclasses that care about context id's will override this method.
   */
  @Override
  public void addPart(final WorkbenchPartPresenter part, final String contextId) {

    // special case: when new perspectives are being built up based on definitions,
    // our definition will already say it contains the given part! We should not try to add it
    // again.
    if (!definition.getParts().contains(part.getDefinition())) {
      definition.addPart(part.getDefinition());
    }
    getPanelView().addPart(part.getPartView());
  }