@Test public void testFillInQuery$() throws Exception { String rawTemplate = loadResource("query_template_ng.sparql"); FillableQueryTemplate sut=new FillableQueryTemplate(); sut.setTemplate(rawTemplate); sut.setNamedGraphs(new HashSet<String>(Arrays.asList("graph1","graph2"))); Map<String,String> mappings=new HashMap<String,String>(); mappings.put("graph1", "http: mappings.put("graph2", "http: String result = sut.instantiate(mappings); System.out.println(String.format("Raw template:\n%s\nMappings: %s\nResult:\n%s",rawTemplate,mappings,result)); assertThat(result,equalTo(loadResource("resolved_query_template_ng.sparql"))); }
@Override protected final String fillInQuery(Map<String, String> namedGraphs) { String result=getTemplate(); for(Entry<String,String> entry:namedGraphs.entrySet()) { result=result.replace("${"+entry.getKey()+"}", "<"+entry.getValue()+">"); } return result; }
FillableQueryTemplate extends AbstractQueryTemplate { @Override protected final String fillInQuery(Map<String, String> namedGraphs) { String result=getTemplate(); for(Entry<String,String> entry:namedGraphs.entrySet()) { result=result.replace("${"+entry.getKey()+"}", "<"+entry.getValue()+">"); } return result; } }
FillableQueryTemplate extends AbstractQueryTemplate { @Override protected final String fillInQuery(Map<String, String> namedGraphs) { String result=getTemplate(); for(Entry<String,String> entry:namedGraphs.entrySet()) { result=result.replace("${"+entry.getKey()+"}", "<"+entry.getValue()+">"); } return result; }  }
FillableQueryTemplate extends AbstractQueryTemplate { @Override protected final String fillInQuery(Map<String, String> namedGraphs) { String result=getTemplate(); for(Entry<String,String> entry:namedGraphs.entrySet()) { result=result.replace("${"+entry.getKey()+"}", "<"+entry.getValue()+">"); } return result; }   }
FillableQueryTemplate extends AbstractQueryTemplate { @Override protected final String fillInQuery(Map<String, String> namedGraphs) { String result=getTemplate(); for(Entry<String,String> entry:namedGraphs.entrySet()) { result=result.replace("${"+entry.getKey()+"}", "<"+entry.getValue()+">"); } return result; }    }