### Question:
TypeKey { @Override public final String toString() { if (elementType == null && nodeType == null) { return "TypeKey: " + treeType.getName(); } else if (nodeType == null) { return "TypeKey: " + treeType.getName() + " : unknown : " + elementType.getName(); } else if (elementType == null) { return "TypeKey: " + treeType.getName() + " : " + nodeType.getName(); } else { return "TypeKey: " + treeType.getName() + " : " + nodeType.getName() + " : " + elementType.getName(); } } @SuppressWarnings("unchecked")  TypeKey(); final Class<T> getTreeType(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override final String toString();  }### Answer:
@Test public void testToString0() { final TypeKey<Tree<String, Node<String>>> key0 = new TypeKey<Tree<String, Node<String>>>() { }; assertTrue(key0.toString().startsWith("TypeKey")); assertTrue(key0.toString().contains(TypeKey.class.getSimpleName())); assertTrue(key0.toString().contains(String.class.getSimpleName())); assertTrue(key0.toString().contains(Node.class.getSimpleName())); }
@Test public void testToString1() { final TypeKey<TestTree> key0 = new TypeKey<TestTree>() { }; assertTrue(key0.toString().startsWith("TypeKey")); assertTrue(key0.toString().contains(TypeKey.class.getSimpleName())); assertTrue(key0.toString().contains(TestTree.class.getSimpleName())); }
@Test public void testToString2() { final TypeKey<? extends Tree<String, Node<String>>> key0 = new TypeKey<OtherTestTree<String>>() { }; assertTrue(key0.toString().startsWith("TypeKey")); assertTrue(key0.toString().contains(TypeKey.class.getSimpleName())); assertTrue(key0.toString().contains(OtherTestTree.class.getSimpleName())); }