GitBlameService { public List<GitBlameWithUsage> getGitBlameWithUsages(TextUnitSearcherParameters textUnitSearcherParameters) { logger.debug("Get the text units required for Git blame operation"); List<TextUnitDTO> textUnitDTOS = textUnitSearcher.search(textUnitSearcherParameters); List<GitBlameWithUsage> gitBlameWithUsages = convertTextUnitsDTOsToGitBlameWithUsages(textUnitDTOS); if (!gitBlameWithUsages.isEmpty()) { enrichTextUnitsWithUsages(gitBlameWithUsages); enrichTextUnitsWithGitBlame(gitBlameWithUsages); enrichTextUnitsWithScreenshots(gitBlameWithUsages); enrichTextUnitsWithThirdPartyTextUnitId(gitBlameWithUsages); } return gitBlameWithUsages; }  List<GitBlameWithUsage> getGitBlameWithUsages(TextUnitSearcherParameters textUnitSearcherParameters); @Transactional @Pollable(async = true, message = "Save git blame information") PollableFuture saveGitBlameWithUsages(List<GitBlameWithUsage> gitBlameWithUsages);  }
@Test public void getGitBlameWithUsages() throws Exception { TMTestData tmTestData = new TMTestData(testIdWatcher); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParameters(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setForRootLocale(true); textUnitSearcherParameters.setPluralFormsFiltered(false); List<GitBlameWithUsage> gitBlameWithUsages = gitBlameService.getGitBlameWithUsages(textUnitSearcherParameters); assertEquals(3, gitBlameWithUsages.size()); logger.debug("Check none of the entry have git information"); for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { logger.info(gitBlameWithUsage.getTextUnitName()); Assert.assertNull(gitBlameWithUsage.getGitBlame()); } logger.debug("Save without info"); gitBlameService.saveGitBlameWithUsages(gitBlameWithUsages).get(); logger.debug("Save GitBlame"); for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { GitBlame gitBlame = new GitBlame(); gitBlame.setAuthorName(gitBlameWithUsage.getTextUnitName() + "-author-name"); gitBlame.setAuthorEmail(gitBlameWithUsage.getTextUnitName() + "-author-email"); gitBlame.setCommitName(gitBlameWithUsage.getTextUnitName() + "-commit-name"); gitBlame.setCommitTime(gitBlameWithUsage.getTextUnitName() + "-commit-time"); gitBlameWithUsage.setGitBlame(gitBlame); } gitBlameService.saveGitBlameWithUsages(gitBlameWithUsages).get(); List<GitBlameWithUsage> gitBlameWithUsagesAfterSave = gitBlameService.getGitBlameWithUsages(textUnitSearcherParameters); assertEquals(3, gitBlameWithUsages.size()); for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { GitBlame gitBlame = gitBlameWithUsage.getGitBlame(); assertEquals(gitBlameWithUsage.getTextUnitName() + "-author-name", gitBlame.getAuthorName()); assertEquals(gitBlameWithUsage.getTextUnitName() + "-author-email", gitBlame.getAuthorEmail()); assertEquals(gitBlameWithUsage.getTextUnitName() + "-commit-name", gitBlame.getCommitName()); assertEquals(gitBlameWithUsage.getTextUnitName() + "-commit-time", gitBlame.getCommitTime()); } logger.info("Update GitBlame"); for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { GitBlame gitBlame = new GitBlame(); gitBlame.setAuthorName(gitBlameWithUsage.getTextUnitName() + "-author-name-up"); gitBlame.setAuthorEmail(gitBlameWithUsage.getTextUnitName() + "-author-email-up"); gitBlame.setCommitName(gitBlameWithUsage.getTextUnitName() + "-commit-name-up"); gitBlame.setCommitTime(gitBlameWithUsage.getTextUnitName() + "-commit-time-up"); gitBlameWithUsage.setGitBlame(gitBlame); } gitBlameService.saveGitBlameWithUsages(gitBlameWithUsages).get(); List<GitBlameWithUsage> gitBlameWithUsagesAfterUpdate = gitBlameService.getGitBlameWithUsages(textUnitSearcherParameters); assertEquals(3, gitBlameWithUsagesAfterUpdate.size()); for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { GitBlame gitBlame = gitBlameWithUsage.getGitBlame(); assertEquals(gitBlameWithUsage.getTextUnitName() + "-author-name-up", gitBlame.getAuthorName()); assertEquals(gitBlameWithUsage.getTextUnitName() + "-author-email-up", gitBlame.getAuthorEmail()); assertEquals(gitBlameWithUsage.getTextUnitName() + "-commit-name-up", gitBlame.getCommitName()); assertEquals(gitBlameWithUsage.getTextUnitName() + "-commit-time-up", gitBlame.getCommitTime()); } }