/** 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);
    }
  }
 /**
  * Test constructor <code>AddFreeTextAction(GraphNode freeTextGraphNode, GraphNode diagram,
  * UMLModelManager modelManager)</code> for failure with freeTextGraphNode which has no semantic
  * model, <code>IllegalArgumentException</code> is expected.
  */
 public void testCtor_FreeTextGraphNodeWithoutSemanticModel() {
   GraphNode node = new GraphNode();
   node.addContained(new TextElement());
   try {
     new AddFreeTextAction(node, this.diagram, this.manager);
     fail("IllegalArgumentException is expected!");
   } catch (IllegalArgumentException e) {
     // expected
   }
 }
 /**
  * Tests constructor CutFreeTextAction(freeTextGraphNode, clipboard) if freeTextGraphNode doesn't
  * contain a semanticModel attribute (SimpleSemanticModelElement object). IllegalArgumentException
  * is expected.
  */
 public void testCtorIfFreeTextNodeNotContainSemanticModelAttribute() {
   try {
     freeTextGraphNode.addContained(new TextElement());
     new CutFreeTextAction(freeTextGraphNode, null);
     fail(
         "IllegalArgumentException is expected because freeTextGraphNode doesn't contain a semanticModel"
             + "attribute (SimpleSemanticModelElement object).");
   } catch (IllegalArgumentException e) {
     // success
   }
 }
 /**
  * Tests constructor CutFreeTextAction(freeTextGraphNode, clipboard) if freeTextGraphNode contains
  * a semanticModel attribute, but not SimpleSemanticModelElement object. IllegalArgumentException
  * is expected.
  */
 public void testCtorIfFreeTextNodeContainInvalidSemanticModelAttribute() {
   try {
     freeTextGraphNode.addContained(new TextElement());
     freeTextGraphNode.setSemanticModel(new Uml1SemanticModelBridge());
     new CutFreeTextAction(freeTextGraphNode, null);
     fail(
         "IllegalArgumentException is expected because freeTextGraphNode contains invalid semanticModel"
             + "attribute (non-SimpleSemanticModelElement object).");
   } catch (IllegalArgumentException e) {
     // success
   }
 }
 /**
  * Test constructor <code>AddFreeTextAction(GraphNode freeTextGraphNode, GraphNode diagram,
  * UMLModelManager modelManager)</code> for failure with freeTextGraphNode has bad
  * SimpleSemanticModelElement semantic model(bad typeInfo), <code>IllegalArgumentException</code>
  * is expected.
  */
 public void testCtor_FreeTextGraphNodeWithIllegalSemanticModel3() {
   GraphNode node = new GraphNode();
   SimpleSemanticModelElement ssme = new SimpleSemanticModelElement();
   ssme.setTypeInfo("NonFreeText");
   node.setSemanticModel(ssme);
   node.addContained(new TextElement());
   try {
     new AddFreeTextAction(node, this.diagram, this.manager);
     fail("IllegalArgumentException is expected!");
   } catch (IllegalArgumentException e) {
     // expected
   }
 }
 /**
  * Tests method copyToClipboard(node, clipboard) if node is null. IllegalArgumentException is
  * expected
  *
  * @throws Exception exception
  */
 public void testCopyToClipboardIfNodeNull() throws Exception {
   SimpleSemanticModelElement semanticModelBridge = new SimpleSemanticModelElement();
   semanticModelBridge.setTypeInfo("FreeText");
   freeTextGraphNode.setSemanticModel(semanticModelBridge);
   freeTextGraphNode.addContained(new TextElement());
   CutFreeTextActionExt cutFreeTextAction = new CutFreeTextActionExt(freeTextGraphNode, null);
   try {
     cutFreeTextAction.copyToClipboard(null, null);
     fail("IllegalArgumentException is expected because node cannot be null.");
   } catch (IllegalArgumentException e) {
     // success
   }
 }
 /**
  * Tests constructor CutFreeTextAction(freeTextGraphNode, clipboard) if freeTextGraphNode contains
  * a semanticModel attribute (SimpleSemanticModelElement object), but its typeInfo attribute is
  * not equal to "FreeText". IllegalArgumentException is expected.
  */
 public void testCtorITypeInfoInvalid() {
   try {
     freeTextGraphNode.addContained(new TextElement());
     SimpleSemanticModelElement semanticModelBridge = new SimpleSemanticModelElement();
     semanticModelBridge.setTypeInfo("invalid_type_info");
     freeTextGraphNode.setSemanticModel(semanticModelBridge);
     new CutFreeTextAction(freeTextGraphNode, null);
     fail(
         "IllegalArgumentException is expected because semanticModel's typeInfo is not equal "
             + "to 'FreeText'.");
   } catch (IllegalArgumentException e) {
     // success
   }
 }