### Question:
HashFunction implements Function { @Override public abstract Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException;  @Override abstract Literal evaluate(ValueFactory valueFactory, Value... args);  }### Answer:
@Test public void testEvaluate() { try { Literal hash = getHashFunction().evaluate(f, f.createLiteral(getToHash())); assertNotNull(hash); assertEquals(XMLSchema.STRING, hash.getDatatype()); assertEquals(hash.getLabel(), getExpectedDigest()); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluate2() { try { Literal hash = getHashFunction().evaluate(f, f.createLiteral(getToHash(), XMLSchema.STRING)); assertNotNull(hash); assertEquals(XMLSchema.STRING, hash.getDatatype()); assertEquals(hash.getLabel(), getExpectedDigest()); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluate3() { try { getHashFunction().evaluate(f, f.createLiteral("4", XMLSchema.INTEGER)); fail("incompatible operand should have resulted in type error."); } catch (ValueExprEvaluationException e) { } }
@Test public void testEvaluate() { try { Literal hash = getHashFunction().evaluate(f, f.createLiteral(getToHash())); assertNotNull(hash); assertEquals(XSD.STRING, hash.getDatatype()); assertEquals(hash.getLabel(), getExpectedDigest()); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluate2() { try { Literal hash = getHashFunction().evaluate(f, f.createLiteral(getToHash(), XSD.STRING)); assertNotNull(hash); assertEquals(XSD.STRING, hash.getDatatype()); assertEquals(hash.getLabel(), getExpectedDigest()); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testEvaluate3() { try { getHashFunction().evaluate(f, f.createLiteral("4", XSD.INTEGER)); fail("incompatible operand should have resulted in type error."); } catch (ValueExprEvaluationException e) { } }