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