Package org.freeplane.plugin.script.proxy.Proxy

Examples of org.freeplane.plugin.script.proxy.Proxy.Node


    // getPlainTextContent() is deprecated - see #test_NodeRO_getPlainText()
  }

  public void test_NodeRO_getText() {
    map = c.newMap();
    final Node root = map.getRoot();
    root.setText(" xxx ");
    assertEquals("", " xxx ", root.getText());
    root.setText(" x\nxx ");
    assertEquals("", " x\nxx ", root.getText());
  }
View Full Code Here


    assertEquals("", " x\nxx ", root.getText());
  }

  public void test_NodeRO_isDescendantOf_Node_p() {
    createTestMap();
    final Node root = map.getRoot();
    assertTrue("a node is its own descendant", root.isDescendantOf(root));
    assertFalse("siblings aren't descendants of each other", firstChild(root).isDescendantOf(
        root.getChildren().get(1)));
    assertFalse("siblings aren't descendants of each other", root.getChildren().get(1).isDescendantOf(
        firstChild(root)));
    assertTrue("children are descendants of their parents", firstChild(root).isDescendantOf(root));
    final Node grandchild = firstChild(root).createChild();
    assertTrue("grandchildren are descendants of their parents", firstChild(root).isDescendantOf(root));
    assertTrue("grandchildren are descendants of their grandparents", grandchild.isDescendantOf(root));
  }
View Full Code Here

    assertTrue("grandchildren are descendants of their grandparents", grandchild.isDescendantOf(root));
  }

  public void test_NodeRO_isFolded() {
    createTestMap();
    final Node root = map.getRoot();
    final Node child = firstChild();
    final Node grandchild = child.createChild("grandchild");
    assertFalse("initially nothing should be folded", root.isFolded());
    assertFalse("initially nothing should be folded", child.isFolded());
    root.setFolded(true);
    assertFalse("root isn't foldable", root.isFolded());
    child.setFolded(true);
    assertTrue("node should be folded now", child.isFolded());
    assertFalse("folding is not recursive in terms of isFolded()", grandchild.isFolded());
    child.setFolded(false);
    assertFalse("node should be unfolded again", child.isFolded());
    grandchild.setFolded(true);
    assertFalse("a node without children is not foldable", grandchild.isFolded());
    // test undo of folding - give the new node a child first to make it foldable
    grandchild.createChild("grandgrandchild");
    grandchild.setFolded(true);
    assertTrue("node should be folded now", grandchild.isFolded());
    c.undo();
    assertFalse("folding should be undone now", grandchild.isFolded());
  }
View Full Code Here

    assertFalse("folding should be undone now", grandchild.isFolded());
  }

  public void test_NodeRO_isLeaf() {
    map = c.newMap();
    final Node root = map.getRoot();
    assertTrue("even root is a leaf, if single", root.isLeaf());
    root.createChild("child");
    assertFalse("root is never a leaf, even without children", root.isLeaf());
    assertTrue("child without children should be leaf", firstChild(root).isLeaf());
    firstChild(root).createChild("grandchild");
    assertFalse("child with children is not a leaf", firstChild(root).isLeaf());
  }
View Full Code Here

  /** copy of {@link #test_ControllerRO_find_ICondition_condition()}. */
  @SuppressWarnings("deprecation")
  public void test_NodeRO_find_ICondition_condition() {
    map = c.newMap();
    @SuppressWarnings("unused")
    final Node firstChild = map.getRoot().createChild("child 1");
    final Node secondChild = map.getRoot().createChild("child 2");
    final List<Node> found = c.find(new NodeContainsCondition(TextController.FILTER_NODE, "child 2", false));
    assertEquals("one matching node should be found", list(secondChild), found);
  }
