@Override public boolean moveTo(@NotNull NodeBuilder newParent, @NotNull String newName) { return exists() && builder.moveTo(newParent, newName); }
@Override public boolean moveTo(NodeBuilder newParent, String newName) { return getWrappedNodeBuilder().moveTo(newParent, newName); }
@Override public boolean moveTo(@NotNull NodeBuilder newParent, @NotNull String newName) { return exists() && builder.moveTo(newParent, newName); }
@Override public boolean moveTo(@Nonnull NodeBuilder newParent, @Nonnull String newName) { return exists() && builder.moveTo(newParent, newName); }
/** * Move this tree to the parent at {@code destParent} with the new name * {@code newName}. * @param newParent new parent for this tree * @param newName new name for this tree */ boolean moveTo(@NotNull MutableTree newParent, @NotNull String newName) { name = checkNotNull(newName); parent = checkNotNull(newParent); boolean success = nodeBuilder.moveTo(newParent.nodeBuilder, newName); if (success) { parent.updateChildOrder(false); newParent.updateChildOrder(false); } return success; }
@Test public void testMoveToSelf() { NodeBuilder rootBuilder = base.builder(); assertFalse(rootBuilder.getChildNode("y").moveTo(rootBuilder, "y")); NodeState newRoot = rootBuilder.getNodeState(); assertTrue(newRoot.hasChildNode("y")); }
@Test public void testRename() { NodeBuilder rootBuilder = base.builder(); assertTrue(rootBuilder.getChildNode("y").moveTo(rootBuilder, "yy")); NodeState newRoot = rootBuilder.getNodeState(); assertFalse(newRoot.hasChildNode("y")); assertTrue(newRoot.hasChildNode("yy")); }
@Test public void testMoveToDescendant() { NodeBuilder rootBuilder = base.builder(); assertTrue(rootBuilder.getChildNode("x").moveTo(rootBuilder.getChildNode("x"), "xx")); assertFalse(rootBuilder.hasChildNode("x")); }
@Test public void testMove() { NodeBuilder rootBuilder = base.builder(); assertTrue(rootBuilder.getChildNode("y").moveTo(rootBuilder.child("x"), "yy")); NodeState newRoot = rootBuilder.getNodeState(); assertFalse(newRoot.hasChildNode("y")); assertTrue(newRoot.hasChildNode("x")); assertTrue(newRoot.getChildNode("x").hasChildNode("q")); assertTrue(newRoot.getChildNode("x").hasChildNode("yy")); }
private static NodeBuilder move(NodeBuilder builder, String source, String dest) { NodeBuilder sourceBuilder = getBuilder(builder, source); NodeBuilder destParentBuilder = getBuilder(builder, PathUtils.getParentPath(dest)); assertTrue(sourceBuilder.moveTo(destParentBuilder, PathUtils.getName(dest))); return builder; }
@Test public void moveToSelfNonExisting() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder any = test.getChildNode("any"); assertFalse(any.moveTo(test, "any")); assertFalse(any.exists()); assertFalse(test.hasChildNode("any")); }
@Test public void renameNonExisting() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder any = test.getChildNode("any"); assertFalse(any.moveTo(test, "xx")); assertFalse(any.exists()); assertFalse(test.hasChildNode("xx")); }
@Test public void moveToSelf() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); assertFalse(x.moveTo(test, "x")); assertTrue(x.exists()); assertTrue(test.hasChildNode("x")); }
@Test public void rename() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); assertTrue(x.moveTo(test, "xx")); assertFalse(x.exists()); assertFalse(test.hasChildNode("x")); assertTrue(test.hasChildNode("xx")); }
@Test public void moveToExisting() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); assertFalse(x.moveTo(test, "y")); assertTrue(x.exists()); assertTrue(test.hasChildNode("x")); assertTrue(test.hasChildNode("y")); }
@Test public void renameToExisting() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); assertFalse(x.moveTo(test, "y")); assertTrue(x.exists()); assertTrue(test.hasChildNode("x")); assertTrue(test.hasChildNode("y")); }
@Test public void moveNonExisting() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder any = test.getChildNode("any"); NodeBuilder y = test.getChildNode("y"); assertFalse(any.moveTo(y, "xx")); assertFalse(any.exists()); assertTrue(y.exists()); assertFalse(y.hasChildNode("xx")); }
@Test public void moveNodeInSameStore() throws Exception { NodeBuilder builder = store.getRoot().builder(); NodeBuilder src = builder.child("src"); NodeBuilder dst = builder.child("dst"); boolean result = src.moveTo(dst, "src"); assertTrue("move result should be success", result); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertFalse("/src must no longer exist", store.getRoot().hasChildNode("src")); assertTrue("/dst/src must exist (composite store)", store.getRoot().getChildNode("dst").hasChildNode("src")); }
@Test @Ignore("Test ignored, since only the default store is writeable") public void moveNodeBetweenStores() throws Exception { NodeBuilder builder = store.getRoot().builder(); NodeBuilder src = builder.child("src"); NodeBuilder dst = builder.child("tmp"); boolean result = src.moveTo(dst, "src"); assertTrue("move result should be success", result); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertFalse("/src must no longer exist", store.getRoot().hasChildNode("src")); assertTrue("/tmp/src must exist (composite store)", store.getRoot().getChildNode("tmp").hasChildNode("src")); }
@Test public void move() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); NodeBuilder y = test.getChildNode("y"); assertTrue(x.moveTo(y, "xx")); assertFalse(x.exists()); assertTrue(y.exists()); assertFalse(test.hasChildNode("x")); assertTrue(y.hasChildNode("xx")); }