### Question:
ZkTreeNode extends DefaultTreeNode<E> { public ZkTreeNode<E> moveTo(@Nonnull TreeNode<E> destinationNode) { TreeNode<E> moveFrom = getParent(); if (moveFrom == destinationNode) { return this; } else if (moveFrom != null) { moveFrom.remove(this); } destinationNode.add(this); return this; } ZkTreeNode(E data, TreeNode<E>... children);  ZkTreeNode(E data, Collection<? extends TreeNode<E>> children);  ZkTreeNode(E data); ZkTreeNode<E> moveTo(@Nonnull TreeNode<E> destinationNode); ZkTreeNode<E> select();  }### Answer:
@Test @SuppressWarnings ("unchecked") public void testMoveNode() throws Exception { TreeNode<String> moveFrom = new ZkTreeNode<String>("b", sut); TreeNode<String> destination = new DefaultTreeNode<String>("c", new ArrayList<TreeNode<String>>()); sut.moveTo(destination); assertSame(sut.getParent(), destination); assertNotSame(sut, moveFrom); }
@Test public void testMoveNodeWithoutParent() throws Exception { TreeNode<String> destination = new DefaultTreeNode<String>("g", new ArrayList<TreeNode<String>>()); sut.moveTo(destination); assertSame(sut.getParent(), destination); }
@Test @SuppressWarnings ("unchecked") public void testMoveNodeToTheSameParent() throws Exception { TreeNode<String> moveFrom = new DefaultTreeNode<String>("d", asList(sut)); sut.moveTo(moveFrom); assertSame(sut.getParent(), moveFrom); }