BranchStatisticService { long getForTranslationCount(long tmTextUnitId) { TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParameters(); textUnitSearcherParameters.setTmTextUnitIds(tmTextUnitId); textUnitSearcherParameters.setStatusFilter(FOR_TRANSLATION); textUnitSearcherParameters.setToBeFullyTranslatedFilter(true); TextUnitAndWordCount textUnitAndWordCount = textUnitSearcher.countTextUnitAndWordCount(textUnitSearcherParameters); return textUnitAndWordCount.getTextUnitCount(); }  void computeAndSaveBranchStatistics(Long repositoryId); void computeAndSaveBranchStatistics(Branch branch); List<TextUnitDTO> getTextUnitDTOsForBranch(Branch branch);  }
@Test public void getForTranslationCount() throws Exception { BranchTestData branchTestData = new BranchTestData(testIdWatcher); Branch branch1 = branchTestData.getBranch1(); Branch branch2 = branchTestData.getBranch2(); RepositoryLocale repositoryLocaleFrFr = branchTestData.getRepositoryLocaleFrFr(); RepositoryLocale repositoryLocaleJaJp = branchTestData.getRepositoryLocaleJaJp(); Asset asset = branchTestData.getAsset(); Long tmTextUnitId = tmTextUnitRepository.findFirstByAssetAndName(asset, "string3").getId(); long forTranslationCount = branchStatisticService.getForTranslationCount(tmTextUnitId); assertEquals(2L, forTranslationCount); logger.debug("Add translation for french, expect for translation count to change"); tmService.importLocalizedAssetAsync(asset.getId(), "string3=content3_fr-FR", repositoryLocaleFrFr.getLocale().getId(), APPROVED, null, null).get(); assertEquals(1L, branchStatisticService.getForTranslationCount(tmTextUnitId)); logger.debug("Add translation for french, expect for translation count to change"); tmService.importLocalizedAssetAsync(asset.getId(), "string3=content3_ja-JP", repositoryLocaleJaJp.getLocale().getId(), APPROVED, null, null).get(); assertEquals(0L, branchStatisticService.getForTranslationCount(tmTextUnitId)); }