KnowledgeCardCreator { public String process(String uri) throws JsonGenerationException, IOException { String query = PREFIXES + "SELECT (GROUP_CONCAT(distinct ?type;separator=' ') as ?types) (GROUP_CONCAT(distinct ?property;separator=' ') as ?properties) WHERE {\n" + "<" + uri + "> rdf:type ?type . FILTER(STRSTARTS(STR(?type), 'http: + "<" + uri + "> ?property ?value . FILTER(STRSTARTS(STR(?property), 'http: QueryExecution queryExecution = executeQuery(query); Iterator<QuerySolution> results = queryExecution.execSelect(); LinkedHashSet<Field> fields = new LinkedHashSet<>(); while (results.hasNext()) { QuerySolution solution = results.next(); if (solution.get("types") != null && solution.get("properties") != null) { List<String> types = Arrays.asList(solution.get("types").asLiteral().getString().split(" ")); String[] split = solution.get("properties").asLiteral().getString().split(" "); HashSet<String> properties = Sets .newHashSet(split); List<Field> relevantProperties = getRelevantProperties(uri, types, properties); fields.addAll(relevantProperties); } } queryExecution.close(); return JsonUtils.toPrettyString(fields); }  String process(String uri); List<Field> getRelevantProperties(String uri, List<String> Answer, HashSet<String> properties);  }
@Test public void knowledgeCardTest() throws JsonGenerationException, IOException { String uri = "http: String answerCard = knowledgeCardCreator.process(uri); Assert.assertTrue(answerCard.equals(realCard)); }