Пример #1
0
 public void testHasChild() {
   assertFalse(new RootNode(null, new SequenceNumber(1)).hasChild());
   ChildNode leaf =
       new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello"));
   RootNode root = new RootNode(null, new SequenceNumber(1), leaf);
   assertTrue(root.hasChild());
 }
Пример #2
0
  public void testAllRoots() {
    RootNode root = new RootNode(null, new SequenceNumber(10));

    List roots = root.allRoots();

    assertEquals(1, roots.size());
    assertTrue(roots.contains(root));
  }
Пример #3
0
 //	testCountEmpty
 //		| root |
 //		root := RootNode edition: nil branch: 1.
 //		self should: [root count = 0]!
 //
 public void testNew() {
   BeEdition edition = new BeEdition();
   RootNode root = new RootNode(edition, new SequenceNumber(10));
   assertEquals(new SequenceNumber(10), root.getBranch());
   assertEquals(0, root.getDsp());
   assertNull(root.getChild());
   assertEquals(edition, root.getEdition());
 }
Пример #4
0
 public void testCount() {
   RootNode root =
       new RootNode(
           null,
           new SequenceNumber(1),
           new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("12345")));
   assertEquals(5, root.count());
 }
Пример #5
0
  public void testAllEditions() {
    BeEdition edition = new BeEdition();
    RootNode root = new RootNode(edition, new SequenceNumber(10));

    List editions = root.allEditions();

    assertEquals(1, editions.size());
    assertTrue(editions.contains(edition));
  }
Пример #6
0
  public void TODOtestInsertWithDsp() {
    CollectionLeaf leaf =
        new CollectionLeaf(new SequenceNumber(1), 10, AboraConverter.toAboraContent("hello"));
    BeEdition edition = new BeEdition();
    RootNode root = new RootNode(edition, new SequenceNumber(1), leaf, -9);

    root.insert(new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("ab")));

    assertTextContents("habello", root);
  }
Пример #7
0
  public void testChildren() {
    CollectionLeaf leaf =
        new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello"));
    BeEdition edition = new BeEdition();
    RootNode root = new RootNode(edition, new SequenceNumber(10), leaf);

    List children = root.children();
    assertEquals(1, children.size());
    assertTrue(children.contains(leaf));
  }
Пример #8
0
 public void testRootFor() throws Exception {
   RootNode root = new RootNode(null, new SequenceNumber(10));
   assertSame(root.rootFor(new SequenceNumber(10)), root);
   assertSame(root.rootFor(new SequenceNumber(11)), root);
   try {
     assertSame(root.rootFor(new SequenceNumber(9)), root);
     fail();
   } catch (NonCompatibleBranchException e) {
     // expected
   }
 }
Пример #9
0
  public void testDuplicateFor() {
    CollectionLeaf leaf =
        new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello"));
    BeEdition edition = new BeEdition();
    RootNode root = new RootNode(edition, new SequenceNumber(1), leaf);

    RootNode newRoot = (RootNode) root.duplicateFor(new SequenceNumber(1));

    assertSame(root, newRoot);
    assertTextContents("12345", newRoot);
  }
Пример #10
0
  public void testInsertEmpty() {
    CollectionLeaf leaf =
        new CollectionLeaf(new SequenceNumber(1), 0, AboraConverter.toAboraContent("hello"));
    BeEdition edition = new BeEdition();
    RootNode root = new RootNode(edition, new SequenceNumber(1));

    root.insert(leaf);

    assertEquals(leaf, root.getChild());
    assertEquals(1, leaf.getParents().size());
    assertTrue(leaf.getParents().contains(root));
  }
Пример #11
0
 public void testCreateWithDsp() {
   CollectionLeaf leaf =
       new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello"));
   BeEdition edition = new BeEdition();
   RootNode root = new RootNode(edition, new SequenceNumber(10), leaf, 9);
   assertEquals(new SequenceNumber(10), root.getBranch());
   assertEquals(9, root.getDsp());
   assertEquals(leaf, root.getChild());
   assertEquals(edition, root.getEdition());
   assertEquals(1, leaf.getParents().size());
   assertTrue(leaf.getParents().contains(root));
 }
Пример #12
0
  public void testInsertEmptyBadRevision() {
    CollectionLeaf leaf =
        new CollectionLeaf(new SequenceNumber(2), 1, AboraConverter.toAboraContent("hello"));
    BeEdition edition = new BeEdition();
    RootNode root = new RootNode(edition, new SequenceNumber(1));

    try {
      root.insert(leaf);
      fail("2");
    } catch (NonSameBranchException e) {
      // expecteded
    }

    assertEquals(null, root.getChild());
    assertEquals(0, leaf.getParents().size());
  }
Пример #13
0
 public void testParents() {
   ChildNode leaf =
       new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello"));
   RootNode root = new RootNode(null, new SequenceNumber(10), leaf);
   assertTrue(root.getParents().isEmpty());
 }
Пример #14
0
 public void testCountEmpty() {
   RootNode root = new RootNode(new BeEdition(), new SequenceNumber(1));
   assertEquals(0, root.count());
 }
Пример #15
0
 public void testChildrenEmpty() {
   RootNode node = new RootNode(null, new SequenceNumber(1));
   assertTrue(node.children().isEmpty());
 }