GitBlameCommand extends Command { List<GitBlameWithUsage> getGitBlameWithUsagesFromLine(String line, List<GitBlameWithUsage> gitBlameWithUsages, FileType fileType) { List<GitBlameWithUsage> gitBlameWithUsagesWithLine = new ArrayList<>(); if (line != null) { for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { String textUnitNameInSource = textUnitNameToTextUnitNameInSource(gitBlameWithUsage.getTextUnitName(), fileType, gitBlameWithUsage.getPluralForm() != null); if (line.contains(textUnitNameInSource)) { logger.debug("Found match for string in source file: {} in line: {}", textUnitNameInSource, line); gitBlameWithUsagesWithLine.add(gitBlameWithUsage); } } } return gitBlameWithUsagesWithLine; }  @Override void execute(); List<GitBlameWithUsage> getGitBlameWithUsagesToProcess(List<GitBlameWithUsage> gitBlameWithUsages);  }
@Test public void getTextUnitName() { String lines[] = new String[]{ "<string name=\"test_0\">Test 0</string>\n", " <string name=\"test_1\">Test 1</string>"}; GitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsage(); gitBlameWithUsage.setTextUnitName("test_0"); GitBlameWithUsage gitBlameWithUsage1 = new GitBlameWithUsage(); gitBlameWithUsage1.setTextUnitName("test_1"); List<GitBlameWithUsage> textUnitWithUsages = new ArrayList<>(); textUnitWithUsages.add(gitBlameWithUsage); textUnitWithUsages.add(gitBlameWithUsage1); GitBlameCommand gitBlameCommand = new GitBlameCommand(); for (int i = 0; i < lines.length; i++) { List<GitBlameWithUsage> gitBlameWithUsages = gitBlameCommand.getGitBlameWithUsagesFromLine(lines[i], textUnitWithUsages, new AndroidStringsFileType()); assertEquals(textUnitWithUsages.get(i), gitBlameWithUsages.get(i)); assertEquals(2, gitBlameWithUsages.size()); } }
@Test public void getTextUnitNamePlural() { String line = "<plurals name=\"plural_tests\">\n"; GitBlameWithUsage gitBlameWithUsage_zero = new GitBlameWithUsage(); gitBlameWithUsage_zero.setTextUnitName("plural_tests_zero"); GitBlameWithUsage gitBlameWithUsage_one = new GitBlameWithUsage(); gitBlameWithUsage_one.setTextUnitName("plural_tests_one"); GitBlameWithUsage gitBlameWithUsage_two = new GitBlameWithUsage(); gitBlameWithUsage_two.setTextUnitName("plural_tests_two"); GitBlameWithUsage gitBlameWithUsage_few = new GitBlameWithUsage(); gitBlameWithUsage_few.setTextUnitName("plural_tests_few"); GitBlameWithUsage gitBlameWithUsage_many = new GitBlameWithUsage(); gitBlameWithUsage_many.setTextUnitName("plural_tests_many"); GitBlameWithUsage gitBlameWithUsage_other = new GitBlameWithUsage(); gitBlameWithUsage_other.setTextUnitName("plural_tests_other"); List<GitBlameWithUsage> gitBlameWithUsagesExpected = new ArrayList<>(); gitBlameWithUsagesExpected.add(gitBlameWithUsage_zero); gitBlameWithUsagesExpected.add(gitBlameWithUsage_one); gitBlameWithUsagesExpected.add(gitBlameWithUsage_two); gitBlameWithUsagesExpected.add(gitBlameWithUsage_few); gitBlameWithUsagesExpected.add(gitBlameWithUsage_many); gitBlameWithUsagesExpected.add(gitBlameWithUsage_other); GitBlameCommand gitBlameCommand = new GitBlameCommand(); List<GitBlameWithUsage> gitBlameWithUsagesActual = gitBlameCommand.getGitBlameWithUsagesFromLine(line, gitBlameWithUsagesExpected, new AndroidStringsFileType()); for (int i = 0; i < gitBlameWithUsagesActual.size(); i++) assertEquals(gitBlameWithUsagesExpected.get(i), gitBlameWithUsagesActual.get(i)); }