@Test public void shouldLimitQueryLengthWhenAddingRequiredWords() throws Exception { SearchRequest request = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100); request.getInternalData().setRequiredWords(Arrays.asList("characters50sssssssssssssssssssssssssssssssssssss1", "characters50sssssssssssssssssssssssssssssssssssss2", "characters50sssssssssssssssssssssssssssssssssssss3", "characters50sssssssssssssssssssssssssssssssssssss4", "characters40ssssssssssssssssssssssssssss", "aaaaa", "bbbbb")); String query = testee.addRequiredWords(request, ""); assertThat(query.length()).isLessThan(255); }
protected String addRequiredWords(SearchRequest searchRequest, String query) { List<String> allRequiredWords = new ArrayList<>(searchRequest.getInternalData().getRequiredWords()); allRequiredWords.addAll(configProvider.getBaseConfig().getSearching().getRequiredWords()); allRequiredWords.addAll(searchRequest.getCategory().getRequiredWords()); List<String> allPossibleRequiredWords = allRequiredWords.stream().filter(x -> !(x.contains(" ") || x.contains("-") || x.contains("."))).collect(Collectors.toList()); if (allRequiredWords.size() > allPossibleRequiredWords.size()) { logger.debug("Not using some forbidden words in query because characters forbidden by newznab are contained"); } StringBuilder queryBuilder = new StringBuilder(query); for (String word : allPossibleRequiredWords) { if ((queryBuilder + word).length() < 255) { queryBuilder.append(" ").append(queryBuilder); } } query = queryBuilder.toString(); return query; }
NzbsOrg extends Newznab { protected String addRequiredWords(SearchRequest searchRequest, String query) { List<String> allRequiredWords = new ArrayList<>(searchRequest.getInternalData().getRequiredWords()); allRequiredWords.addAll(configProvider.getBaseConfig().getSearching().getRequiredWords()); allRequiredWords.addAll(searchRequest.getCategory().getRequiredWords()); List<String> allPossibleRequiredWords = allRequiredWords.stream().filter(x -> !(x.contains(" ") || x.contains("-") || x.contains("."))).collect(Collectors.toList()); if (allRequiredWords.size() > allPossibleRequiredWords.size()) { logger.debug("Not using some forbidden words in query because characters forbidden by newznab are contained"); } StringBuilder queryBuilder = new StringBuilder(query); for (String word : allPossibleRequiredWords) { if ((queryBuilder + word).length() < 255) { queryBuilder.append(" ").append(queryBuilder); } } query = queryBuilder.toString(); return query; } }
NzbsOrg extends Newznab { protected String addRequiredWords(SearchRequest searchRequest, String query) { List<String> allRequiredWords = new ArrayList<>(searchRequest.getInternalData().getRequiredWords()); allRequiredWords.addAll(configProvider.getBaseConfig().getSearching().getRequiredWords()); allRequiredWords.addAll(searchRequest.getCategory().getRequiredWords()); List<String> allPossibleRequiredWords = allRequiredWords.stream().filter(x -> !(x.contains(" ") || x.contains("-") || x.contains("."))).collect(Collectors.toList()); if (allRequiredWords.size() > allPossibleRequiredWords.size()) { logger.debug("Not using some forbidden words in query because characters forbidden by newznab are contained"); } StringBuilder queryBuilder = new StringBuilder(query); for (String word : allPossibleRequiredWords) { if ((queryBuilder + word).length() < 255) { queryBuilder.append(" ").append(queryBuilder); } } query = queryBuilder.toString(); return query; }  }
NzbsOrg extends Newznab { protected String addRequiredWords(SearchRequest searchRequest, String query) { List<String> allRequiredWords = new ArrayList<>(searchRequest.getInternalData().getRequiredWords()); allRequiredWords.addAll(configProvider.getBaseConfig().getSearching().getRequiredWords()); allRequiredWords.addAll(searchRequest.getCategory().getRequiredWords()); List<String> allPossibleRequiredWords = allRequiredWords.stream().filter(x -> !(x.contains(" ") || x.contains("-") || x.contains("."))).collect(Collectors.toList()); if (allRequiredWords.size() > allPossibleRequiredWords.size()) { logger.debug("Not using some forbidden words in query because characters forbidden by newznab are contained"); } StringBuilder queryBuilder = new StringBuilder(query); for (String word : allPossibleRequiredWords) { if ((queryBuilder + word).length() < 255) { queryBuilder.append(" ").append(queryBuilder); } } query = queryBuilder.toString(); return query; }   }
NzbsOrg extends Newznab { protected String addRequiredWords(SearchRequest searchRequest, String query) { List<String> allRequiredWords = new ArrayList<>(searchRequest.getInternalData().getRequiredWords()); allRequiredWords.addAll(configProvider.getBaseConfig().getSearching().getRequiredWords()); allRequiredWords.addAll(searchRequest.getCategory().getRequiredWords()); List<String> allPossibleRequiredWords = allRequiredWords.stream().filter(x -> !(x.contains(" ") || x.contains("-") || x.contains("."))).collect(Collectors.toList()); if (allRequiredWords.size() > allPossibleRequiredWords.size()) { logger.debug("Not using some forbidden words in query because characters forbidden by newznab are contained"); } StringBuilder queryBuilder = new StringBuilder(query); for (String word : allPossibleRequiredWords) { if ((queryBuilder + word).length() < 255) { queryBuilder.append(" ").append(queryBuilder); } } query = queryBuilder.toString(); return query; }    }