@Transactional(noRollbackFor = {Throwable.class}) @Test public void testReviewNeeded() { TMTestData tmTestData = new TMTestData(testIdWatcher); List<TMTextUnitVariant> variants = tmTextUnitVariantRepository.findAllByLocale_IdAndTmTextUnit_Tm_id(tmTestData.frFR.getId(), tmTestData.tm.getId()); assertEquals("There should be 2 TMTextUnitVariants", 2, variants.size()); logger.debug("Mark one translated string as review needed"); Long reviewNeededTmTextUnitId = tmTestData.addCurrentTMTextUnitVariant1FrFR.getTmTextUnit().getId(); tmService.addTMTextUnitCurrentVariant( reviewNeededTmTextUnitId, tmTestData.addCurrentTMTextUnitVariant1FrFR.getLocale().getId(), tmTestData.addCurrentTMTextUnitVariant1FrFR.getContent(), "this translation fails compilation", TMTextUnitVariant.Status.REVIEW_NEEDED); variants = tmTextUnitVariantRepository.findAllByLocale_IdAndTmTextUnit_Tm_id(tmTestData.frFR.getId(), tmTestData.tm.getId()); assertEquals("There should be 3 TMTextUnitVariants", 3, variants.size()); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setLocaleId(tmTestData.frFR.getId()); textUnitSearcherParameters.setStatusFilter(StatusFilter.REVIEW_NOT_NEEDED); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); assertEquals("The searcher should have returned 1 included text unit DTOs", 1, textUnitDTOs.size()); for (TextUnitDTO textUnitDTO : textUnitDTOs) { assertNotEquals("The found variant should not be the one that needs review", reviewNeededTmTextUnitId, textUnitDTO.getTmTextUnitId()); } textUnitSearcherParameters.setStatusFilter(StatusFilter.REVIEW_NEEDED); textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); assertEquals("The searcher should have returned only 1 excluded text unit DTO", 1, textUnitDTOs.size()); assertEquals("The found variant should be the one that needs review", reviewNeededTmTextUnitId, textUnitDTOs.get(0).getTmTextUnitId()); }
@Transactional @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) public List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters) { NativeCriteria c = getCriteriaForSearch(searchParameters); try { logger.debug("Perform query"); List<TextUnitDTO> resultAsList = c.criteriaResult(new TextUnitDTONativeObjectMapper()); if (logger.isDebugEnabled()) { logger.debug("Query done, info: {}", c.getQueryInfo()); } return resultAsList; } catch (Exception e) { logger.warn("TextUnitSearcher failed to search, exception", e); logger.warn("TextUnitSearcher failed to search, query: {}", c.getQueryInfo().toString()); throw new TextUnitSearcherError(c, "search", e); } }
TextUnitSearcher { @Transactional @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) public List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters) { NativeCriteria c = getCriteriaForSearch(searchParameters); try { logger.debug("Perform query"); List<TextUnitDTO> resultAsList = c.criteriaResult(new TextUnitDTONativeObjectMapper()); if (logger.isDebugEnabled()) { logger.debug("Query done, info: {}", c.getQueryInfo()); } return resultAsList; } catch (Exception e) { logger.warn("TextUnitSearcher failed to search, exception", e); logger.warn("TextUnitSearcher failed to search, query: {}", c.getQueryInfo().toString()); throw new TextUnitSearcherError(c, "search", e); } } }
TextUnitSearcher { @Transactional @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) public List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters) { NativeCriteria c = getCriteriaForSearch(searchParameters); try { logger.debug("Perform query"); List<TextUnitDTO> resultAsList = c.criteriaResult(new TextUnitDTONativeObjectMapper()); if (logger.isDebugEnabled()) { logger.debug("Query done, info: {}", c.getQueryInfo()); } return resultAsList; } catch (Exception e) { logger.warn("TextUnitSearcher failed to search, exception", e); logger.warn("TextUnitSearcher failed to search, query: {}", c.getQueryInfo().toString()); throw new TextUnitSearcherError(c, "search", e); } }  }
TextUnitSearcher { @Transactional @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) public List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters) { NativeCriteria c = getCriteriaForSearch(searchParameters); try { logger.debug("Perform query"); List<TextUnitDTO> resultAsList = c.criteriaResult(new TextUnitDTONativeObjectMapper()); if (logger.isDebugEnabled()) { logger.debug("Query done, info: {}", c.getQueryInfo()); } return resultAsList; } catch (Exception e) { logger.warn("TextUnitSearcher failed to search, exception", e); logger.warn("TextUnitSearcher failed to search, query: {}", c.getQueryInfo().toString()); throw new TextUnitSearcherError(c, "search", 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); }
TextUnitSearcher { @Transactional @Retryable( value = {TextUnitSearcherError.class}, backoff = @Backoff(delay = 500, multiplier = 2)) public List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters) { NativeCriteria c = getCriteriaForSearch(searchParameters); try { logger.debug("Perform query"); List<TextUnitDTO> resultAsList = c.criteriaResult(new TextUnitDTONativeObjectMapper()); if (logger.isDebugEnabled()) { logger.debug("Query done, info: {}", c.getQueryInfo()); } return resultAsList; } catch (Exception e) { logger.warn("TextUnitSearcher failed to search, exception", e); logger.warn("TextUnitSearcher failed to search, query: {}", c.getQueryInfo().toString()); throw new TextUnitSearcherError(c, "search", 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);  }