/**
   * Test method <code>void updateName(GraphElement newElement) </code>.
   *
   * <p>In this test case, the logic is simple. First creat a valid GraphNode instance. Set the
   * visible to true (the default value should be false), and expected that the extractor graph
   * element has the visible value of true.
   *
   * <p>For update, an element with visible false is created and should be updated correctly.
   *
   * <p>Also the dimension size should be updated too.
   *
   * @throws Exception to junit.
   */
  public void testUpdateName() throws Exception {
    GraphEdge root = HelperUtil.createGraphEdgeInstance();

    extractor = new DefaultEdgeCompartmentExtractor(root);

    GraphNode back = (GraphNode) extractor.extractName();
    assertTrue("The visible should be true for this GraphElement.", back.isVisible());

    GraphNode node = new GraphNode();

    SimpleSemanticModelElement semanticModel = new SimpleSemanticModelElement();
    semanticModel.setTypeinfo(EnumUtil.NAME);

    node.setSemanticModel(semanticModel);

    Dimension dimension = new Dimension();
    dimension.setHeight(new Double(10));
    dimension.setWidth(new Double(100));

    node.setSize(dimension);

    // update the Name compartment.
    extractor.updateName(node);

    back = (GraphNode) extractor.extractName();

    assertFalse("The visible should be false as it is updated.", back.isVisible());

    // check the dimension size.

    Dimension d = back.getSize();

    assertTrue("The height should be 10.", d.getHeight() == 10);
    assertTrue("The width should be 100.", d.getWidth() == 100);
  }
  /**
   * Test method <code>GraphElement extractStereotype() </code>.
   *
   * <p>Mainly check the size of the stereotype node.
   *
   * @throws Exception to junit.
   */
  public void testExtractStereotype() throws Exception {
    GraphEdge root = HelperUtil.createGraphEdgeInstance();

    extractor = new DefaultEdgeCompartmentExtractor(root);

    GraphNode back = (GraphNode) extractor.extractStereotype();

    Dimension d = back.getSize();

    assertTrue("The height should be 100.", d.getHeight() == 100);
    assertTrue("The width should be 1000.", d.getWidth() == 1000);
  }
  /**
   * Test method <code>void updateStereotype(GraphElement newElement) </code>.
   *
   * @throws Exception to junit.
   */
  public void testUpdateStereotype() throws Exception {

    GraphEdge root = HelperUtil.createGraphEdgeInstance();

    extractor = new DefaultEdgeCompartmentExtractor(root);

    GraphNode back = (GraphNode) extractor.extractStereotype();

    Dimension d = back.getSize();

    assertTrue("The height should be 100.", d.getHeight() == 100);
    assertTrue("The width should be 1000.", d.getWidth() == 1000);

    GraphNode node = new GraphNode();

    SimpleSemanticModelElement semanticModel = new SimpleSemanticModelElement();
    semanticModel.setTypeinfo(EnumUtil.STEREOTYPE_COMPARTMENT);

    node.setSemanticModel(semanticModel);

    Dimension dimension = new Dimension();
    dimension.setHeight(new Double(10));
    dimension.setWidth(new Double(100));

    node.setSize(dimension);

    // update the stereotype node.
    extractor.updateStereotype(node);

    back = (GraphNode) extractor.extractStereotype();

    d = back.getSize();

    assertTrue("The height should be 10.", d.getHeight() == 10);
    assertTrue("The width should be 100.", d.getWidth() == 100);
  }