@Test public void shouldGenerateStringForSingleCategory() { List<String> result = CategoryStringGenerator.getPostgresCategoryString(SINGLE_CAT, Collections.EMPTY_MAP, null ); assertEquals( result.size(), 1 ); assertEquals(result.get( 0 ), SINGLE_CAT_RESULT); }
public static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit ) { List<String> finalList = new ArrayList<String>(); if (searchString == null || !(searchString.trim().length() > 0)) { finalList.add( "{}" ); return finalList; } List<String> categories = parse(searchString.trim().toLowerCase()); List<String> catHolder = new ArrayList<String>(); for( String cat : categories ) { if (cat.matches( SearchToSqlConverter.BAD_SEARCH_REGEX ) ) { throw new IllegalArgumentException( SearchToSqlConverter.BAD_CHAR_MSG ); } if (prefixSplit != null ) { int index = cat.indexOf( prefixSplit ); if ( index != -1 ) { String prefix = cat.substring( 0, index ); String value = cat.substring( index + prefixSplit.length() ); if ( mapPrefix.containsKey( prefix ) ) { addToFinalList( finalList, catHolder ); finalList.add( value ); } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } addToFinalList( finalList, catHolder ); return finalList; }
CategoryStringGenerator { public static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit ) { List<String> finalList = new ArrayList<String>(); if (searchString == null || !(searchString.trim().length() > 0)) { finalList.add( "{}" ); return finalList; } List<String> categories = parse(searchString.trim().toLowerCase()); List<String> catHolder = new ArrayList<String>(); for( String cat : categories ) { if (cat.matches( SearchToSqlConverter.BAD_SEARCH_REGEX ) ) { throw new IllegalArgumentException( SearchToSqlConverter.BAD_CHAR_MSG ); } if (prefixSplit != null ) { int index = cat.indexOf( prefixSplit ); if ( index != -1 ) { String prefix = cat.substring( 0, index ); String value = cat.substring( index + prefixSplit.length() ); if ( mapPrefix.containsKey( prefix ) ) { addToFinalList( finalList, catHolder ); finalList.add( value ); } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } addToFinalList( finalList, catHolder ); return finalList; } }
CategoryStringGenerator { public static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit ) { List<String> finalList = new ArrayList<String>(); if (searchString == null || !(searchString.trim().length() > 0)) { finalList.add( "{}" ); return finalList; } List<String> categories = parse(searchString.trim().toLowerCase()); List<String> catHolder = new ArrayList<String>(); for( String cat : categories ) { if (cat.matches( SearchToSqlConverter.BAD_SEARCH_REGEX ) ) { throw new IllegalArgumentException( SearchToSqlConverter.BAD_CHAR_MSG ); } if (prefixSplit != null ) { int index = cat.indexOf( prefixSplit ); if ( index != -1 ) { String prefix = cat.substring( 0, index ); String value = cat.substring( index + prefixSplit.length() ); if ( mapPrefix.containsKey( prefix ) ) { addToFinalList( finalList, catHolder ); finalList.add( value ); } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } addToFinalList( finalList, catHolder ); return finalList; } private  CategoryStringGenerator(); }
CategoryStringGenerator { public static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit ) { List<String> finalList = new ArrayList<String>(); if (searchString == null || !(searchString.trim().length() > 0)) { finalList.add( "{}" ); return finalList; } List<String> categories = parse(searchString.trim().toLowerCase()); List<String> catHolder = new ArrayList<String>(); for( String cat : categories ) { if (cat.matches( SearchToSqlConverter.BAD_SEARCH_REGEX ) ) { throw new IllegalArgumentException( SearchToSqlConverter.BAD_CHAR_MSG ); } if (prefixSplit != null ) { int index = cat.indexOf( prefixSplit ); if ( index != -1 ) { String prefix = cat.substring( 0, index ); String value = cat.substring( index + prefixSplit.length() ); if ( mapPrefix.containsKey( prefix ) ) { addToFinalList( finalList, catHolder ); finalList.add( value ); } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } addToFinalList( finalList, catHolder ); return finalList; } private  CategoryStringGenerator(); static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit ); }
CategoryStringGenerator { public static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit ) { List<String> finalList = new ArrayList<String>(); if (searchString == null || !(searchString.trim().length() > 0)) { finalList.add( "{}" ); return finalList; } List<String> categories = parse(searchString.trim().toLowerCase()); List<String> catHolder = new ArrayList<String>(); for( String cat : categories ) { if (cat.matches( SearchToSqlConverter.BAD_SEARCH_REGEX ) ) { throw new IllegalArgumentException( SearchToSqlConverter.BAD_CHAR_MSG ); } if (prefixSplit != null ) { int index = cat.indexOf( prefixSplit ); if ( index != -1 ) { String prefix = cat.substring( 0, index ); String value = cat.substring( index + prefixSplit.length() ); if ( mapPrefix.containsKey( prefix ) ) { addToFinalList( finalList, catHolder ); finalList.add( value ); } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } else { catHolder.add( cat ); } } addToFinalList( finalList, catHolder ); return finalList; } private  CategoryStringGenerator(); static List<String> getPostgresCategoryString(String searchString, Map<String, String> mapPrefix, String prefixSplit );  }