### Question:
FunctionDefinitionStringNormalize extends FunctionDefinitionHomogeneousSimple<String, String> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<String> convertedArguments = new ArrayList<>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } ExpressionResult expressionResult = null; switch (operation) { case SPACE: result = new StdAttributeValue<>(XACML.ID_DATATYPE_STRING, convertedArguments.get(0).trim() ); break; case LOWER_CASE: result = new StdAttributeValue<>(XACML.ID_DATATYPE_STRING, convertedArguments.get(0).toLowerCase() ); break; } expressionResult = ExpressionResult.newSingle(result); return expressionResult; } FunctionDefinitionStringNormalize(Identifier idIn,  OPERATION op); @Override ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments);  }### Answer:
@Test public void testString_normalize_space() { String initialString = " First and last are whitespace "; FunctionArgumentAttributeValue attr1 = null; try { attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(initialString)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionStringNormalize fd = (FunctionDefinitionStringNormalize) StdFunctions.FD_STRING_NORMALIZE_SPACE; assertEquals(XACML3.ID_FUNCTION_STRING_NORMALIZE_SPACE, fd.getId()); assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); assertEquals(new Integer(1), fd.getNumArgs()); arguments.add(attr1); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); String resValue = (String)res.getValue().getValue(); assertEquals(initialString.length() - 4, resValue.length()); assertTrue(initialString.trim().equals(resValue)); }
@Test public void testString_normalize_to_lower_case() { String initialString = " First and last are whitespace "; FunctionArgumentAttributeValue attr1 = null; try { attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(initialString)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionStringNormalize fd = (FunctionDefinitionStringNormalize) StdFunctions.FD_STRING_NORMALIZE_TO_LOWER_CASE; assertEquals(XACML3.ID_FUNCTION_STRING_NORMALIZE_TO_LOWER_CASE, fd.getId()); assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); assertEquals(new Integer(1), fd.getNumArgs()); arguments.add(attr1); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); String resValue = (String)res.getValue().getValue(); assertTrue(initialString.toLowerCase().equals(resValue)); }