GitBlameCommand extends Command { void initGitRepository() throws CommandException { gitRepository.init(commandDirectories.getSourceDirectoryPath().toString()); }  @Override void execute(); List<GitBlameWithUsage> getGitBlameWithUsagesToProcess(List<GitBlameWithUsage> gitBlameWithUsages);  }
@Test public void getBlameResultForLines() throws Exception { Assume.assumeFalse(shallowClone); File sourceDirectory = getInputResourcesTestDir("source"); String filepath = sourceDirectory.getAbsolutePath(); GitBlameCommand gitBlameCommand = new GitBlameCommand(); gitBlameCommand.commandDirectories = new CommandDirectories(filepath); gitBlameCommand.initGitRepository(); String relativePath = gitBlameCommand.gitRepository.getDirectory().toPath().getParent().relativize(sourceDirectory.toPath()).toString(); relativePath = relativePath + "/res/values/strings.xml"; BlameResult blameResult = gitBlameCommand.gitRepository.getBlameResultForFile(relativePath); String expectedAuthor = "Liz Magalindan"; String expectedEmail = "256@holbertonschool.com"; String expectedSourceCommit = "88025e7b8b0f5d0f12f90c4ed9f86623074bc2ee"; int expectedTime = 1537477876; for (int lineNumber = 0; lineNumber < blameResult.getResultContents().size(); lineNumber++) { PersonIdent actualAuthor = blameResult.getSourceAuthor(lineNumber); RevCommit actualCommit = blameResult.getSourceCommit(lineNumber); assertEquals(expectedAuthor, actualAuthor.getName()); assertEquals(expectedEmail, actualAuthor.getEmailAddress()); assertEquals(expectedSourceCommit, actualCommit.getName()); assertEquals(expectedTime, actualCommit.getCommitTime()); } }
@Test public void getBlameResultForFileWhenFileIsMissing() throws CommandException, NoSuchFileException { GitBlameCommand gitBlameCommand = new GitBlameCommand(); gitBlameCommand.commandDirectories = new CommandDirectories(getInputResourcesTestDir().getAbsolutePath()); gitBlameCommand.initGitRepository(); BlameResult blameResult = gitBlameCommand.gitRepository.getBlameResultForFile("forSomeMissingFile"); assertNull(blameResult); }