View Full Code Here

  //  public void test_NodeRO_find_Closure_closure() {
  //   
  //  }
  public void test_NodeRO_getLastModifiedAt() {
    map = c.newMap();
    final Node child = map.getRoot().createChild("a node");
    final Date initialLastModifiedAt = child.getLastModifiedAt();
    long diff = System.currentTimeMillis() - initialLastModifiedAt.getTime();
    // one second should be enough
    assertTrue("lastModifiedAt seems to be set incorrectly. It says it's " + diff + " ms ago", //
        diff >= 0 && diff < 1000L);
    // createChild() initially set both timestamps to the same value and changes modifiedAt directly
    // afterwards in setText()
    diff = initialLastModifiedAt.getTime() - child.getCreatedAt().getTime();
    assertTrue("modifiedAt and createdAt should be set nearly to the same timestamp initially but modifiedAt = "
            + initialLastModifiedAt.getTime() + ", createdAt = " + child.getCreatedAt().getTime(), //
        diff >= 0 && diff < 50);
    final Date epoch = new Date(0);
    child.setLastModifiedAt(epoch);
    child.setText("changed");
    assertTrue("lastModifiedAt should be changed after changing the node text", //
        child.getLastModifiedAt().after(epoch));
  }
View Full Code Here

        child.getLastModifiedAt().after(epoch));
  }

  public void test_NodeRO_getCreatedAt() {
    map = c.newMap();
    final Node child = map.getRoot().createChild("a node");
    final Date initialCreatedAt = child.getCreatedAt();
    final long diff = System.currentTimeMillis() - initialCreatedAt.getTime();
    // one second should be enough
    assertTrue("createdAt seems to be set incorrectly. It says it's " + diff + " ms ago", //
        diff >= 0 && diff < 1000L);
    final Date epoch = new Date(0);
    child.setCreatedAt(epoch);
    child.setText("changed");
    assertEquals("createdAt should not be changed after changing the node text", //
        epoch, child.getCreatedAt());
  }
View Full Code Here

    assertEquals("child should be created", 1, map.getRoot().getChildren().size());
  }

  public void test_Node_createChild_int_position() {
    map = c.newMap();
    final Node root = map.getRoot();
    final Node child1 = root.createChild("child 1");
    final Node child2 = root.createChild("child 2");
    assertEquals("wrong position", 0, root.getChildPosition(child1));
    assertEquals("wrong position", 1, root.getChildPosition(child2));
    final Node child3 = root.createChild(0);
    assertEquals("wrong insert position", 0, root.getChildPosition(child3));
    assertEquals("node should be shifted", 1, root.getChildPosition(child1));
    assertEquals("node should be shifted", 2, root.getChildPosition(child2));
    final Node child4 = root.createChild(3);
    assertEquals("wrong insert position", 3, root.getChildPosition(child4));
    assertEquals("node should be shifted", 0, root.getChildPosition(child3));
    assertEquals("node should be shifted", 1, root.getChildPosition(child1));
    try {
      root.createChild(-1);
View Full Code Here

    }
  }

  public void test_Node_delete() {
    map = c.newMap();
    final Node root = map.getRoot();
    final Node child1 = root.createChild("child 1");
    final Node child2 = root.createChild("child 2");
    assertEquals("", 2, root.getChildren().size());
    child1.delete();
    assertEquals("deletion failed", 1, root.getChildren().size());
    assertEquals("wrong node deleted", child2, root.getChildren().get(0));
  }
View Full Code Here

    assertEquals("wrong node deleted", child2, root.getChildren().get(0));
  }

  public void test_Node_moveTo_Node_parentNode() {
    map = c.newMap();
    final Node root = map.getRoot();
    final Node child1 = root.createChild("child 1");
    final Node child2 = root.createChild("child 2");
    final Node grandchild = child1.createChild("grandchild");
    assertEquals("child2 should have no children", 0, child2.getChildren().size());
    grandchild.moveTo(child2);
    assertEquals("grandchild should be a child of child2 now", child2, grandchild.getParent());
  }
View Full Code Here

TOP

Related Classes of org.freeplane.plugin.script.proxy.Proxy.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.