### Question:
ClassNameUtils { public static String toFormat(String className, TypeFormat format) { String baseName = getComponentBase(className); if (baseName.contains("/") || internalPrimitiveToBinaryName.containsKey(baseName)) { switch (format) { case INTERNAL: return className; case BINARY: return internalToBinary(className); case SOURCE: return internalToSource(className); } } else { if (className.endsWith(";")) { switch (format) { case INTERNAL: return binaryToInternal(className); case BINARY: return className; case SOURCE: return internalToSource(binaryToInternal(className)); } } else { switch (format) { case INTERNAL: return sourceToInternal(className); case BINARY: return sourceToBinary(className); case SOURCE: return className; } } } return className; }  static String binaryToInternal(String binaryName); static String getComponentBase(String className); static String getComponentType(String className); static int getDimensionCount(String className); static String getPackageName(String className); static @Nullable String getPrimitive(String className); static Class<?> getPrimitiveClass(String className); static @Nullable String getWrapper(String className); static String internalToBinary(String internalName); static String internalToSource(String internalName); static boolean isObject(String type); static boolean isPrimitive(String className); static boolean isPrimitiveOrWrapper(String className); static boolean isWrapper(String className); static String sourceToBinary(String sourceName); static String sourceToInternal(String sourceName); static String toFormat(String className, TypeFormat format); static String toInternal(Class<?> klazz); static List<String> toInternal(Class<?>... classes); static ReferenceType guessReferenceType(@Nonnull String s);  }### Answer:
@Test public void toFormatTest() { assertEquals("java.lang.Object", ClassNameUtils.toFormat("Ljava/lang/Object;", TypeFormat.SOURCE)); assertEquals("java.lang.Object", ClassNameUtils.toFormat("java.lang.Object", TypeFormat.SOURCE)); assertEquals("java.lang.Object[]", ClassNameUtils.toFormat("[Ljava.lang.Object;", TypeFormat.SOURCE)); assertEquals("SomeClass", ClassNameUtils.toFormat("LSomeClass;", TypeFormat.SOURCE)); assertEquals("SomeClass", ClassNameUtils.toFormat("SomeClass", TypeFormat.SOURCE)); assertEquals("SomeClass[]", ClassNameUtils.toFormat("[LSomeClass;", TypeFormat.SOURCE)); assertEquals("[Ljava/lang/Object;", ClassNameUtils.toFormat("java.lang.Object[]", TypeFormat.INTERNAL)); assertEquals("I", ClassNameUtils.toFormat("int", TypeFormat.INTERNAL)); assertEquals("[I", ClassNameUtils.toFormat("int[]", TypeFormat.INTERNAL)); assertEquals("[Ljava/lang/Object;", ClassNameUtils.toFormat("[Ljava.lang.Object;", TypeFormat.INTERNAL)); assertEquals("[Ljava/lang/Object;", ClassNameUtils.toFormat("[Ljava/lang/Object;", TypeFormat.INTERNAL)); assertEquals("[Ljava.lang.Object;", ClassNameUtils.toFormat("java.lang.Object[]", TypeFormat.BINARY)); assertEquals("java.lang.Object", ClassNameUtils.toFormat("java.lang.Object", TypeFormat.BINARY)); assertEquals("java.lang.Object", ClassNameUtils.toFormat("Ljava/lang/Object;", TypeFormat.BINARY)); assertEquals("int", ClassNameUtils.toFormat("I", TypeFormat.BINARY)); assertEquals("[I", ClassNameUtils.toFormat("[I", TypeFormat.BINARY)); }