use of org.openrdf.model.impl.URIImpl in project blueprints by tinkerpop.
the class GraphSailTest method testAddVertex.
@Test
public void testAddVertex() throws Exception {
GraphSail gSail = (GraphSail) sail;
Value toAdd = new URIImpl("http://example.org/thelarch");
assertNull(gSail.getVertex(toAdd));
int count = countVertices();
Vertex added = gSail.addVertex(toAdd);
assertNotNull(added);
assertEquals(1 + count, countVertices());
assertEquals("http://example.org/thelarch", added.getProperty(GraphSail.VALUE));
// also test that we get the vertex through getVertex
added = gSail.getVertex(toAdd);
assertNotNull(added);
assertEquals("http://example.org/thelarch", added.getProperty(GraphSail.VALUE));
}
use of org.openrdf.model.impl.URIImpl in project blueprints by tinkerpop.
the class SailVertex method setProperty.
public void setProperty(final String key, final Object value) {
if (this.rawVertex instanceof Resource) {
throw new RuntimeException(URI_BLANK_NODE_PROPERTIES);
} else {
boolean update = false;
final Literal oldLiteral = (Literal) this.rawVertex;
if (key.equals(SailTokens.DATATYPE)) {
this.rawVertex = new LiteralImpl(oldLiteral.getLabel(), new URIImpl(this.graph.expandPrefix(value.toString())));
update = true;
} else if (key.equals(SailTokens.LANGUAGE)) {
this.rawVertex = new LiteralImpl(oldLiteral.getLabel(), value.toString());
update = true;
}
if (update) {
this.updateLiteral(oldLiteral, (Literal) this.rawVertex);
}
}
}
use of org.openrdf.model.impl.URIImpl in project blueprints by tinkerpop.
the class SailGraphSpecificTestSuite method testTypeConversion.
public void testTypeConversion() {
assertEquals(SailVertex.castLiteral(new LiteralImpl("marko", new URIImpl("http://www.w3.org/2001/XMLSchema#string"))).getClass(), String.class);
assertEquals(SailVertex.castLiteral(new LiteralImpl("marko")).getClass(), String.class);
assertEquals(SailVertex.castLiteral(new LiteralImpl("27", new URIImpl("http://www.w3.org/2001/XMLSchema#int"))).getClass(), Integer.class);
assertEquals(SailVertex.castLiteral(new LiteralImpl("27", new URIImpl("http://www.w3.org/2001/XMLSchema#float"))).getClass(), Float.class);
assertEquals(SailVertex.castLiteral(new LiteralImpl("27.0134", new URIImpl("http://www.w3.org/2001/XMLSchema#double"))).getClass(), Double.class);
assertEquals(SailVertex.castLiteral(new LiteralImpl("hello", "en")), "hello");
}
use of org.openrdf.model.impl.URIImpl in project wikidata-query-rdf by wikimedia.
the class T213375_UnitTest method test_value_inlining.
@SuppressWarnings("rawtypes")
@Test
public void test_value_inlining() {
// Prepare value URI
String value = "http://www.wikidata.org/value/";
String id = "0123456789abcdef0123456789abcdef01234567";
String uri = value + id;
// Pass URI to the journal for inlining
IV<?, ?> iv = this.store.addTerm(new URIImpl(uri));
// Test IV type
assertEquals(URIExtensionIV.class, iv.getClass());
// Test prefix is inlined as vocabulary IV
IV extensionIV = ((URIExtensionIV) iv).getExtensionIV();
assertEquals(VocabURIByteIV.class, extensionIV.getClass());
// Test prefix encoded correctly in lexicon
assertEquals(value, extensionIV.asValue(this.store.getLexiconRelation()).stringValue());
// Test local name is xsd:integer
assertEquals(XSDIntegerIV.class, ((URIExtensionIV) iv).getLocalNameIV().getClass());
// Test local name is encoded as hex BigInteger
assertEquals(new BigInteger(id, 16), ((URIExtensionIV) iv).getLocalNameIV().integerValue());
// Test string representation of the IV matches to reference URI
assertEquals(uri, iv.asValue(this.store.getLexiconRelation()).stringValue());
}
use of org.openrdf.model.impl.URIImpl in project wikidata-query-rdf by wikimedia.
the class WikibasePrefixesUnitTest method testPrefixesRFDSandSchema.
@Test
public void testPrefixesRFDSandSchema() {
add("wd:Q123", SchemaDotOrg.ABOUT, SKOS.ALT_LABEL);
TupleQueryResult res = query("SELECT * WHERE { ?x schema:about skos:altLabel }");
assertResult(res, binds("x", new URIImpl(uris().entityIdToURI("Q123"))));
}
Aggregations