use of org.molgenis.data.DatabaseAction.ADD in project molgenis by molgenis.
the class OntologyImportServiceIT method verifyOwlAsSystem.
private void verifyOwlAsSystem() {
// Verify two imported rows (organization and team, as these are interesting examples)
List<Entity> entities = dataService.findAll("sys_ont_OntologyTerm").collect(Collectors.toList());
Optional<Entity> organizationOpt = entities.stream().filter(e -> e.getString("ontologyTermName").equals("organization")).findFirst();
assertTrue(organizationOpt.isPresent());
Entity organization = organizationOpt.get();
Optional<Entity> teamOpt = entities.stream().filter(e -> e.getString("ontologyTermName").equals("team")).findFirst();
assertTrue(teamOpt.isPresent());
Entity team = teamOpt.get();
// Verify organization
assertEquals(organization.getString("ontologyTermIRI"), "http://www.molgenis.org#Organization");
assertEquals(organization.getString("ontologyTermName"), "organization");
// verify organization ontologyTermSynonym
Iterable<Entity> ontologyTermSynonym = organization.getEntities("ontologyTermSynonym");
List<Entity> termSynonymRefList = new ArrayList<>();
ontologyTermSynonym.forEach(termSynonymRefList::add);
assertEquals(termSynonymRefList.size(), 1);
Entity organizationOntologyTermSynonym = dataService.findOneById("sys_ont_OntologyTermSynonym", termSynonymRefList.get(0).getIdValue());
assertEquals(organizationOntologyTermSynonym.getString("ontologyTermSynonym"), "organization");
// verify organization ontology
Ontology ontology = (Ontology) organization.get("ontology");
assertEquals(ontology.getOntologyName(), "ontology-small");
// Verify the team row
assertEquals(team.getString("ontologyTermIRI"), "http://www.molgenis.org#Team");
assertEquals(team.getString("ontologyTermName"), "team");
// verify team dynamic annotations
Iterable<Entity> dynamicAnnotationItr = team.getEntities("ontologyTermDynamicAnnotation");
List<Entity> dynamicAnnotations = new ArrayList<>();
dynamicAnnotationItr.forEach(dynamicAnnotations::add);
assertEquals(dynamicAnnotations.size(), 2);
Entity annotationOne = dataService.findOneById("sys_ont_OntologyTermDynamicAnnotation", dynamicAnnotations.get(0).getIdValue());
assertEquals(annotationOne.getString("label"), "friday:2412423");
Entity annotationTwo = dataService.findOneById("sys_ont_OntologyTermDynamicAnnotation", dynamicAnnotations.get(1).getIdValue());
assertEquals(annotationTwo.getString("label"), "molgenis:1231424");
// verify team ontology
ontology = (Ontology) team.get("ontology");
assertEquals(ontology.getOntologyName(), "ontology-small");
}
Aggregations