TypeNameConverter { public String toCompilableType(String typeName, List<String> importedList, String callerClassPackageName) { return toCompilableType(typeName, null, importedList, callerClassPackageName); } TypeNameConverter(Configuration config); String toAvailableInMethodName(String typeName); String toCompilableType(String typeName, List<String> importedList, String callerClassPackageName); String toCompilableType(String typeName, List<String> generics, List<String> importedList,
            String callerClassPackageName);  }
@Test public void toCompilableType_A$List$List$String() throws Exception { String[] argList = new String[] { "String", "hoge.foo.Var", "List<String>", "Map<String,Object>", "List<?>", "Map<?,?>" }; String[] expectedList = new String[] { "String", "hoge.foo.Var", "List", "Map", "List", "Map" }; List<String> importedList = new ArrayList<String>(); importedList.add("java.util.List"); importedList.add("java.util.Map"); for (int i = 0; i < argList.length; i++) { String className = argList[i]; String actual = target.toCompilableType(className, importedList, null); String expected = expectedList[i]; assertEquals(i + "," + expected + "-" + actual, expected, actual); } }
@Test public void toCompilableType_A$String$List$String() throws Exception { Configuration config = new Configuration(); TypeNameConverter target = new TypeNameConverter(config); String packageName = null; String className = "InputStream"; List<String> importedList = new ArrayList<String>(); importedList.add("java.io.InputStream"); String actual = target.toCompilableType(className, importedList, packageName); String expected = "InputStream"; assertEquals(expected, actual); }
@Test public void toCompilableType_A$String$List$String_WildcardImport() throws Exception { Configuration config = new Configuration(); TypeNameConverter target = new TypeNameConverter(config); String packageName = null; String className = "InputStream"; List<String> importedList = new ArrayList<String>(); importedList.add("java.io.*"); String actual = target.toCompilableType(className, importedList, packageName); String expected = "InputStream"; assertEquals(expected, actual); }
@Test public void toCompilableType_A$String$List$List$String() throws Exception { Configuration config = null; TypeNameConverter target = new TypeNameConverter(config); String packageName = null; String className = "List"; List<String> generics = new ArrayList<String>(); generics.add("String"); List<String> importedList = new ArrayList<String>(); importedList.add("java.util.List"); String actual = target.toCompilableType(className, generics, importedList, packageName); String expected = "List<String>"; assertEquals(expected, actual); }
@Test public void toCompilableType_A$String$List$String_StringIsNull() throws Exception { TypeNameConverter target = new TypeNameConverter(config); String typeName = null; List<String> importedList = new ArrayList<String>(); String callerClassPackageName = null; String actual = target.toCompilableType(typeName, importedList, callerClassPackageName); String expected = null; assertThat(actual, is(equalTo(expected))); }
@Test public void toCompilableType_A$String$List$String_StringIsEmpty() throws Exception { TypeNameConverter target = new TypeNameConverter(config); String typeName = ""; List<String> importedList = new ArrayList<String>(); String callerClassPackageName = ""; String actual = target.toCompilableType(typeName, importedList, callerClassPackageName); String expected = "Object"; assertThat(actual, is(equalTo(expected))); }
@Test public void toCompilableType_A$String$List$List$String_StringIsNull() throws Exception { TypeNameConverter target = new TypeNameConverter(config); String typeName = null; List<String> generics = new ArrayList<String>(); List<String> importedList = new ArrayList<String>(); String callerClassPackageName = null; String actual = target.toCompilableType(typeName, generics, importedList, callerClassPackageName); String expected = null; assertThat(actual, is(equalTo(expected))); }
@Test public void toCompilableType_A$String$List$List$String_StringIsEmpty() throws Exception { TypeNameConverter target = new TypeNameConverter(config); String typeName = ""; List<String> generics = new ArrayList<String>(); List<String> importedList = new ArrayList<String>(); String callerClassPackageName = ""; String actual = target.toCompilableType(typeName, generics, importedList, callerClassPackageName); String expected = "Object"; assertThat(actual, is(equalTo(expected))); }