@Test public void testGetFulltextPartOfFilter() throws Exception { TestObjectFilter objectFilter = new TestObjectFilter(); HashMap<String, String> testCases = new HashMap<>(); testCases.put("", ""); testCases.put(null, ""); testCases.put("no match, fulltext", "no match, fulltext"); testCases.put("match", "match"); testCases.put("no match fulltext,hash=23", "no match fulltext"); testCases.put("no match, fulltext,hash=23", "no match, fulltext"); testCases.put("match,hash=no match", "match"); testCases.put(",hash=no match", ""); testCases.put("23", "23"); testCases.put("hash=34", ""); testCases.put("hash=no match", ""); testCases.put("hash=no match,moreKeys=values", ""); testCases.put("fulltext,hash=no match,moreKeys=values", "fulltext"); testCases.put("fulltext, more fulltext,hash=no match,moreKeys=values", "fulltext, more fulltext"); for (Map.Entry<String, String> testCase : testCases.entrySet()) { try { Assert.assertEquals("Case handled incorrectly: " + testCase.getKey(), testCase.getValue(), objectFilter.getFulltextPartOfFilter(testCase.getKey())); } catch (Exception exception) { Assert.fail("Failed due to exception: " + exception.getMessage() + " - Test was: " + testCase.getKey() + " -> " + testCase.getValue()); } } }
final String getFulltextPartOfFilter(String filter) { if (filter == null) { return ""; } if (!filter.contains(SEPARATOR)) { return filter; } if (!filter.contains(DELIMITER) || filter.indexOf(SEPARATOR) < filter.indexOf(DELIMITER)) { return ""; } return filter.substring(0, StringUtils.lastIndexOf(filter.substring(0, filter.indexOf(SEPARATOR)), DELIMITER)); }
PaginationFilter implements Predicate<T> { final String getFulltextPartOfFilter(String filter) { if (filter == null) { return ""; } if (!filter.contains(SEPARATOR)) { return filter; } if (!filter.contains(DELIMITER) || filter.indexOf(SEPARATOR) < filter.indexOf(DELIMITER)) { return ""; } return filter.substring(0, StringUtils.lastIndexOf(filter.substring(0, filter.indexOf(SEPARATOR)), DELIMITER)); } }
PaginationFilter implements Predicate<T> { final String getFulltextPartOfFilter(String filter) { if (filter == null) { return ""; } if (!filter.contains(SEPARATOR)) { return filter; } if (!filter.contains(DELIMITER) || filter.indexOf(SEPARATOR) < filter.indexOf(DELIMITER)) { return ""; } return filter.substring(0, StringUtils.lastIndexOf(filter.substring(0, filter.indexOf(SEPARATOR)), DELIMITER)); }  }
PaginationFilter implements Predicate<T> { final String getFulltextPartOfFilter(String filter) { if (filter == null) { return ""; } if (!filter.contains(SEPARATOR)) { return filter; } if (!filter.contains(DELIMITER) || filter.indexOf(SEPARATOR) < filter.indexOf(DELIMITER)) { return ""; } return filter.substring(0, StringUtils.lastIndexOf(filter.substring(0, filter.indexOf(SEPARATOR)), DELIMITER)); }  PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset); final boolean test(T object, Class<V> enumType); }
PaginationFilter implements Predicate<T> { final String getFulltextPartOfFilter(String filter) { if (filter == null) { return ""; } if (!filter.contains(SEPARATOR)) { return filter; } if (!filter.contains(DELIMITER) || filter.indexOf(SEPARATOR) < filter.indexOf(DELIMITER)) { return ""; } return filter.substring(0, StringUtils.lastIndexOf(filter.substring(0, filter.indexOf(SEPARATOR)), DELIMITER)); }  PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset); final boolean test(T object, Class<V> enumType);  }