/** * {@inheritDoc} */ @Override public boolean isIsomorphicWith(Model g) { return super.object.isIsomorphicWith(g); }
public boolean isIsomorphicWith(Model g) { return model.isIsomorphicWith(g); }
/** Compare two result sets for bNode isomorphism equivalence. * Only does RDF term comparison. */ public static boolean isomorphic(ResultSet rs1, ResultSet rs2) { Model m1 = ResultSetFormatter.toModel(rs1) ; Model m2 = ResultSetFormatter.toModel(rs2) ; return m1.isIsomorphicWith(m2) ; }
/** Compare two result sets for bNode isomorphism equivalence. * Only does RDF term comparison. */ public static boolean isomorphic(ResultSet rs1, ResultSet rs2) { Model m1 = ResultSetFormatter.toModel(rs1) ; Model m2 = ResultSetFormatter.toModel(rs2) ; return m1.isIsomorphicWith(m2) ; }
@Override public boolean isIsomorphicWith(Model other) { if(other instanceof ModelImplJena) { return this.jenaModel.isIsomorphicWith(((ModelImplJena)other).getInternalJenaModel()); } else { // TODO: reasoning might be different ModelImplJena otherJenaModel = new ModelImplJena(Reasoning.none); otherJenaModel.addAll(other.iterator()); return this.jenaModel.isIsomorphicWith(otherJenaModel.getInternalJenaModel()); } }
public boolean checkModel(Model actual, String expectedFile) { Model expected = EldaFileManager.get().loadModel(expectedFile); if ( ! expected.isIsomorphicWith(actual)) { System.out.println("Model check failed, found:"); actual.write(System.out, "Turtle"); return false; } else { return true; } }
@Test public void testConfigLoader() { Model m = ConfigLoader.loadModelExpanding("includefiles/toplevel.ttl"); assertTrue(m.isIsomorphicWith(testModel)); } }
private void rtRJRg(String filename) throws Exception { final Model model = loadModelFromClasspathResource("/com/github/jsonldjava/jena/" + filename); // Write a JSON-LD final ByteArrayOutputStream out = new ByteArrayOutputStream(); RDFDataMgr.write(out, model, JSONLD); final ByteArrayInputStream r = new ByteArrayInputStream(out.toByteArray()); // Read as JSON-LD final Model model2 = ModelFactory.createDefaultModel(); RDFDataMgr.read(model2, r, null, JSONLD); assertFalse("JSON-LD model was empty", model2.isEmpty()); // Compare if (!model.isIsomorphicWith(model2)) { System.out.println("## ---- DIFFERENT"); } } }
@Test public void testModelEncode() { Model src = ModelIOUtils.modelFromTurtle(":r :p 42; :q :r2. :r2 :p 24 ."); Context context = new Context(); JsonObject obj = Encoder.get(context).encode(src); String encoding = obj.toString(); Model dec = Decoder.decodeModel(context, new StringReader(encoding) ); assertTrue( dec.isIsomorphicWith(src) ); } }
@Test public void testIncludeReaderTriple() throws IOException { Model m = ModelFactory.createDefaultModel(); Reader r = new IncludeReader("includefiles/toplevel.ttl"); m.read(r, "", "TTL"); r.close(); // Model expect = ModelFactory.createDefaultModel(); Resource S = expect.createResource(ELDA_API.NS + "example"); Property P = RDF.type; RDFNode O = XSD.xstring; expect.add(S, P, O); // if (!m.isIsomorphicWith(expect)) fail("did not read concatenated turtle."); // System.err.println(">> OK."); }
private void graphJ2R(String inResource, String outResource) throws Exception { final Model model1 = loadModelFromClasspathResource("/com/github/jsonldjava/jena/" + inResource); assertFalse("Failed to load input model from classpath: " + inResource, model1.isEmpty()); final Model model2 = loadModelFromClasspathResource("/com/github/jsonldjava/jena/" + outResource); assertFalse("Failed to load output model from classpath: " + outResource, model2.isEmpty()); assertTrue("Input graph " + inResource + " not isomorphic to output dataset" + outResource, model1.isIsomorphicWith(model2)); }
@Test public void query1() { Dataset ds = create() ; Model m = ds.getDefaultModel() ; load1(m) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE {?s ?p ?o}" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
/** * Test method for * {@link net.sf.taverna.t2.reference.sadi.RDFReference#setContents(java.lang.String)} * . */ @Test public void testSetContents() { rdfReference.setContents("5"); assertEquals("5", rdfReference.getContents()); rdfReference.setContents(rdfURIResourceString); assertTrue(rdfReference.getContents().contains( "UniProt_Record rdf:about=\"http://purl.uniprot.org/uniprot/P12345\"")); rdfReference.setContents(rdfResourceString); Model model1 = ModelFactory.createDefaultModel().read(new StringReader(rdfResourceString), null); Model model2 = ModelFactory.createDefaultModel().read( new StringReader(rdfReference.getContents()), null); assertTrue(model1.isIsomorphicWith(model2)); }
@Test public void special1() { Dataset ds = create() ; Model m = ds.getDefaultModel() ; load1(m) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE { GRAPH <"+defaultGraph+"> {?s ?p ?o}}" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void special2() { Dataset ds = create() ; load1(ds.getDefaultModel()) ; load2(ds.getNamedModel("http://example/graph1")) ; load3(ds.getNamedModel("http://example/graph2")) ; Model m = ModelFactory.createDefaultModel() ; load2(m) ; load3(m) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE { GRAPH <"+unionGraph+"> {?s ?p ?o}}" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void generalDataset3() { Dataset ds = create() ; load1(ds.getDefaultModel()) ; load2(ds.getNamedModel("http://example/graph1")) ; load3(ds.getNamedModel("http://example/graph2")) ; Model m = ds.getDefaultModel() ; // Use the default model in one dataset as a named model in another. DataSource ds2 = DatasetFactory.create() ; ds2.addNamedModel("http://example/graphOther", m) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE { {?s ?p ?o} UNION { GRAPH <http://example/graphOther> {?s ?p ?o} } }" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds2) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void generalDataset2() { Dataset ds = create() ; load1(ds.getDefaultModel()) ; load2(ds.getNamedModel("http://example/graph1")) ; load3(ds.getNamedModel("http://example/graph2")) ; Model m = ds.getNamedModel("http://example/graph2") ; // Use graph1 as a differently named model. DataSource ds2 = DatasetFactory.create() ; ds2.addNamedModel("http://example/graphOther", m) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE { {?s ?p ?o} UNION { GRAPH <http://example/graphOther> {?s ?p ?o} } }" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds2) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void generalDataset1() { Dataset ds = create() ; load1(ds.getDefaultModel()) ; load2(ds.getNamedModel("http://example/graph1")) ; load3(ds.getNamedModel("http://example/graph2")) ; Model m = ds.getNamedModel("http://example/graph2") ; // Use graph2 as default model. DataSource ds2 = DatasetFactory.create() ; ds2.setDefaultModel(ds.getNamedModel("http://example/graph2")) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE { ?s ?p ?o}" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds2) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void special3() { Dataset ds = create() ; load1(ds.getDefaultModel()) ; load2(ds.getNamedModel("http://example/graph1")) ; load3(ds.getNamedModel("http://example/graph2")) ; Model m = ModelFactory.createDefaultModel() ; load2(m) ; load3(m) ; String qs = "CONSTRUCT {?s ?p ?o } WHERE { ?s ?p ?o }" ; Query q = QueryFactory.create(qs) ; QueryExecution qExec = QueryExecutionFactory.create(q, ds) ; qExec.getContext().set(TDB.symUnionDefaultGraph, true) ; Model m2 = qExec.execConstruct() ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void model_4() { Model assem = FileManager.get().loadModel(dir+"graph-assembler.ttl") ; Resource xDft = assem.getResource("http://example/test#graphDft") ; Resource xNamed = assem.getResource("http://example/test#graphNamed") ; Store store = create(assem) ; Model model1 = (Model)Assembler.general.open(xDft) ; Model model2 = (Model)Assembler.general.open(xNamed) ; // Check they are not connected to the same place in the store Resource s = model1.createResource() ; Property p = model1.createProperty("http://example/p") ; Literal o = model1.createLiteral("foo") ; model1.add(s,p,o) ; assertTrue(model1.contains(s, p, o)) ; assertTrue(model1.size() == 1 ) ; assertTrue(model2.size() == 0 ) ; assertFalse(model1.isIsomorphicWith(model2)) ; }