AbstractRotatingBinarySearchTree extends BinarySearchTree<E, N> { protected void rotateLeft(N target) { final N substitute = (N) target.getRightChild(); if (substitute == null) { throw new IllegalStateException(); } initiateRotation(target, substitute); target.setRightChild(substitute.getLeftChild()); substitute.setParent(target.getParent()); substitute.setLeftChild(target); target.setParent(substitute); } AbstractRotatingBinarySearchTree(Comparator<E> comparator, TreeNodeFactory<E, N> factory);   }
@Test public void testRotateLeft() throws Exception { final AbstractRotatingBinarySearchTree<Integer, BinaryTreeNode<Integer>> tree = tree(); tree.insert(5, 3, 7, 1, 4, 6, 9, 8, 10); final BinaryTreeNode<Integer> node = tree.find(7); tree.rotateLeft(node); assertThat(node.getParent(), is(notNullValue())); assertThat(node.getParent().getValue(), is(9)); assertThat(node.getLeftChild(), is(notNullValue())); assertThat(node.getLeftChild().getValue(), is(6)); assertThat(node.getRightChild(), is(notNullValue())); assertThat(node.getRightChild().getValue(), is(8)); }