### Question:
RedBlackTree { public RedBlackNode<K,V> upperBound(K key){ RedBlackNode<K,V> bestNode = null; RedBlackNode<K,V> node = root; while (node != null) { int result = comparator.compare(key, node.key); if (result < 0) { bestNode = node; node = node.left; } else { node = node.right; } } return bestNode; } RedBlackTree(Comparator<K> comparator, boolean allowDuplicateKeys);  RedBlackTree(RedBlackTree<K, V> tree); @Override String toString(); int size(); boolean containsKey(K key); RedBlackNode<K,V> getFirst(); RedBlackNode<K,V> getLast(); RedBlackNode<K,V> lowerBound(K key); RedBlackNode<K,V> upperBound(K key); Pair<RedBlackNode<K, V>, Boolean> put(K key, V value); RedBlackNode<K,V> findFirstNode(K key); RedBlackNode<K,V> findLastNode(K key); V remove(K key); void removeAll(); boolean isEmpty(); void deleteEntry(RedBlackNode<K,V> p); static final String EOL; }### Answer:
@Test public void testUpperBound() { RedBlackNode<Integer,String> node = tree.upperBound(-1); assertEquals(1, (int)node.getKey()); node = tree.upperBound(2); assertEquals(3, (int)node.getKey()); node = tree.upperBound(7); assertEquals(9, (int)node.getKey()); node = tree.upperBound(8); assertEquals(9, (int)node.getKey()); node = tree.upperBound(10); assertEquals(null, node); node = tree.upperBound(20); assertEquals(null, node); node = treeWithDups.upperBound(-1); assertEquals(1, (int)node.getKey()); node = treeWithDups.upperBound(2); assertEquals(3, (int)node.getKey()); node = treeWithDups.upperBound(7); assertEquals(9, (int)node.getKey()); node = treeWithDups.upperBound(4); assertEquals(5, (int)node.getKey()); assertEquals("five", node.getValue()); node = treeWithDups.upperBound(8); assertEquals(9, (int)node.getKey()); node = treeWithDups.upperBound(10); assertEquals(null, node); node = treeWithDups.upperBound(20); assertEquals(null, node); }