### Question:
TreeTransformerImpl implements TreeTransformer { @Override public <E, N extends OpenMutableBinaryTreeNode<E, N>> void rotateRootInPlace(MutableBinaryTree<E, N> tree, RotationDirection direction) { if (tree.isEmpty()) { throw new IllegalArgumentException("An empty tree cannot be rotated"); } final N root = tree.getRoot(); final ParentReferenceFactory<E, N> referenceFactory = rootReferenceFactoryProvider.get(root); final ParentReference<N> reference = referenceFactory.wrap(tree); final Rotator<E, N> rotator = rotatorProvider.get(root, direction); rotator.rotate(reference, root); } TreeTransformerImpl(RootReferenceFactoryProvider rootReferenceFactoryProvider, RotatorProvider rotatorProvider); @Override void rotateRootInPlace(MutableBinaryTree<E, N> tree, RotationDirection direction); @Override void rotateInPlace(N rootParent, N rotationRoot, RotationDirection direction);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void rotateEmptyTree() { final KeyMappingProvider keyMappingProvider = KeyMappingProvider.get(); final TreeTransformerImpl transformer = new TreeTransformerImpl( new RootReferenceFactoryProviderImpl(keyMappingProvider), new RotatorProviderImpl(keyMappingProvider)); when(tree.isEmpty()).thenReturn(true); transformer.rotateRootInPlace(tree, RotationDirection.LEFT); }
@Test(expected = OperationNotSupportedForType.class) public void rotateRootInPlaceNoneFound() { final KeyMappingProvider keyMappingProvider = KeyMappingProvider.get(); final TreeTransformerImpl transformer = new TreeTransformerImpl( new RootReferenceFactoryProviderImpl(keyMappingProvider), new RotatorProviderImpl(keyMappingProvider)); transformer.rotateRootInPlace(tree, RotationDirection.LEFT); }
@Test public void rotateRootInPlaceWithMock() { when(tree.getRoot()).thenReturn(root); final TreeTransformerImpl transformer = new TreeTransformerImpl( referenceFactoryProvider, rotatorProvider); transformer.rotateRootInPlace(tree, RotationDirection.LEFT); verify(referenceFactory).wrap(tree); verify(rotator).rotate(reference, root); }