@Test public void removeAllTest() throws PreconditionException, IOException { StandardSizeCalculator sdc = new StandardSizeCalculator(true); long s1 = sdc.serializ(tree); long s2 = sdc.serializ(tree2); long s3 = sdc.serializ(tree3); assertTrue(s3 < s1); assertTrue(s3 < s2); CRDTMessage mess1 = tree2.remove(Arrays.asList(0, 1, 0)); // f CRDTMessage mess2 = tree2.remove(Arrays.asList(2, 1)); // h CRDTMessage mess3 = tree2.remove(Arrays.asList(2, 0)); // g CRDTMessage mess4 = tree2.remove(Arrays.asList(0, 1)); // e CRDTMessage mess5 = tree2.remove(Arrays.asList(0, 0)); // d CRDTMessage mess6 = tree2.remove(Arrays.asList(2)); // c CRDTMessage mess7 = tree2.remove(Arrays.asList(1)); // b CRDTMessage mess8 = tree2.remove(Arrays.asList(0)); // a tree.applyOneRemote(mess1); tree.applyOneRemote(mess4); tree.applyOneRemote(mess5); tree.applyOneRemote(mess6); tree.applyOneRemote(mess3); tree.applyOneRemote(mess7); tree.applyOneRemote(mess8); tree.applyOneRemote(mess2); assertEquals("null", tree.getRoot().nodetail()); assertEquals("null", tree2.getRoot().nodetail()); long sa1 = sdc.serializ(tree); long sa2 = sdc.serializ(tree2); assertEquals(s3, sa1); assertEquals(s3, sa2); }
@Test public void removeAll2Test() throws Exception { tree.setRemoveEntireSubtree(true); tree2.setRemoveEntireSubtree(true); StandardSizeCalculator sdc = new StandardSizeCalculator(true); long s1 = sdc.serializ(tree); long s2 = sdc.serializ(tree2); long s3 = sdc.serializ(tree3); assertTrue(s3 < s1); assertTrue(s3 < s2); CRDTMessage mess1 = tree2.remove(Arrays.asList(0)); // f CRDTMessage mess2 = tree2.remove(Arrays.asList(0)); // f CRDTMessage mess3 = tree2.remove(Arrays.asList(0)); // f tree.applyRemote(mess1); tree.applyRemote(mess3); tree.applyRemote(mess2); assertEquals("null", tree2.getRoot().nodetail()); assertEquals("null", tree.getRoot().nodetail()); long sa1 = sdc.serializ(tree); long sa2 = sdc.serializ(tree2); assertEquals(1, tree.map.size()); assertEquals(1, tree2.map.size()); assertEquals(s3, sa1); assertEquals(s3, sa2); }
@Test public void removeTest() throws PreconditionException { CRDTMessage m = tree2.remove(Arrays.asList(0, 1)); tree.applyOneRemote(m); assertEquals("null{a{d,},b,c{g,h,},}", tree.getRoot().nodetail()); assertEquals("null{a{d,},b,c{g,h,},}", tree2.getRoot().nodetail()); }