@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()); }
@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);  }