public void testBulkByModelReifying(boolean suppress) { Model m = modelWithStatements(ReificationStyle.Minimal, "a P b"); addReification(m, "x", "S P O"); addReification(m, "a", "x R y"); Model target = modelWithStatements(ReificationStyle.Minimal, ""); target.add(m, suppress); target.setNsPrefixes(PrefixMapping.Standard); assertIsoModels((suppress ? modelWithStatements("a P b") : m), target); }
/** * Check that a predicate for which no shortnames are defined in name map still gets a term * binding in the metadata. */ @Test public void testTermBindingsCoverAllPredicates() throws URISyntaxException { Resource thisPage = ResourceFactory.createResource("elda:thisPage"); String pageNumber = "1"; Bindings cc = new Bindings(); URI reqURI = new URI(""); // EndpointDetails spec = new EndpointDetails() { @Override public boolean isListEndpoint() { return true; } @Override public boolean hasParameterBasedContentNegotiation() { return false; } }; EndpointMetadata em = new EndpointMetadata(spec, thisPage, pageNumber, cc, reqURI); // PrefixMapping pm = PrefixMapping.Factory.create().setNsPrefix("this", "http://example.com/root#"); Model toScan = ModelIOUtils.modelFromTurtle(":a <http://example.com/root#predicate> :b."); toScan.setNsPrefixes(pm); Resource predicate = toScan.createProperty("http://example.com/root#predicate"); Model meta = ModelFactory.createDefaultModel(); Resource exec = meta.createResource("fake:exec"); ShortnameService sns = new StandardShortnameService(); // APIEndpoint.Request r = new APIEndpoint.Request( new Controls(), reqURI, cc ); CompleteContext c = new CompleteContext(CompleteContext.Mode.PreferPrefixes, sns.asContext(), pm) .include(toScan); em.addTermBindings(toScan, meta, exec, c); @SuppressWarnings("unused") Map<String, String> termBindings = c.Do(); Resource tb = meta.listStatements(null, API.termBinding, Any).nextStatement().getResource(); assertTrue(meta.contains(tb, API.label, "this_predicate")); assertTrue(meta.contains(tb, API.property, predicate)); }