Search in sources :

Example 1 with URIExtensionIV

use of com.bigdata.rdf.internal.impl.uri.URIExtensionIV 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());
}
Also used : URIExtensionIV(com.bigdata.rdf.internal.impl.uri.URIExtensionIV) BigInteger(java.math.BigInteger) URIImpl(org.openrdf.model.impl.URIImpl) IV(com.bigdata.rdf.internal.IV) XSDIntegerIV(com.bigdata.rdf.internal.impl.literal.XSDIntegerIV) VocabURIByteIV(com.bigdata.rdf.internal.impl.uri.VocabURIByteIV) URIExtensionIV(com.bigdata.rdf.internal.impl.uri.URIExtensionIV) Test(org.junit.Test)

Example 2 with URIExtensionIV

use of com.bigdata.rdf.internal.impl.uri.URIExtensionIV in project wikidata-query-rdf by wikimedia.

the class T213375_UnitTest method test_reference_inlining.

@SuppressWarnings("rawtypes")
@Test
public void test_reference_inlining() {
    // Prepare reference URI
    String reference = "http://www.wikidata.org/reference/";
    String id = "0123456789abcdef0123456789abcdef01234567";
    String uri = reference + 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(reference, 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());
}
Also used : URIExtensionIV(com.bigdata.rdf.internal.impl.uri.URIExtensionIV) BigInteger(java.math.BigInteger) URIImpl(org.openrdf.model.impl.URIImpl) IV(com.bigdata.rdf.internal.IV) XSDIntegerIV(com.bigdata.rdf.internal.impl.literal.XSDIntegerIV) VocabURIByteIV(com.bigdata.rdf.internal.impl.uri.VocabURIByteIV) URIExtensionIV(com.bigdata.rdf.internal.impl.uri.URIExtensionIV) Test(org.junit.Test)

Aggregations

IV (com.bigdata.rdf.internal.IV)2 XSDIntegerIV (com.bigdata.rdf.internal.impl.literal.XSDIntegerIV)2 URIExtensionIV (com.bigdata.rdf.internal.impl.uri.URIExtensionIV)2 VocabURIByteIV (com.bigdata.rdf.internal.impl.uri.VocabURIByteIV)2 BigInteger (java.math.BigInteger)2 Test (org.junit.Test)2 URIImpl (org.openrdf.model.impl.URIImpl)2