@BeforeClass
  public static void initRelationship() throws Exception {

    // Prepare source and target
    View container =
        ViewUtil.getChildBySemanticHint(
            getDiagramView(), SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID);
    View blockStructureView =
        ViewUtil.getChildBySemanticHint(
            container, SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID);
    View actorPartSourceView =
        createGraphicalNode(
            SysMLElementTypes.ACTOR_PART_PROPERTY,
            SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID,
            blockStructureView);
    View actorPartTargetView =
        createGraphicalNode(
            SysMLElementTypes.ACTOR_PART_PROPERTY,
            SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID,
            blockStructureView);

    // Prepare relationship
    relationshipView =
        TestPrepareUtils.createGraphicalLink(
            UMLElementTypes.CONNECTOR,
            UMLGraphicalTypes.LINK_UML_CONNECTOR_ID,
            container,
            EditorUtils.getEditPart(actorPartSourceView),
            EditorUtils.getEditPart(actorPartTargetView));
  }
  @BeforeClass
  public static void prepareContainerForTest() throws Exception {
    try {
      View blockView =
          ViewUtil.getChildBySemanticHint(
              getDiagramView(), SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID);
      View blockStructureView =
          ViewUtil.getChildBySemanticHint(
              blockView, SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID);
      View partView =
          createGraphicalNode(
              UMLElementTypes.PROPERTY,
              SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID,
              blockStructureView);
      containerView =
          ViewUtil.getChildBySemanticHint(
              partView, SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID);

      if (containerView == null) {
        throw new Exception("Unable to prepare container for test.");
      }

      // Ensure the compartment is visible (required for EditPart to be found)
      if (!containerView.isVisible()) {
        changeVisibility(containerView);
      }

    } catch (Exception e) {
      throw new Exception("Unable to prepare container for test.", e);
    }
  }
  protected void createExitPoint(Edge edge, Diagram subdiagram) {
    Transition transition = (Transition) edge.getElement();
    // create semantic exit point
    Region exitPointContainer = getExitPointContainer(transition);
    Exit exitPoint = createSemanticExitPoint(transition);

    // create node for exit point
    View exitPointContainerView = helper.getViewForSemanticElement(exitPointContainer, subdiagram);
    View exitPointRegionCompartment =
        ViewUtil.getChildBySemanticHint(exitPointContainerView, SemanticHints.REGION_COMPARTMENT);
    Node exitNode =
        ViewService.createNode(
            exitPointRegionCompartment, exitPoint, SemanticHints.EXIT, preferencesHint);

    // re-wire existing transition to new exit point
    Vertex oldTarget = transition.getTarget();
    transition.setTarget(exitPoint);
    ViewService.createEdge(
        edge.getSource(), exitNode, transition, SemanticHints.TRANSITION, preferencesHint);

    // create transition from selected state to former transition target
    Transition exitPointTransition = SGraphFactory.eINSTANCE.createTransition();
    exitPointTransition.setSource((State) subdiagram.getElement());
    exitPointTransition.setTarget(oldTarget);
    ViewService.createEdge(
        getContextObject(),
        edge.getTarget(),
        exitPointTransition,
        SemanticHints.TRANSITION,
        preferencesHint);

    addExitPointSpec(exitPointTransition, exitPoint);
  }
  protected void createEntryPoint(Edge edge, Diagram subdiagram) {
    Transition transition = (Transition) edge.getElement();
    Region entryPointContainer = getEntryPointContainer(transition);
    Entry entryPoint = createSemanticEntryPoint(transition);

    // re-wire old transition to targeting the selected state
    transition.setTarget((State) subdiagram.getElement());
    View oldTarget = edge.getTarget();
    edge.setTarget(getContextObject());

    // create node for entry point
    View entryPointContainerView =
        helper.getViewForSemanticElement(entryPointContainer, subdiagram);
    View entryPointRegionCompartment =
        ViewUtil.getChildBySemanticHint(entryPointContainerView, SemanticHints.REGION_COMPARTMENT);
    Node entryNode =
        ViewService.createNode(
            entryPointRegionCompartment, entryPoint, SemanticHints.ENTRY, preferencesHint);
    ViewService.createEdge(
        entryNode,
        oldTarget,
        entryPoint.getOutgoingTransitions().get(0),
        SemanticHints.TRANSITION,
        preferencesHint);

    addEntryPointSpec(transition, entryPoint);
  }
  @BeforeClass
  public static void prepareContainerForTest() throws Exception {
    try {
      View blockView =
          ViewUtil.getChildBySemanticHint(
              getDiagramView(), SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID);
      View blockStructureView =
          ViewUtil.getChildBySemanticHint(
              blockView, SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID);
      View partView =
          createGraphicalNode(
              SysMLElementTypes.PART_PROPERTY,
              SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID,
              blockStructureView);
      View partContainerView =
          ViewUtil.getChildBySemanticHint(
              partView, SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID);
      if (partContainerView == null) {
        throw new Exception("Unable to prepare container for test.");
      }

      View nestedPartView =
          createGraphicalNode(
              UMLElementTypes.PROPERTY,
              SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID,
              partContainerView);
      containerView =
          ViewUtil.getChildBySemanticHint(
              nestedPartView, SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID);
      if (containerView == null) {
        throw new Exception("Unable to prepare nested container for test.");
      }

      // prepare container package (getDiagramView references the shown Block).
      containerPackage =
          EMFCoreUtil.getContainer(
              getDiagramView().getElement(), UMLPackage.eINSTANCE.getPackage());

    } catch (Exception e) {
      throw new Exception("Unable to prepare container for test.", e);
    }
  }
 /** Creates a new {@link Diagram} and copies child elements */
 protected Diagram createSubdiagram() {
   View contextView = getContextObject();
   State contextElement = (State) contextView.getElement();
   Diagram subdiagram =
       ViewService.createDiagram(contextElement, StatechartDiagramEditor.ID, preferencesHint);
   View figureCompartment =
       ViewUtil.getChildBySemanticHint(contextView, SemanticHints.STATE_FIGURE_COMPARTMENT);
   getResource().getContents().add(subdiagram);
   while (figureCompartment.getChildren().size() > 0) {
     subdiagram.insertChild((View) figureCompartment.getChildren().get(0));
   }
   return subdiagram;
 }
  @BeforeClass
  public static void prepareContainerForTest() throws Exception {
    try {
      createNodeFromPalette("blockdefinition.tool.interface", getDiagramView(), true);
      View blockView =
          ViewUtil.getChildBySemanticHint(
              getDiagramView(), UMLGraphicalTypes.SHAPE_UML_INTERFACE_AS_CLASSIFIER_ID);
      containerView =
          ViewUtil.getChildBySemanticHint(
              blockView, UMLGraphicalTypes.COMPARTMENT_UML_PROPERTY_AS_LIST_ID);

      if (containerView == null) {
        throw new Exception("Unable to prepare container for test.");
      }

      // Ensure the compartment is visible (required for EditPart to be found)
      if (!containerView.isVisible()) {
        changeVisibility(containerView);
      }

    } catch (Exception e) {
      throw new Exception("Unable to prepare container for test.", e);
    }
  }
  @BeforeClass
  public static void prepareContainerForTest() throws Exception {
    try {
      // force inherited provider loading...
      createGraphicalNode(
          UMLElementTypes.PACKAGE, ElementTypes.PACKAGE.getSemanticHint(), getDiagramView());

      createNodeFromPalette("blockdefinition.tool.flowspecification", getDiagramView(), true);
      containerView =
          ViewUtil.getChildBySemanticHint(
              getDiagramView(), SysMLGraphicalTypes.SHAPE_SYSML_FLOWSPECIFICATION_AS_CLASSIFIER_ID);

      if (containerView == null) {
        throw new Exception("Unable to prepare container for test.");
      }

    } catch (Exception e) {
      throw new Exception("Unable to prepare container for test.", e);
    }
  }