TextUnitSearcher { @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) public TextUnitAndWordCount countTextUnitAndWordCount(TextUnitSearcherParameters searchParameters) throws TextUnitSearcherError { NativeCriteria c = getCriteriaForSearch(searchParameters); c.setProjection(NativeExps.projection(). addAggregateProjection("tu.id", "tu_count", NativeProjection.AggregateProjection.COUNT). addAggregateProjection("tu.word_count", "tu_word_count", NativeProjection.AggregateProjection.SUM)); try { TextUnitAndWordCount textUnitAndWordCount = c.criteriaResult(new CriteriaResultTransformerTextUnitAndWordCount()); return textUnitAndWordCount; } catch (Exception e) { logger.warn("TextUnitSearcher failed to count, query: {}", c.getQueryInfo().toString()); throw new TextUnitSearcherError(c, "count text unit", e); } }  @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) TextUnitAndWordCount countTextUnitAndWordCount(TextUnitSearcherParameters searchParameters); @Recover TextUnitAndWordCount recoverCountTextUnitAndWordCount(TextUnitSearcherError textUnitSearcherError, TextUnitSearcherParameters searchParameters); @Recover List<TextUnitDTO> recoverSearch(TextUnitSearcherError textUnitSearcherError, TextUnitSearcherParameters searchParameters); @Transactional @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters);  }
@Test public void testCountNone() throws Exception { TMTestData tmTestData = new TMTestData(testIdWatcher); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParameters(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setStatusFilter(StatusFilter.FOR_TRANSLATION); textUnitSearcherParameters.setLocaleTags(Arrays.asList("fr-FR")); textUnitSearcherParameters.setUsedFilter(UsedFilter.USED); textUnitSearcherParameters.setDoNotTranslateFilter(false); textUnitSearcherParameters.setName("name with no match"); TextUnitAndWordCount textUnitAndWordCount = textUnitSearcher.countTextUnitAndWordCount(textUnitSearcherParameters); assertEquals("Should return no text unit hence count = 0", 0, textUnitAndWordCount.getTextUnitCount()); assertEquals("Should return no text unit hence word count = 0", 0, textUnitAndWordCount.getTextUnitWordCount()); }