ClassMetaExtractor { String renameIfDuplicatedToConstructorArgNames(String argName, List<String> constructorArgs, List<String> methodArgs) { if (argName == null) { return null; } if (isDuplicatedVariableName(argName)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } for (String consArg : constructorArgs) { if (argName.equals(consArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } for (String methodArg : methodArgs) { if (argName.equals(methodArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } return argName; } ClassMetaExtractor(Configuration config); ClassMeta extract(String sourceCodeString);  }
@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_target() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = "target"; List<String> constructorArgs = new ArrayList<String>(); List<String> methodArgs = new ArrayList<String>(); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = "target_"; assertEquals(expected, actual); }
@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_notDuplicated() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = "name"; List<String> constructorArgs = new ArrayList<String>(); constructorArgs.add("category"); List<String> methodArgs = new ArrayList<String>(); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = "name"; assertEquals(expected, actual); }
@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_duplicated() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = "name"; List<String> constructorArgs = new ArrayList<String>(); constructorArgs.add("name"); List<String> methodArgs = new ArrayList<String>(); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = "name_"; assertEquals(expected, actual); }
@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_duplicated2() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = "name"; List<String> constructorArgs = new ArrayList<String>(); constructorArgs.add("name"); List<String> methodArgs = new ArrayList<String>(); methodArgs.add("name_"); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = "name__"; assertEquals(expected, actual); }
@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_StringIsNull() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = null; List<String> constructorArgs = new ArrayList<String>(); List<String> methodArgs = new ArrayList<String>(); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = null; assertThat(actual, is(equalTo(expected))); }
@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_StringIsEmpty() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = ""; List<String> constructorArgs = new ArrayList<String>(); List<String> methodArgs = new ArrayList<String>(); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = ""; assertThat(actual, is(equalTo(expected))); }