IsTripleFunction implements Function { @Override public Value evaluate(ValueFactory vf, Value... args) throws ValueExprEvaluationException { if (args.length != 1) { throw new ValueExprEvaluationException("expect exactly 1 argument"); } return vf.createLiteral((args[0] instanceof Triple)); }  @Override String getURI(); @Override Value evaluate(ValueFactory vf, Value... args);  }
@Test public void testEvaluateWithTriple() { IRI subj = f.createIRI("urn:a"); IRI pred = f.createIRI("urn:b"); IRI obj = f.createIRI("urn:c"); Triple testValue = f.createTriple(subj, pred, obj); Value value = function.evaluate(f, testValue); assertNotNull(value); assertTrue("expect Literal", value instanceof Literal); assertTrue("expect positive result", ((Literal) value).booleanValue()); value = function.evaluate(f, subj); assertNotNull(value); assertTrue("expect Literal", value instanceof Literal); assertTrue("expect negative result", !((Literal) value).booleanValue()); }
@Test(expected = ValueExprEvaluationException.class) public void testNegativeWrongArguments() { IRI subj = f.createIRI("urn:a"); IRI pred = f.createIRI("urn:b"); IRI obj = f.createIRI("urn:c"); Triple testValue = f.createTriple(subj, pred, obj); function.evaluate(f, testValue, subj); fail("expect ValueExprEvaluationException"); }
@Test(expected = ValueExprEvaluationException.class) public void testNegativeNoArguments() { function.evaluate(f); fail("expect ValueExprEvaluationException"); }