use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.
the class LibTest method test.
static void test(String exprStr, String exprStrExpected) {
Expr expr = ExprUtils.parse(exprStrExpected);
NodeValue rExpected = expr.eval(null, LibTestExpr.createTest());
test(exprStr, rExpected);
}
use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.
the class TestFnFunctionsCollation method testFunctionCollationExec.
@Test
public void testFunctionCollationExec() {
collation function = new collation();
NodeValue collation = NodeValue.makeString("fi");
final String[] unordered = { "tšekin kieli", "tulun kieli", "töyhtöhyyppä", "tsahurin kieli", "tsahurin kieli", "tulun kieli" };
String[] ordered = { "tsahurin kieli", "tsahurin kieli", "tšekin kieli", "tulun kieli", "tulun kieli", "töyhtöhyyppä" };
// tests collation sort order with Danish words, but New Zealand English
// collation rules
List<NodeValue> nodeValues = new LinkedList<>();
for (String string : unordered) {
nodeValues.add(function.exec(collation, NodeValue.makeString(string)));
}
nodeValues.sort((NodeValue o1, NodeValue o2) -> NodeValue.compare(o1, o2));
List<String> result = new LinkedList<>();
for (NodeValue nv : nodeValues) {
String s = nv.getNode().getLiteralLexicalForm();
result.add(s);
}
assertArrayEquals(ordered, result.toArray(new String[0]));
}
use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.
the class TestFnFunctionsString method testEvalException.
private void testEvalException(String exprStr) {
Expr expr = ExprUtils.parse(exprStr);
try {
NodeValue r = expr.eval(null, LibTestExpr.createTest());
fail("No exception raised");
} catch (ExprEvalException ex) {
}
}
use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.
the class TestNV method nv_12.
@Test
public void nv_12() {
NodeValue nodeValue = nv("<http://jena.apache.org/>");
NV nv = new NV(nodeValue);
assertEquals("http://jena.apache.org/", nv.getUri());
assertEquals("http://jena.apache.org/", nv.getValue());
assertEquals("NamedNode", nv.getTermType());
}
use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.
the class TestNV method test.
private void test(String str) {
NodeValue nv = nv(str);
Object x = NV.fromNodeValue(nv);
NodeValue nv2 = NV.toNodeValue(x);
assertEquals(nv, nv2);
}
Aggregations