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);  }
@Transactional @Test public void testAllFilters() { TMTestData tmTestData = new TMTestData(testIdWatcher); List<String> localeTags = new ArrayList<>(); localeTags.add("ko-KR"); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setName("zuora_error_message_verify_state_province"); textUnitSearcherParameters.setLocaleTags(localeTags); textUnitSearcherParameters.setTarget("올바른 국가, 지역 또는 시/도를 입력하십시오."); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setSource("Please enter a valid state, region or province"); textUnitSearcherParameters.setUsedFilter(UsedFilter.USED); textUnitSearcherParameters.setStatusFilter(StatusFilter.TRANSLATED); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); for (TextUnitDTO textUnitDTO : textUnitDTOs) { logger.debug(ToStringBuilder.reflectionToString(textUnitDTO, ToStringStyle.MULTI_LINE_STYLE)); } Iterator<TextUnitDTO> iterator = textUnitDTOs.iterator(); TextUnitDTO next = iterator.next(); assertEquals(tmTestData.asset.getId(), next.getAssetId()); assertEquals("Comment1", next.getComment()); assertEquals(tmTestData.koKR.getId(), next.getLocaleId()); assertEquals("zuora_error_message_verify_state_province", next.getName()); assertEquals("Please enter a valid state, region or province", next.getSource()); assertEquals("올바른 국가, 지역 또는 시/도를 입력하십시오.", next.getTarget()); assertEquals("ko-KR", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit1.getId(), next.getTmTextUnitId()); assertEquals(tmTestData.addCurrentTMTextUnitVariant1KoKR.getId(), next.getTmTextUnitVariantId()); assertTrue(next.isTranslated()); assertTrue(next.isUsed()); assertFalse(iterator.hasNext()); }
@Transactional @Test public void testMultipleLocalesTranslatedAndUntranslated() { TMTestData tmTestData = new TMTestData(testIdWatcher); List<String> localeTags = new ArrayList<>(); localeTags.add("ko-KR"); localeTags.add("fr-FR"); localeTags.add("fr-CA"); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setName("zuora_error_message_verify_state_province"); textUnitSearcherParameters.setLocaleTags(localeTags); textUnitSearcherParameters.setSource("Please enter a valid state, region or province"); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); for (TextUnitDTO textUnitDTO : textUnitDTOs) { logger.debug(ToStringBuilder.reflectionToString(textUnitDTO, ToStringStyle.MULTI_LINE_STYLE)); } Iterator<TextUnitDTO> iterator = textUnitDTOs.iterator(); TextUnitDTO next = iterator.next(); assertEquals(tmTestData.asset.getId(), next.getAssetId()); 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(tmTestData.addCurrentTMTextUnitVariant1FrFR.getId(), next.getTmTextUnitVariantId()); assertTrue(next.isTranslated()); assertTrue(next.isUsed()); next = iterator.next(); assertEquals(tmTestData.asset.getId(), next.getAssetId()); assertEquals("Comment1", next.getComment()); assertEquals(tmTestData.frCA.getId(), next.getLocaleId()); assertEquals("zuora_error_message_verify_state_province", next.getName()); assertEquals("Please enter a valid state, region or province", next.getSource()); assertEquals(null, next.getTarget()); assertEquals("fr-CA", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit1.getId(), next.getTmTextUnitId()); assertEquals(null, next.getTmTextUnitVariantId()); assertFalse(next.isTranslated()); assertTrue(next.isUsed()); next = iterator.next(); assertEquals(tmTestData.asset.getId(), next.getAssetId()); assertEquals("Comment1", next.getComment()); assertEquals(tmTestData.koKR.getId(), next.getLocaleId()); assertEquals("zuora_error_message_verify_state_province", next.getName()); assertEquals("Please enter a valid state, region or province", next.getSource()); assertEquals("올바른 국가, 지역 또는 시/도를 입력하십시오.", next.getTarget()); assertEquals("ko-KR", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit1.getId(), next.getTmTextUnitId()); assertEquals(tmTestData.addCurrentTMTextUnitVariant1KoKR.getId(), next.getTmTextUnitVariantId()); assertTrue(next.isTranslated()); assertTrue(next.isUsed()); assertFalse(iterator.hasNext()); }
@Transactional @Test public void testUnusedAndTranslated() { TMTestData tmTestData = new TMTestData(testIdWatcher); List<String> localeTags = new ArrayList<>(); localeTags.add("ko-KR"); localeTags.add("fr-FR"); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setLocaleTags(localeTags); textUnitSearcherParameters.setStatusFilter(StatusFilter.TRANSLATED); textUnitSearcherParameters.setUsedFilter(UsedFilter.UNUSED); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); for (TextUnitDTO textUnitDTO : textUnitDTOs) { logger.debug(ToStringBuilder.reflectionToString(textUnitDTO, ToStringStyle.MULTI_LINE_STYLE)); } Iterator<TextUnitDTO> iterator = textUnitDTOs.iterator(); TextUnitDTO next = iterator.next(); assertEquals("Comment3", next.getComment()); assertEquals(tmTestData.frFR.getId(), next.getLocaleId()); assertEquals("TEST3", next.getName()); assertEquals("Content3", next.getSource()); assertEquals("Content3 fr-FR", next.getTarget()); assertEquals("fr-FR", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit3.getId(), next.getTmTextUnitId()); assertEquals(tmTestData.addCurrentTMTextUnitVariant3FrFR.getId(), next.getTmTextUnitVariantId()); assertTrue(next.isTranslated()); assertFalse(next.isUsed()); assertFalse(iterator.hasNext()); }
@Transactional @Test public void testPagination() { TMTestData tmTestData = new TMTestData(testIdWatcher); List<String> localeTags = new ArrayList<>(); localeTags.add("ko-KR"); localeTags.add("fr-FR"); localeTags.add("fr-CA"); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParametersForTesting(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setLocaleTags(localeTags); textUnitSearcherParameters.setLimit(2); textUnitSearcherParameters.setOffset(2); List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters); for (TextUnitDTO textUnitDTO : textUnitDTOs) { logger.debug(ToStringBuilder.reflectionToString(textUnitDTO, ToStringStyle.MULTI_LINE_STYLE)); } Iterator<TextUnitDTO> iterator = textUnitDTOs.iterator(); TextUnitDTO next = iterator.next(); assertEquals("Comment1", next.getComment()); assertEquals(tmTestData.koKR.getId(), next.getLocaleId()); assertEquals("zuora_error_message_verify_state_province", next.getName()); assertEquals("Please enter a valid state, region or province", next.getSource()); assertEquals("올바른 국가, 지역 또는 시/도를 입력하십시오.", next.getTarget()); assertEquals("ko-KR", next.getTargetLocale()); assertEquals(tmTestData.addTMTextUnit1.getId(), next.getTmTextUnitId()); assertEquals(tmTestData.addCurrentTMTextUnitVariant1KoKR.getId(), next.getTmTextUnitVariantId()); assertTrue(next.isTranslated()); assertTrue(next.isUsed()); 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()); assertFalse(iterator.hasNext()); }
@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 @Test public void testIncludedInLocalizedFile() { 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 not included"); Long invalidTmTextUnitId = tmTestData.addCurrentTMTextUnitVariant1FrFR.getTmTextUnit().getId(); tmService.addTMTextUnitCurrentVariant( invalidTmTextUnitId, tmTestData.addCurrentTMTextUnitVariant1FrFR.getLocale().getId(), tmTestData.addCurrentTMTextUnitVariant1FrFR.getContent(), "this translation fails compilation", TMTextUnitVariant.Status.REVIEW_NEEDED, false); 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.NOT_REJECTED); 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 invalid one", invalidTmTextUnitId, textUnitDTO.getTmTextUnitId()); } textUnitSearcherParameters.setStatusFilter(StatusFilter.REJECTED); 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 invalid one", invalidTmTextUnitId, textUnitDTOs.get(0).getTmTextUnitId()); }
@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()); }
@Test public void testCreatedDate() throws Exception { DateTime now = DateTime.now(); DateTime secondsBefore = now.minusSeconds(2); DateTime secondsAfter = now.plusSeconds(2); TMTestData tmTestData = new TMTestData(testIdWatcher); TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParameters(); textUnitSearcherParameters.setRepositoryIds(tmTestData.repository.getId()); textUnitSearcherParameters.setUsedFilter(UsedFilter.USED); List<TextUnitDTO> search = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(8, search.size()); textUnitSearcherParameters.setTmTextUnitCreatedBefore(secondsBefore); search = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(0, search.size()); textUnitSearcherParameters.setTmTextUnitCreatedAfter(secondsBefore); textUnitSearcherParameters.setTmTextUnitCreatedBefore(null); search = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(8, search.size()); textUnitSearcherParameters.setTmTextUnitCreatedAfter(secondsBefore); textUnitSearcherParameters.setTmTextUnitCreatedBefore(secondsAfter); search = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(8, search.size()); textUnitSearcherParameters.setTmTextUnitCreatedAfter(secondsAfter); textUnitSearcherParameters.setTmTextUnitCreatedBefore(null); search = textUnitSearcher.search(textUnitSearcherParameters); assertEquals(0, search.size()); }
@Test public void testSkipAssetPathWithPattern() { TMTestData testData = new TMTestData(testIdWatcher); TextUnitSearcherParameters params = new TextUnitSearcherParameters(); params.setRepositoryIds(testData.repository.getId()); params.setSkipAssetPathWithPattern("%skip_me"); Asset asset = assetService.createAssetWithContent(testData.repository.getId(), "fake_skip_me", "fake for test other tm repo"); TMTextUnit tu1 = tmService.addTMTextUnit(testData.tm.getId(), asset.getId(), "fake1", "Content1", "Comment1"); TMTextUnit tu2 = tmService.addTMTextUnit(testData.tm.getId(), asset.getId(), "fake2", "Content2", "Comment2"); TMTextUnit tu3 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "fake3", "Content4", "Comment4"); TMTextUnit tu4 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "fake4", "Content4", "Comment4"); List<TextUnitDTO> textUnits = textUnitSearcher.search(params); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).doesNotContain(tu1.getId(), tu2.getId()); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).contains(tu3.getId(), tu4.getId()); params.setSkipAssetPathWithPattern("dont_use%"); asset = assetService.createAssetWithContent(testData.repository.getId(), "dont_use_me", "fake for test other tm repo"); tu1 = tmService.addTMTextUnit(testData.tm.getId(), asset.getId(), "dont_use_fake1", "Content1", "Comment1"); tu2 = tmService.addTMTextUnit(testData.tm.getId(), asset.getId(), "dont_use_fake2", "Content2", "Comment2"); tu3 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "use_fake3", "Content4", "Comment4"); tu4 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "use_fake4", "Content4", "Comment4"); textUnits = textUnitSearcher.search(params); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).doesNotContain(tu1.getId(), tu2.getId()); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).contains(tu3.getId(), tu4.getId()); params.setSkipAssetPathWithPattern("%ignore%"); asset = assetService.createAssetWithContent(testData.repository.getId(), "wil_be_ignored", "fake for test other tm repo"); tu1 = tmService.addTMTextUnit(testData.tm.getId(), asset.getId(), "ignore_fake1", "Content1", "Comment1"); tu2 = tmService.addTMTextUnit(testData.tm.getId(), asset.getId(), "ignore_use_fake2", "Content2", "Comment2"); tu3 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "no_fake3", "Content4", "Comment4"); tu4 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "no_fake4", "Content4", "Comment4"); textUnits = textUnitSearcher.search(params); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).doesNotContain(tu1.getId(), tu2.getId()); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).contains(tu3.getId(), tu4.getId()); }
@Test public void testSkipTextUnitsWithPattern() { TMTestData testData = new TMTestData(testIdWatcher); TMTextUnit tu1, tu2, tu3; TextUnitSearcherParameters params = new TextUnitSearcherParameters(); params.setRepositoryIds(testData.repository.getId()); params.setSkipTextUnitWithPattern("%skip_me"); tu1 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "text_unit_skip_me", "Content1", "Comment1"); tu2 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "text_unit2_skip_me", "Content2", "Comment2"); tu3 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "skip_me_not", "Content2", "Comment2"); List<TextUnitDTO> textUnits = textUnitSearcher.search(params); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).allSatisfy(textUnit -> assertThat(textUnit.getName()).doesNotEndWith("skip_me")); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).contains(tu3.getId()); params.setSkipTextUnitWithPattern("not_this%"); tu1 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "not_this_text", "Content1", "Comment1"); tu2 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "not_this_text2", "Content2", "Comment2"); tu3 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "this_should_be_in_not_this_one", "Content2", "Comment2"); textUnits = textUnitSearcher.search(params); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).allSatisfy(textUnit -> assertThat(textUnit.getName()).doesNotStartWith("not_this")); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).contains(tu3.getId()); params.setSkipTextUnitWithPattern("%ignore%"); tu1 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "unit_to_ignored", "Content1", "Comment1"); tu2 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "should_ignore_this_unit", "Content2", "Comment2"); tu3 = tmService.addTMTextUnit(testData.tm.getId(), testData.asset.getId(), "this_should_show_up", "Content2", "Comment2"); textUnits = textUnitSearcher.search(params); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).allSatisfy(textUnit -> assertThat(textUnit.getName()).doesNotContain("ignore")); assertThat(textUnits).extracting(TextUnitDTO::getTmTextUnitId).contains(tu3.getId()); }