RecommendationService { public RecommendationService(Anno4j anno4j) { this.algorithms = new HashMap<String, SimilarityAlgorithm>(); this.anno4j = anno4j; } RecommendationService(Anno4j anno4j);  RecommendationService(HashMap<String, SimilarityAlgorithm> algorithms); void generateSimilarity(Annotation subject, Annotation object, String algorithmName); void generateAllSimilarities(Annotation subject, Annotation object); void addAlgorithm(String key, SimilarityAlgorithm algorithm); void removeAlgorithm(String key); Map<String, SimilarityAlgorithm> getAlgorithms(); void setAlgorithms(Map<String, SimilarityAlgorithm> algorithms);  }
@Test public void testRecommendationService() throws QueryEvaluationException, RepositoryException, ParseException, MalformedQueryException, InstantiationException, IllegalAccessException { RecommendationService recommendationService = new RecommendationService(this.anno4j); assertEquals(0, recommendationService.getAlgorithms().size()); final String algorithmName = "algo1"; recommendationService.addAlgorithm(algorithmName, new SimpleSimilarityAlgorithm()); assertEquals(1, recommendationService.getAlgorithms().size()); Annotation anno1 = anno4j.createObject(Annotation.class); Annotation anno2 = anno4j.createObject(Annotation.class); List<Annotation> result = this.queryService.addCriteria("oa:hasBody[is-a arec:SimilarityStatement]").execute(); assertEquals(0, result.size()); recommendationService.generateSimilarity(anno1, anno2, algorithmName); result = this.queryService.execute(); assertEquals(1, result.size()); Annotation annotation = result.get(0); SimilarityStatement statement = (SimilarityStatement) annotation.getBodies().iterator().next(); assertEquals(new Double(1.0), (Double) statement.getSimilarity()); }