PartDefinitionImpl implements
        PartDefinition { @Override public void setParentPanel(final PanelDefinition parentPanel) { if (parentPanel != null && this.parentPanel != null) { throw new IllegalStateException("Can't set parent: this part already belongs to " + this.parentPanel); } this.parentPanel = parentPanel; } PartDefinitionImpl();  PartDefinitionImpl(final PlaceRequest place); @Override PlaceRequest getPlace(); @Override void setPlace(final PlaceRequest place); @Override PanelDefinition getParentPanel(); @Override void setParentPanel(final PanelDefinition parentPanel); @Override ContextDefinition getContextDefinition(); @Override void setContextDefinition(final ContextDefinition contextDefinition); @Override ContextDisplayMode getContextDisplayMode(); @Override void setContextDisplayMode(final ContextDisplayMode contextDisplayMode); @Override boolean isSelectable(); @Override void setSelectable(final boolean selectable); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }
@Test(expected = IllegalStateException.class) public void defineParentPanelWithOldParent() throws Exception { PanelDefinitionImpl parentMock = createParentMock(); part.setParentPanel(parentMock); part.setParentPanel(anotherParent); }
@Test(expected = IllegalStateException.class) public void defineParentPanelWithOldParentWithoutPart() throws Exception { parent = createParentMock(); part.setParentPanel(parent); when(parent.getParts()).thenReturn(new HashSet<PartDefinition>()); PanelDefinitionImpl anotherParent = createParentMock(); part.setParentPanel(anotherParent); }