### Question:
ImportUtils { public String formatJavaType(String typeName, boolean usePrimitives) { if (usePrimitives) { String primitive = primitivesForClasses.get(typeName); return (primitive != null) ? primitive : formatJavaType(typeName); } else { String primitiveClass = classesForPrimitives.get(typeName); return (primitiveClass != null) ? formatJavaType(primitiveClass) : formatJavaType(typeName); } }  void addReservedType(String typeName); void addType(String typeName); void setPackage(String packageName); String formatJavaType(String typeName, boolean usePrimitives); String formatJavaType(String typeName); String formatJavaTypeAsNonBooleanPrimitive(String type); boolean isNonBooleanPrimitive(String type); boolean isNumericPrimitive(String type); boolean isBoolean(String type); boolean isPrimitive(String type); boolean canUsePrimitive(ObjAttribute attribute); boolean canUsePrimitive(EmbeddableAttribute attribute); String generate(); String dbAttributeToJavaType(DbAttribute attribute); static final String[] importOrdering; }### Answer:
@Test public void testFormatJavaTypeWithPrimitives() throws Exception { assertEquals("int", importUtils.formatJavaType("int", true)); assertEquals("Integer", importUtils.formatJavaType("int", false)); assertEquals("char", importUtils.formatJavaType("char", true)); assertEquals("Character", importUtils .formatJavaType("java.lang.Character", false)); assertEquals("double", importUtils.formatJavaType("java.lang.Double", true)); assertEquals("Double", importUtils.formatJavaType("java.lang.Double", false)); assertEquals("a.b.C", importUtils.formatJavaType("a.b.C", true)); assertEquals("a.b.C", importUtils.formatJavaType("a.b.C", false)); }
@Test public void testFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs() throws Exception { final String baseType = "myType"; final String fullyQualifiedType = "org.myPackage." + baseType; assertEquals(fullyQualifiedType, importUtils.formatJavaType(fullyQualifiedType)); }
@Test public void testFormatJavaType() { assertEquals("x.X", importUtils.formatJavaType("x.X")); assertEquals("X", importUtils.formatJavaType("java.lang.X")); assertEquals("java.lang.x.X", importUtils.formatJavaType("java.lang.x.X")); }
@Test public void testJavaLangTypeFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs() throws Exception { final String baseType = "myType"; final String packageType = "java.lang"; final String fullyQualifiedType = packageType + "." + baseType; assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType)); }