### Question:
StringFunctionDefinitionParser { public static List<StringFunction> parse(String definition) { List<StringFunction> functions = new ArrayList<StringFunction>(); String[] functionsDef = StringUtils.split(definition, SEPARATOR); for(String functionDef : functionsDef) { if(functionDef.equals(TRIM_DEFINITION)) { functions.add(TRIM_FUNCTION); }else if(functionDef.equals(LEFT_TRIM_DEFINITION)) { functions.add(LEFT_TRIM_FUNCTION); }else if(functionDef.equals(RIGHT_TRIM_DEFINITION)) { functions.add(RIGHT_TRIM_FUNCTION); } else if(functionDef.equals(UPPER_CASE_DEFINITION)) { functions.add(UPPER_CASE_FUNCTION); } else if(functionDef.equals(LOWER_CASE_DEFINITION)) { functions.add(LOWER_CASE_FUNCTION); } else if(functionDef.equals(CAPITALIZE_DEFINITION)) { functions.add(CAPITALIZE_FUNCTION); } else if(functionDef.equals(CAPITALIZE_FIRST_DEFINITION)) { functions.add(CAPITALIZE_FIRST_FUNCTION); } else if(functionDef.equals(UNCAPITALIZE_FIRST_DEFINITION)) { functions.add(UNCAPITALIZE_FIRST_FUNCTION); } else { throw new UnknownStringFunctionException("The function '"+ functionDef +"' in the function definition '"+ definition +"' is unknown."); } } return functions; } private  StringFunctionDefinitionParser(); static List<StringFunction> parse(String definition); static final TrimFunction TRIM_FUNCTION; static final LeftTrimFunction LEFT_TRIM_FUNCTION; static final RightTrimFunction RIGHT_TRIM_FUNCTION; static final UpperCaseFunction UPPER_CASE_FUNCTION; static final LowerCaseFunction LOWER_CASE_FUNCTION; static final CapitalizeFunction CAPITALIZE_FUNCTION; static final CapitalizeFirstFunction CAPITALIZE_FIRST_FUNCTION; static final UncapitalizeFirstFunction UNCAPITALIZE_FIRST_FUNCTION; static final String TRIM_DEFINITION; static final String LEFT_TRIM_DEFINITION; static final String RIGHT_TRIM_DEFINITION; static final String UPPER_CASE_DEFINITION; static final String LOWER_CASE_DEFINITION; static final String CAPITALIZE_DEFINITION; static final String CAPITALIZE_FIRST_DEFINITION; static final String UNCAPITALIZE_FIRST_DEFINITION; static final char SEPARATOR; }### Answer:
@Test public void test_parse() { assertSame(TRIM_FUNCTION, parse(TRIM_DEFINITION).get(0)); assertSame(LEFT_TRIM_FUNCTION, parse(LEFT_TRIM_DEFINITION).get(0)); assertSame(RIGHT_TRIM_FUNCTION, parse(RIGHT_TRIM_DEFINITION).get(0)); assertSame(UPPER_CASE_FUNCTION, parse(UPPER_CASE_DEFINITION).get(0)); assertSame(LOWER_CASE_FUNCTION, parse(LOWER_CASE_DEFINITION).get(0)); assertSame(CAPITALIZE_FUNCTION, parse(CAPITALIZE_DEFINITION).get(0)); assertSame(CAPITALIZE_FIRST_FUNCTION, parse(CAPITALIZE_FIRST_DEFINITION).get(0)); assertSame(UNCAPITALIZE_FIRST_FUNCTION, parse(UNCAPITALIZE_FIRST_DEFINITION).get(0)); String def = TRIM_DEFINITION + SEPARATOR + UPPER_CASE_DEFINITION + SEPARATOR + CAPITALIZE_DEFINITION; List<StringFunction> functions = parse(def); assertSame(TRIM_FUNCTION, functions.get(0)); assertSame(UPPER_CASE_FUNCTION, functions.get(1)); assertSame(CAPITALIZE_FUNCTION, functions.get(2)); }
@Test public void test_unknown_function() { try { parse("fewfewfwe"); } catch (UnknownStringFunctionException e) { return; } fail("UnknownStringFunctionException not thrown"); }