@Transactional(noRollbackFor = {Throwable.class}) @Test public void testUntranslatedOrTranslationNeeded() { TMTestData tmTestData = new TMTestData(testIdWatcher); logger.debug("Mark on translated string as need review"); TMTextUnitCurrentVariant addTMTextUnitCurrentVariantReviewNeeded = tmService.addTMTextUnitCurrentVariant( tmTestData.addCurrentTMTextUnitVariant1FrFR.getTmTextUnit().getId(), tmTestData.addCurrentTMTextUnitVariant1FrFR.getLocale().getId(), tmTestData.addCurrentTMTextUnitVariant1FrFR.getContent(), "this translation is bad in context", TMTextUnitVariant.Status.TRANSLATION_NEEDED, true); List<String> localeTags = new ArrayList<>(); localeTags.add("fr-FR"); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setStatusFilter(StatusFilter.FOR_TRANSLATION); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setLocaleTags(localeTags); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); for (TextUnitDTO textUnitDTO : textUnitDTOs) { logger.debug(ToStringBuilder.reflectionToString(textUnitDTO, ToStringStyle.MULTI_LINE_STYLE)); } Iterator<TextUnitDTO> iterator = textUnitDTOs.iterator(); logger.debug("Check the entry that needs review"); TextUnitDTO next = iterator.next(); assertEquals("Comment1", next.getComment()); assertEquals(tmTestData.frFR.getId(), next.getLocaleId()); assertEquals("zuora_error_message_verify_state_province", next.getName()); assertEquals("Please enter a valid state, region or province", next.getSource()); assertEquals("Veuillez indiquer un état, une région ou une province valide.", next.getTarget()); assertEquals("fr-FR", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit1.getId(), next.getTmTextUnitId()); assertEquals(addTMTextUnitCurrentVariantReviewNeeded.getTmTextUnitVariant().getId(), next.getTmTextUnitVariantId()); assertTrue(next.isTranslated()); assertTrue(next.isUsed()); assertEquals(TMTextUnitVariant.Status.TRANSLATION_NEEDED, next.getStatus()); assertTrue(next.isIncludedInLocalizedFile()); logger.debug("Check the entry that is untranslated (no need for review, not included in the file)"); next = iterator.next(); assertEquals("Comment2", next.getComment()); assertEquals(tmTestData.frFR.getId(), next.getLocaleId()); assertEquals("TEST2", next.getName()); assertEquals("Content2", next.getSource()); assertEquals("fr-FR", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit2.getId(), next.getTmTextUnitId()); assertFalse(next.isTranslated()); assertTrue(next.isUsed()); assertEquals(TMTextUnitVariant.Status.TRANSLATION_NEEDED, next.getStatus()); assertFalse(next.isIncludedInLocalizedFile()); assertFalse(iterator.hasNext()); }
@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);  }