-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-3332: DirectTypeHierarchyInferencer queries are broken and tests a…
…re missing (#4698)
- Loading branch information
Showing
4 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...src/test/java/org/eclipse/rdf4j/sail/inferencer/fc/DirectTypeHierarchyInferencerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Eclipse RDF4J contributors. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.sail.inferencer.fc; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.eclipse.rdf4j.model.Model; | ||
import org.eclipse.rdf4j.query.QueryResults; | ||
import org.eclipse.rdf4j.repository.RepositoryConnection; | ||
import org.eclipse.rdf4j.repository.sail.SailRepository; | ||
import org.eclipse.rdf4j.repository.util.RDFLoader; | ||
import org.eclipse.rdf4j.rio.RDFFormat; | ||
import org.eclipse.rdf4j.rio.Rio; | ||
import org.eclipse.rdf4j.sail.memory.MemoryStore; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class DirectTypeHierarchyInferencerTest { | ||
|
||
@BeforeAll | ||
public static void setUpClass() throws Exception { | ||
System.setProperty("org.eclipse.rdf4j.repository.debug", "true"); | ||
} | ||
|
||
@AfterAll | ||
public static void afterClass() throws Exception { | ||
System.setProperty("org.eclipse.rdf4j.repository.debug", "false"); | ||
} | ||
|
||
@Test | ||
public void testDirectTypeHierarchyInference() throws IOException { | ||
SailRepository rep = new SailRepository(new DirectTypeHierarchyInferencer(new MemoryStore())); | ||
try { | ||
rep.init(); | ||
|
||
Model inputModel = Rio.parse(this.getClass().getResourceAsStream("direct-type-hierarchy-test-in.nt"), | ||
RDFFormat.NTRIPLES); | ||
Model expectedEntailedStatements = Rio.parse( | ||
this.getClass().getResourceAsStream("direct-type-hierarchy-test-out.nt"), | ||
RDFFormat.NTRIPLES); | ||
|
||
try (RepositoryConnection con = rep.getConnection()) { | ||
con.begin(); | ||
con.add(inputModel); | ||
con.commit(); | ||
} | ||
|
||
Model entailedStatements; | ||
try (RepositoryConnection con = rep.getConnection()) { | ||
entailedStatements = QueryResults.asModel(con.getStatements(null, null, null, | ||
true)); | ||
entailedStatements.removeAll(inputModel); | ||
} | ||
|
||
assertThat(entailedStatements).hasSameElementsAs(expectedEntailedStatements); | ||
|
||
} finally { | ||
rep.shutDown(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../src/test/resources/org/eclipse/rdf4j/sail/inferencer/fc/direct-type-hierarchy-test-in.nt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<http://example.org/ClassA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://example.org/ClassA> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/ClassA> . | ||
<http://example.org/ClassB> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://example.org/ClassB> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/ClassA> . | ||
<http://example.org/ClassB> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/ClassB> . | ||
<http://example.org/ClassC> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://example.org/ClassC> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/ClassA> . | ||
<http://example.org/ClassC> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/ClassB> . | ||
<http://example.org/ClassC> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/ClassC> . | ||
<http://example.org/propA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://example.org/propA> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/propA> . | ||
<http://example.org/propB> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://example.org/propB> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/propA> . | ||
<http://example.org/propB> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/propB> . | ||
<http://example.org/propC> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://example.org/propC> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/propA> . | ||
<http://example.org/propC> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/propB> . | ||
<http://example.org/propC> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/propC> . | ||
<http://example.org/instA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ClassA> . | ||
<http://example.org/instB> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ClassA> . | ||
<http://example.org/instB> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ClassB> . | ||
<http://example.org/instC> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ClassA> . | ||
<http://example.org/instC> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ClassB> . | ||
<http://example.org/instC> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ClassC> . |
13 changes: 13 additions & 0 deletions
13
...src/test/resources/org/eclipse/rdf4j/sail/inferencer/fc/direct-type-hierarchy-test-out.nt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<http://example.org/ClassA> <http://www.openrdf.org/schema/sesame#directType> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://example.org/ClassB> <http://www.openrdf.org/schema/sesame#directType> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://example.org/ClassB> <http://www.openrdf.org/schema/sesame#directSubClassOf> <http://example.org/ClassA> . | ||
<http://example.org/ClassC> <http://www.openrdf.org/schema/sesame#directType> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://example.org/ClassC> <http://www.openrdf.org/schema/sesame#directSubClassOf> <http://example.org/ClassB> . | ||
<http://example.org/propA> <http://www.openrdf.org/schema/sesame#directType> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://example.org/propB> <http://www.openrdf.org/schema/sesame#directType> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://example.org/propB> <http://www.openrdf.org/schema/sesame#directSubPropertyOf> <http://example.org/propA> . | ||
<http://example.org/propC> <http://www.openrdf.org/schema/sesame#directType> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://example.org/propC> <http://www.openrdf.org/schema/sesame#directSubPropertyOf> <http://example.org/propB> . | ||
<http://example.org/instA> <http://www.openrdf.org/schema/sesame#directType> <http://example.org/ClassA> . | ||
<http://example.org/instB> <http://www.openrdf.org/schema/sesame#directType> <http://example.org/ClassB> . | ||
<http://example.org/instC> <http://www.openrdf.org/schema/sesame#directType> <http://example.org/ClassC> . |