TypeNameConverter { public String toAvailableInMethodName(String typeName) { Assertion.on("typeName").mustNotBeEmpty(typeName); typeName = typeName.replaceAll(RegExp.Generics, StringValue.Empty); typeName = typeName.replaceAll("final ", StringValue.Empty); typeName = typeName.replaceAll("\\.\\.\\.", "Array").replaceAll("\\[\\]", "Array"); typeName = typeName.replaceAll("\\.", StringValue.Empty); typeName = typeName.trim().split(RegExp.WhiteSpace.Consecutive_OneOrMore_Max)[0]; return typeName; } 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 toAvailableInMethodName_A$String() throws Exception { String[] argList = new String[] { "String", "hoge.foo.Var", "List<String>", "Map<String,Object>", "List<?>", "Map<?,?>" }; String[] expectedList = new String[] { "String", "hogefooVar", "List", "Map", "List", "Map" }; for (int i = 0; i < argList.length; i++) { String arg = argList[i]; String actual = target.toAvailableInMethodName(arg); String expected = expectedList[i]; assertEquals(expected + "-" + actual, expected, actual); } }
@Test public void toAvailableInMethodName_A$String_StringIsNull() throws Exception { TypeNameConverter target = new TypeNameConverter(config); String typeName = null; try { target.toAvailableInMethodName(typeName); fail(); } catch (JUnitHelperCoreException e) { } }
@Test public void toAvailableInMethodName_A$String_StringIsEmpty() throws Exception { TypeNameConverter target = new TypeNameConverter(config); String typeName = ""; try { target.toAvailableInMethodName(typeName); fail(); } catch (JUnitHelperCoreException e) { } }