From f4dc6597b318b4041e6b5382edd43efaf43b0794 Mon Sep 17 00:00:00 2001 From: Alessandro Adamou Date: Mon, 23 Apr 2018 17:16:15 +0100 Subject: [PATCH] Sketched unit test for issue #6 --- .../core4/TestClassSignatureGeneralizer.java | 22 +++++++++++++++ squire/src/test/resources/signatures2.json | 27 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/squire/src/test/java/uk/ac/open/kmi/squire/core4/TestClassSignatureGeneralizer.java b/squire/src/test/java/uk/ac/open/kmi/squire/core4/TestClassSignatureGeneralizer.java index c434f26..872ccbd 100644 --- a/squire/src/test/java/uk/ac/open/kmi/squire/core4/TestClassSignatureGeneralizer.java +++ b/squire/src/test/java/uk/ac/open/kmi/squire/core4/TestClassSignatureGeneralizer.java @@ -3,6 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Iterator; import java.util.Map; @@ -23,6 +24,7 @@ import org.apache.jena.vocabulary.DCTerms; import org.apache.jena.vocabulary.RDF; import org.apache.jena.vocabulary.RDFS; +import org.apache.jena.vocabulary.SKOS; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -216,6 +218,26 @@ public void oneTypePresent() throws Exception { assertFalse(find(q1, var_s, rdf_type, type_var)); } + /** + * One type not appearing in the target dataset; two properties, both used in + * the target dataset, also for same type, but neither for the type we need in + * the recommendation. In other words, the ideal query to recommend has + * nothing in common with the original one, except for the rdf:type + * property. + * + * I have no idea what a generalized query that satisfies this case would look + * like. + */ + @Test + public void twoPropertiesPresentButNeitherForOptimalType() throws Exception { + String q = "SELECT DISTINCT ?id ?name WHERE {" + + " ?s a " + " ; <" + + SKOS.notation.getURI() + "> ?id" + " ; <" + SKOS.prefLabel.getURI() + "> ?name" + " }"; + Set qG = _op.generalize(QueryFactory.create(q)); + assertEquals(1, qG.size()); + fail("Unit test NIY - don't know yet what general query we should require."); + } + /** * One type not appearing in the target dataset; two properties, both used in * the target dataset but never for the same type. diff --git a/squire/src/test/resources/signatures2.json b/squire/src/test/resources/signatures2.json index 0b7f5a1..1157a68 100644 --- a/squire/src/test/resources/signatures2.json +++ b/squire/src/test/resources/signatures2.json @@ -28,6 +28,15 @@ }, "http://data.open.ac.uk/openlearn/ontology/Podcast": { + }, + "http://statistics.data.gov.uk/def/geography/LocalEducationAuthority": { + "dps": [ + "http://www.w3.org/2004/02/skos/core#notation", + "http://www.w3.org/2004/02/skos/core#prefLabel" + ], + "ops": [ + "http://statistics.data.gov.uk/def/geography/coverage" + ] } }, "http://example.org/dataset/2": { @@ -62,7 +71,23 @@ "dps": [ "http://www.w3.org/2000/01/rdf-schema#label" ], - "ops": ["http://xmlns.com/foaf/0.1/depiction"] + "ops": [ + "http://xmlns.com/foaf/0.1/depiction" + ] + }, + "http://schema.org/School": { + "dps": [ + "http://gov.genealogy.net/ontology.owl#hasDenomination", + "http://schema.org/legalName", + "http://schema.stapferenquete.ch/schoolType", + "https://gont.ch/id" + ] + }, + "http://example.org/BadRecommendation/1": { + "dps": [ + "http://www.w3.org/2004/02/skos/core#notation", + "http://www.w3.org/2004/02/skos/core#prefLabel" + ] } } } \ No newline at end of file