@Test public void testCheckLegalSearch() { assertEquals(SearchWorker.ERR_EMPTY, SearchWorker.checkLegalSearch(null)); assertEquals(SearchWorker.ERR_EMPTY, SearchWorker.checkLegalSearch("")); assertEquals(SearchWorker.STR_TRUE, SearchWorker.checkLegalSearch("foo")); assertEquals(SearchWorker.STR_TRUE, SearchWorker.checkLegalSearch("foobar*")); assertEquals(SearchWorker.ERR_TOO_SHORT, SearchWorker.checkLegalSearch("foo*")); assertEquals(SearchWorker.ERR_TOO_SHORT, SearchWorker.checkLegalSearch("*foo")); assertEquals(SearchWorker.STR_TRUE, SearchWorker.checkLegalSearch("*foo*")); assertEquals(SearchWorker.ERR_TOO_WILD, SearchWorker.checkLegalSearch("*f*o*o*")); assertEquals(SearchWorker.STR_TRUE, SearchWorker.checkLegalSearch("()()(")); }
public static String checkLegalSearch(String searchString) { if (searchString == null || searchString.isEmpty()) { return ERR_EMPTY; } searchString = Jsoup.clean(searchString, Whitelist.none()); searchString = StringEscapeUtils.unescapeHtml(searchString); if (searchString.contains("*") && searchString.length() <= 4) { return ERR_TOO_SHORT; } if (ConversionHelper.count(searchString, "*") > 2) { return ERR_TOO_WILD; } return STR_TRUE; }
SearchWorker { public static String checkLegalSearch(String searchString) { if (searchString == null || searchString.isEmpty()) { return ERR_EMPTY; } searchString = Jsoup.clean(searchString, Whitelist.none()); searchString = StringEscapeUtils.unescapeHtml(searchString); if (searchString.contains("*") && searchString.length() <= 4) { return ERR_TOO_SHORT; } if (ConversionHelper.count(searchString, "*") > 2) { return ERR_TOO_WILD; } return STR_TRUE; } }
SearchWorker { public static String checkLegalSearch(String searchString) { if (searchString == null || searchString.isEmpty()) { return ERR_EMPTY; } searchString = Jsoup.clean(searchString, Whitelist.none()); searchString = StringEscapeUtils.unescapeHtml(searchString); if (searchString.contains("*") && searchString.length() <= 4) { return ERR_TOO_SHORT; } if (ConversionHelper.count(searchString, "*") > 2) { return ERR_TOO_WILD; } return STR_TRUE; }  }
SearchWorker { public static String checkLegalSearch(String searchString) { if (searchString == null || searchString.isEmpty()) { return ERR_EMPTY; } searchString = Jsoup.clean(searchString, Whitelist.none()); searchString = StringEscapeUtils.unescapeHtml(searchString); if (searchString.contains("*") && searchString.length() <= 4) { return ERR_TOO_SHORT; } if (ConversionHelper.count(searchString, "*") > 2) { return ERR_TOO_WILD; } return STR_TRUE; }  static String checkLegalSearch(String searchString); static int getMaxResults(int requested); static JSONObject doSearch(final SearchCriteria sc); }
SearchWorker { public static String checkLegalSearch(String searchString) { if (searchString == null || searchString.isEmpty()) { return ERR_EMPTY; } searchString = Jsoup.clean(searchString, Whitelist.none()); searchString = StringEscapeUtils.unescapeHtml(searchString); if (searchString.contains("*") && searchString.length() <= 4) { return ERR_TOO_SHORT; } if (ConversionHelper.count(searchString, "*") > 2) { return ERR_TOO_WILD; } return STR_TRUE; }  static String checkLegalSearch(String searchString); static int getMaxResults(int requested); static JSONObject doSearch(final SearchCriteria sc); static final String KEY_TOTAL_COUNT; static final String KEY_ERROR_TEXT; static final String KEY_LOCATIONS; static final String KEY_METHODS; static final String KEY_HAS_MORE; static final String ERR_EMPTY; static final String ERR_TOO_SHORT; static final String ERR_TOO_WILD; static final String STR_TRUE; static final String STR_NULL; }