use of org.apache.jena.rdf.model.Literal in project jena by apache.
the class TestDatasetWithLuceneStoredLiterals method testLiteralValue.
@Test
public void testLiteralValue() {
// test basic capturing of the literal value in a variable
final String turtle = PF_DATA;
String queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s ?literal", "WHERE {", " (?s ?score ?literal) text:query ('text') .", "}");
Set<String> expectedURIs = new HashSet<>();
expectedURIs.addAll(Arrays.asList(R_S1));
Map<String, Literal> literals = doTestSearchWithLiterals(turtle, queryString, expectedURIs);
Literal value = literals.get(R_S1);
assertNotNull(value);
assertEquals(NodeFactory.createLiteral("text"), value.asNode());
}
use of org.apache.jena.rdf.model.Literal in project jena by apache.
the class TestDatasetWithLuceneStoredLiterals method testLiteralValueNonDefaultField.
@Test
public void testLiteralValueNonDefaultField() {
// test basic capturing of the literal value in a variable
final String testName = "testLiteralValueNonDefaultField";
final String turtle = StrUtils.strjoinNL(TURTLE_PROLOG, "<" + RESOURCE_BASE + testName + ">", " rdfs:comment 'a text comment'", ".");
String queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s ?literal", "WHERE {", " (?s ?score ?literal) text:query (rdfs:comment 'text') .", "}");
Set<String> expectedURIs = new HashSet<>();
expectedURIs.addAll(Arrays.asList(RESOURCE_BASE + testName));
Map<String, Literal> literals = doTestSearchWithLiterals(turtle, queryString, expectedURIs);
Literal value = literals.get(RESOURCE_BASE + testName);
assertNotNull(value);
assertEquals(NodeFactory.createLiteral("a text comment"), value.asNode());
}
Aggregations