### Question:
RecodeFunction implements Function { public Object evaluate(Object object) { return evaluate(object, Object.class); } RecodeFunction();  RecodeFunction(List<Expression> parameters, Literal fallback); String getName(); List<Expression> getParameters(); Object accept(ExpressionVisitor visitor, Object extraData); Object evaluate(Object object); T evaluate(Object object, Class<T> context); Literal getFallbackValue(); static final FunctionName NAME; }### Answer:
@Test public void testFindFunction() throws Exception { System.out.println(" testFindFunction"); Literal fallback = ff2.literal("NOT_FOUND"); setupParameters(ints, colors); Function fn = finder.findFunction("recode", parameters, fallback); Object result = fn.evaluate(feature(ints[0])); assertFalse("Could not locate 'recode' function", result.equals(fallback.getValue())); }
@Test public void testIntToColorLookup() throws Exception { System.out.println(" testIntToColorLookup"); setupParameters(ints, colors); Function fn = finder.findFunction("recode", parameters); for (int i = 0; i < ints.length; i++) { assertEquals(colors[i], fn.evaluate(feature(ints[i]), Color.class)); } }
@Test public void testRecodeUndefinedValueReturnsNull() throws Exception { System.out.println(" testRecodeUndefinedValueReturnsNull"); setupParameters(words, ints); Function fn = finder.findFunction("recode", parameters); final String missing = "missing"; assertNull(fn.evaluate(feature(missing))); }