### Question:
Round implements Function { @Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 1) { throw new ValueExprEvaluationException("ROUND requires exactly 1 argument, got " + args.length); } if (args[0] instanceof Literal) { Literal literal = (Literal) args[0]; IRI datatype = literal.getDatatype(); if (datatype != null && XMLDatatypeUtil.isNumericDatatype(datatype)) { if (XMLDatatypeUtil.isIntegerDatatype(datatype)) { return literal; } else if (XMLDatatypeUtil.isDecimalDatatype(datatype)) { BigDecimal rounded = literal.decimalValue().setScale(0, RoundingMode.HALF_UP); return valueFactory.createLiteral(rounded.toPlainString(), datatype); } else if (XMLDatatypeUtil.isFloatingPointDatatype(datatype)) { double ceilingValue = Math.round(literal.doubleValue()); return valueFactory.createLiteral(Double.toString(ceilingValue), datatype); } else { throw new ValueExprEvaluationException("unexpected datatype for function operand: " + args[0]); } } else { throw new ValueExprEvaluationException("unexpected input value for function: " + args[0]); } } else { throw new ValueExprEvaluationException("unexpected input value for function: " + args[0]); } }  @Override String getURI(); @Override Literal evaluate(ValueFactory valueFactory, Value... args);  }### Answer:
@Test public void testEvaluateBigDecimal() { try { BigDecimal bd = new BigDecimal(1234567.567); Literal rounded = round.evaluate(f, f.createLiteral(bd.toPlainString(), XMLSchema.DECIMAL)); BigDecimal roundValue = rounded.decimalValue(); assertEquals(new BigDecimal(1234568.0), roundValue); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluateDouble() { try { double dVal = 1.6; Literal rounded = round.evaluate(f, f.createLiteral(dVal)); double roundValue = rounded.doubleValue(); assertEquals((double) 2.0, roundValue, 0.001d); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluateInt() { try { int iVal = 1; Literal rounded = round.evaluate(f, f.createLiteral(iVal)); int roundValue = rounded.intValue(); assertEquals(iVal, roundValue); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluateBigDecimal() { try { BigDecimal bd = new BigDecimal(1234567.567); Literal rounded = round.evaluate(f, f.createLiteral(bd.toPlainString(), XSD.DECIMAL)); BigDecimal roundValue = rounded.decimalValue(); assertEquals(new BigDecimal(1234568.0), roundValue); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }