GitBlameService { HashMap<Long, GitBlameWithUsage> getGitBlameWithUsagesByTmTextUnitId(List<GitBlameWithUsage> gitBlameWithUsages) { HashMap<Long, GitBlameWithUsage> tmTextUnitIdToGitBlameWithUsage = new HashMap(); for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { Long tmTextUnitId = gitBlameWithUsage.getTmTextUnitId(); if (tmTextUnitIdToGitBlameWithUsage.get(tmTextUnitId) == null) { tmTextUnitIdToGitBlameWithUsage.put(tmTextUnitId, gitBlameWithUsage); } else { logger.debug("Already provided, skip it for tmTextUnitId: {}", tmTextUnitId); } } return tmTextUnitIdToGitBlameWithUsage; }  List<GitBlameWithUsage> getGitBlameWithUsages(TextUnitSearcherParameters textUnitSearcherParameters); @Transactional @Pollable(async = true, message = "Save git blame information") PollableFuture saveGitBlameWithUsages(List<GitBlameWithUsage> gitBlameWithUsages);  }
@Test public void testgetGitBlameWithUsagesByTmTextUnitIdRemovesDuplicates() { List<GitBlameWithUsage> gitBlameWithUsages = new ArrayList<>(); GitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsage(); gitBlameWithUsage.setTmTextUnitId(1L); gitBlameWithUsages.add(gitBlameWithUsage); gitBlameWithUsage = new GitBlameWithUsage(); gitBlameWithUsage.setTmTextUnitId(2L); gitBlameWithUsages.add(gitBlameWithUsage); gitBlameWithUsage = new GitBlameWithUsage(); gitBlameWithUsage.setTmTextUnitId(1L); gitBlameWithUsages.add(gitBlameWithUsage); gitBlameWithUsage = new GitBlameWithUsage(); gitBlameWithUsage.setTmTextUnitId(3L); gitBlameWithUsages.add(gitBlameWithUsage); Set<Long> gitBlameWithUsagesByTmTextUnitId = gitBlameService.getGitBlameWithUsagesByTmTextUnitId(gitBlameWithUsages).keySet(); assertEquals(Sets.newHashSet(1L, 2L, 3L), gitBlameWithUsagesByTmTextUnitId); }