/** Helper method use to add some textField to the edge. */
  public void addTextFieldToEdge() {
    graphNode1 = new GraphNode();
    graphNode1.setContainer(graphEdge);
    graphNode1.setPosition(TestHelper.getWaypoint(25, 13));

    textField1 = test.addTextField(graphNode1, text, AnchorType.LeftEnding);

    graphNode2 = new GraphNode();
    graphNode2.setContainer(graphEdge);
    graphNode2.setPosition(TestHelper.getWaypoint(12, 13));

    // the anchorage will be set to (12, 10).
    textField2 = test.addTextField(graphNode2, text, AnchorType.Line);

    graphNode3 = new GraphNode();
    graphNode3.setContainer(graphEdge);
    graphNode3.setPosition(TestHelper.getWaypoint(8, 6));

    // the anchorage will be set to (7, 7).
    textField3 = test.addTextField(graphNode3, text, AnchorType.Line);

    graphNode4 = new GraphNode();
    graphNode4.setContainer(graphEdge);
    graphNode4.setPosition(TestHelper.getWaypoint(5, 7));

    textField4 = test.addTextField(graphNode4, text, AnchorType.RightEnding);
  }
  /** Set up the stress testing environment. */
  protected void setUp() {
    // create the properties map of BaseNode.
    properties = StressTestHelper.getProperties();

    // get the graphNode here.
    graphNode = StressTestHelper.getGraphNode(2);

    // create the structure of the Subsystem here.
    nameNode = new GraphNode();
    stereotypeNode = new GraphNode();
    namespaceNode = new GraphNode();

    // set the initializing size and position.
    nameNode.setPosition(StressTestHelper.createPoint(0, 0));
    nameNode.setSize(StressTestHelper.createDimension(10, 10));
    stereotypeNode.setPosition(StressTestHelper.createPoint(0, 0));
    stereotypeNode.setSize(StressTestHelper.createDimension(10, 10));
    namespaceNode.setPosition(StressTestHelper.createPoint(0, 0));
    namespaceNode.setSize(StressTestHelper.createDimension(10, 10));

    // create the NameCompartment here.
    GraphNode nameCompartment = new GraphNode();

    nameCompartment.addContained(stereotypeNode);
    nameCompartment.addContained(nameNode);
    nameCompartment.addContained(namespaceNode);

    graphNode.addContained(nameCompartment);
  }
  /**
   * Basic stress test of <code>notifyGraphNodeChange()</code> method.
   *
   * @throws Exception if if any exception occurs when testing.
   */
  public void testUseCaseNode_notifyGraphNodeChange_AbsolutePosition() throws Exception {
    GraphNode dv = new GraphNode();
    dv.setPosition(StressTestHelper.createPoint(0, 0));
    GraphNode ssNode = StressTestHelper.getGraphNode(1);
    ssNode.setSize(StressTestHelper.createDimension(400, 800));
    ssNode.setPosition(StressTestHelper.createPoint(100, 200));
    ssNode.setContainer(dv);
    graphNode.setContainer(ssNode);
    ssNode.addContained(graphNode);

    // create a use case node here.
    node = new UseCaseNode(graphNode, properties);

    // change the node and test it.
    for (int i = 0; i < LOOPTIMES; i++) {
      int width = 40 + i;
      int height = 80 + i;
      graphNode.setSize(StressTestHelper.createDimension(width, height));

      int x = 10 + i;
      int y = 20 + i;
      graphNode.setPosition(StressTestHelper.createPoint(x, y));

      // notify the node change here.
      node.notifyGraphNodeChange("node changed.");

      // check the Node here.

      // get the location to test.
      assertEquals("The notifyGraphNodeChange method is incorrect.", 105 + i, node.getLocation().x);
      assertEquals("The notifyGraphNodeChange method is incorrect.", 215 + i, node.getLocation().y);
    }
  }
 /**
  * Setup test environment.
  *
  * @throws Exception to JUnit
  */
 protected void setUp() throws Exception {
   TestHelper.loadXMLConfig(TestHelper.CONFIG_FILE);
   mapping = new PropertyMapping(VALID_NAMESPACE);
   graphNode = new GraphNode();
   usmb = new Uml1SemanticModelBridge();
   usmb.setElement(new CommentImpl());
   graphNode.setSemanticModel(usmb);
   graphNode.setPosition(new com.topcoder.diagraminterchange.Point());
   graphNode.setSize(new com.topcoder.diagraminterchange.Dimension());
   node = new CommentNode(graphNode, mapping);
   connector = new CommentConnector(node);
 }
  /** Accuracy Test of the <code>addTextField()</code> method. */
  public void testAddTextField_RightEnding() {
    graphNode.setPosition(TestHelper.getWaypoint(5, 7));

    TextField textField = test.addTextField(graphNode, text, AnchorType.RightEnding);
    // get the contained graphNode to check the constructor.
    assertEquals("The contained graphNode should be equals.", graphNode, textField.getGraphNode());

    // get the anchorage point.
    Point anchorage = textField.getAnchorage();
    //  get the position of the anchorage point to check the method.
    assertEquals("The anchorage point should be at (30, 0).", 30, anchorage.x);
    assertEquals("The anchorage point should be at (0, 0).", 0, anchorage.y);
  }
  /** Accuracy Test of the <code>addTextField()</code> method. */
  public void testAddTextField_Line() {
    graphNode.setPosition(TestHelper.getWaypoint(12, 13));
    graphNode.setContainer(graphEdge);

    TextField textField = test.addTextField(graphNode, text, AnchorType.Line);
    // get the contained graphNode to check the constructor.
    assertEquals("The contained graphNode should be equals.", graphNode, textField.getGraphNode());

    // get the anchorage point.
    Point anchorage = textField.getAnchorage();
    //  get the position of the anchorage point to check the method.
    assertEquals("The anchorage point should be at (12, 10).", 12, anchorage.x);
    assertEquals("The anchorage point should be at (12, 10).", 10, anchorage.y);
  }