RedBlackTree { protected Node rotateRight(Node h) { assert(h != null); Node x = h.left; h.left = x.right; x.right = h; x.color = h.color; h.color = RedBlackTree.Color.RED; x.N = h.N; h.N = 1 + size(h.left) + size(h.right); return x; }    }
@Test public void rotateRight1() { RedBlackTree<String, Integer>.Node nodeR = tester.new Node("R", 1, 6, RedBlackTree.Color.BLACK); RedBlackTree<String, Integer>.Node nodeE = tester.new Node("E", 1, 4, RedBlackTree.Color.RED); RedBlackTree<String, Integer>.Node nodeC = tester.new Node("C", 1, 2, RedBlackTree.Color.BLACK); RedBlackTree<String, Integer>.Node nodeA = tester.new Node("A", 1, 1, RedBlackTree.Color.RED); RedBlackTree<String, Integer>.Node nodeH = tester.new Node("H", 1, 1, RedBlackTree.Color.BLACK); RedBlackTree<String, Integer>.Node nodeS = tester.new Node("S", 1, 1, RedBlackTree.Color.BLACK); nodeR.left = nodeE; nodeR.right = nodeS; nodeE.left = nodeC; nodeE.right = nodeH; nodeC.left = nodeA; nodeE.right = nodeH; RedBlackTree<String, Integer>.Node nodeRRotated = tester.rotateRight(nodeR); assertEquals(nodeRRotated, nodeE); nodeE = nodeRRotated; assertEquals("E", nodeE.key); assertEquals(RedBlackTree.Color.BLACK, nodeE.color); assertEquals(6, nodeE.N); assertEquals(nodeR, nodeE.right); assertEquals(nodeC, nodeE.left); assertEquals("R", nodeR.key); assertEquals(RedBlackTree.Color.RED, nodeR.color); assertEquals(3, nodeR.N); assertEquals(nodeS, nodeR.right); assertEquals(nodeH, nodeR.left); assertEquals("H", nodeH.key); assertEquals(RedBlackTree.Color.BLACK, nodeH.color); assertEquals(1, nodeH.N); assertEquals(null, nodeH.left); assertEquals(null, nodeH.right); assertEquals("C", nodeC.key); assertEquals(RedBlackTree.Color.BLACK, nodeC.color); assertEquals(2, nodeC.N); assertEquals(nodeA, nodeC.left); assertEquals(null, nodeC.right); assertEquals("A", nodeA.key); assertEquals(RedBlackTree.Color.RED, nodeA.color); assertEquals(1, nodeA.N); assertEquals(null, nodeA.left); assertEquals(null, nodeA.right); }