### Question:
FunctionDefinitionNumberTypeConversion extends FunctionDefinitionHomogeneousSimple<O, I> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { List<I> convertedArguments = new ArrayList<I>(); Status status = this.validateArguments(arguments, convertedArguments); if (!status.getStatusCode().equals(StdStatusCode.STATUS_CODE_OK)) { return ExpressionResult.newError(getFunctionStatus(status)); } ExpressionResult expressionResult; try { if (convertedArguments.get(0).getClass() == java.math.BigInteger.class) { AttributeValue<Double> doubleResult = new StdAttributeValue<Double>(XACML.ID_DATATYPE_DOUBLE, new Double( ((BigInteger)convertedArguments.get(0)).toString() ) ); expressionResult = ExpressionResult.newSingle(doubleResult); } else { AttributeValue<BigInteger> integerResult = new StdAttributeValue<BigInteger>(XACML.ID_DATATYPE_INTEGER, BigInteger.valueOf(((Double)convertedArguments.get(0)).intValue()) ); expressionResult = ExpressionResult.newSingle(integerResult); } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return expressionResult; } FunctionDefinitionNumberTypeConversion(Identifier idIn, DataType<O> outputType, DataType<I> argType); @Override ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments);  }### Answer:
@Test public void testDouble_to_integer() { FunctionArgumentAttributeValue attr1 = null; try { attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(5.432)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionNumberTypeConversion<?, ?> fd = (FunctionDefinitionNumberTypeConversion<?, ?>) StdFunctions.FD_DOUBLE_TO_INTEGER; assertEquals(XACML3.ID_FUNCTION_DOUBLE_TO_INTEGER, fd.getId()); assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); assertEquals(new Integer(1), fd.getNumArgs()); arguments.add(attr1); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); BigInteger resValue = (BigInteger)res.getValue().getValue(); assertEquals(BigInteger.valueOf(5), resValue); }
@Test public void testInteger_to_double() { FunctionArgumentAttributeValue attr1 = null; try { attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionNumberTypeConversion<?, ?> fd = (FunctionDefinitionNumberTypeConversion<?, ?>) StdFunctions.FD_INTEGER_TO_DOUBLE; assertEquals(XACML3.ID_FUNCTION_INTEGER_TO_DOUBLE, fd.getId()); assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); assertEquals(new Integer(1), fd.getNumArgs()); arguments.add(attr1); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); Double resValue = (Double)res.getValue().getValue(); assertEquals(new Double(5.0), resValue); }