RepositoryFederatedService implements FederatedService { protected String insertValuesClause(String queryString, String valuesClause) { StringBuilder sb = new StringBuilder(queryString); if (sb.indexOf(ROW_IDX_VAR) == -1) { if (sb.indexOf("SELECT * ") == -1) { sb.insert(sb.indexOf("SELECT") + 6, " ?" + ROW_IDX_VAR); } } sb.insert(sb.indexOf("{") + 1, " " + valuesClause); return sb.toString(); } RepositoryFederatedService(Repository repo);  RepositoryFederatedService(Repository repo, boolean shutDown); @Override CloseableIteration<BindingSet, QueryEvaluationException> select(Service service, Set<String> projectionVars,
			BindingSet bindings, String baseUri); @Override boolean ask(Service service, BindingSet bindings, String baseUri); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Service service,
			CloseableIteration<BindingSet, QueryEvaluationException> bindings, String baseUri); @Override void initialize(); @Override boolean isInitialized(); int getBoundJoinBlockSize(); void setBoundJoinBlockSize(int boundJoinBlockSize); void setUseFreshConnection(boolean flag); @Override void shutdown();  }
@Test public void testInsertValuesClause() throws Exception { RepositoryFederatedService inst = new RepositoryFederatedService(null); Assert.assertEquals( "SELECT ?s ?var ?__rowIdx WHERE { VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) } ?s ?p ?var }", inst.insertValuesClause("SELECT ?s ?var ?__rowIdx WHERE { ?s ?p ?var }", "VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }")); Assert.assertEquals( "SELECT ?s ?var ?__rowIdx WHERE { VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }?s ?p ?var}", inst.insertValuesClause("SELECT ?s ?var ?__rowIdx WHERE {?s ?p ?var}", "VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }")); Assert.assertEquals( "SELECT ?s ?var ?__rowIdx { VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) } ?s ?p ?varv}", inst.insertValuesClause("SELECT ?s ?var ?__rowIdx { ?s ?p ?varv}", "VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }")); Assert.assertEquals( "SELECT ?__rowIdx ?s ?var WHERE { VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) } ?s ?p ?var }", inst.insertValuesClause("SELECT ?s ?var WHERE { ?s ?p ?var }", "VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }")); Assert.assertEquals( "SELECT * WHERE { VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) } ?s ?p ?var }", inst.insertValuesClause("SELECT * WHERE { ?s ?p ?var }", "VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }")); Assert.assertEquals( "SELECT ?__rowIdx * WHERE { VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) } ?s ?p ?var }", inst.insertValuesClause("SELECT * WHERE { ?s ?p ?var }", "VALUES (?var ?__rowIdx) { (:val1 1) (:val2 2) }")); }