### Question:
EnvFunction extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { String varName = getExpression(0).evaluate(feature, String.class); Object value = localLookup.getTable().get(varName.toUpperCase()); if (value == null) { value = globalLookup.get(varName.toUpperCase()); } if (value == null) { final int paramSize = getParameters().size(); if (paramSize > getArgCount()) { value = getExpression(paramSize - 1).evaluate(feature); } } return value; } EnvFunction(); static void setLocalValues(Map<String, Object> values); static void clearLocalValues(); static void setGlobalValues(Map<String, Object> values); static void clearGlobalValues(); static void setLocalValue(String name, Object value); static void setGlobalValue(String name, Object value); @Override int getArgCount(); @Override Object evaluate(Object feature); @Override void setParameters(List params); @Override void setFallbackValue(Literal fallback);  }### Answer:
@Test public void testLiteralDefaultValue() { System.out.println(" literal default value"); int defaultValue = 42; Object result = ff.function("env", ff.literal("doesnotexist"), ff.literal(defaultValue)).evaluate(null); int value = ((Number) result).intValue(); assertEquals(defaultValue, value); }
@Test public void testNonLiteralDefaultValue() { System.out.println(" non-literal default value"); int x = 21; Expression defaultExpr = ff.add(ff.literal(x), ff.literal(x)); Object result = ff.function("env", ff.literal("doesnotexist"), defaultExpr).evaluate(null); int value = ((Number) result).intValue(); assertEquals(x + x, value); }