RepositoryStatisticService { public RepositoryLocaleStatistic computeLocaleStatistics(RepositoryLocale repositoryLocale) { logger.debug("Compute locale statistic for repositoryLocale id: {}", repositoryLocale.getId()); Query createNativeQuery = entityManager.createNamedQuery("RepositoryLocaleStatistic.computeLocaleStatistics"); createNativeQuery.setParameter(1, repositoryLocale.getId()); RepositoryLocaleStatistic repositoryLocaleStatistic = (RepositoryLocaleStatistic) createNativeQuery.getSingleResult(); logger.debug("Replace POJO with a reference object"); repositoryLocaleStatistic.setLocale(repositoryLocale.getLocale()); repositoryLocaleStatistic.setDiffToSourcePluralCount(computeDiffToSourceLocaleCount(repositoryLocale.getLocale().getBcp47Tag())); TextUnitAndWordCount countTextUnitAndWordCount = getForTranslationStatistics(repositoryLocale); repositoryLocaleStatistic.setForTranslationCount(countTextUnitAndWordCount.getTextUnitCount()); repositoryLocaleStatistic.setForTranslationWordCount(countTextUnitAndWordCount.getTextUnitWordCount()); return repositoryLocaleStatistic; }  void updateStatistics(Long repositoryId); RepositoryStatistic computeBaseStatistics(Long repositoryId); RepositoryLocaleStatistic computeLocaleStatistics(RepositoryLocale repositoryLocale);  }
@Test public void testComputeLocaleStatistics() throws Exception { TMTestData tmTestData = new TMTestData(testIdWatcher); logger.debug("Mark one translated string as not included and needs review"); tmService.addTMTextUnitCurrentVariant( tmTestData.addCurrentTMTextUnitVariant1FrFR.getTmTextUnit().getId(), tmTestData.frFR.getId(), tmTestData.addCurrentTMTextUnitVariant1FrFR.getContent(), "this translation fails compilation", TMTextUnitVariant.Status.REVIEW_NEEDED, false); tmService.addTMTextUnitCurrentVariant( tmTestData.addCurrentTMTextUnitVariant1KoKR.getTmTextUnit().getId(), tmTestData.koKR.getId(), tmTestData.addCurrentTMTextUnitVariant1KoKR.getContent(), "this translation fails compilation", TMTextUnitVariant.Status.TRANSLATION_NEEDED, true); RepositoryLocaleStatistic repositoryLocaleStatisticFrFR = repositoryStatisticService.computeLocaleStatistics(tmTestData.repoLocaleFrFR); RepositoryLocaleStatistic repositoryLocaleStatisticKoKR = repositoryStatisticService.computeLocaleStatistics(tmTestData.repoLocaleKoKR); checkRepositoryLocaleStatistic(repositoryLocaleStatisticFrFR, "fr-FR", 1, 8, 0, 0, 1, 8, 0, 0); checkRepositoryLocaleStatistic(repositoryLocaleStatisticKoKR, "ko-KR", 1, 8, 1, 8, 0, 0, 1, 8); }