/
OntologyModelServiceTest.java
96 lines (81 loc) · 3.17 KB
/
OntologyModelServiceTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package org.dataone.cn.indexer.annotation;
import static org.junit.Assert.*;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "../../index/test-context.xml" })
public class OntologyModelServiceTest {
@Test
public void testConceptNotFoundExpansion() {
/**
* Test that the OntologyModelService returns just the concept you asked it to expand when
* we expect that no pre-loaded ontologies define superclasses for it.
*/
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("https://example.org");
// Assert on Solr fields returend
Set<String> fields = new HashSet<String>();
fields.add("annotation_property_uri");
fields.add("annotation_value_uri");
assertEquals(concepts.keySet(), fields);
// Assert on Solr field values returned
Set<String> values = new HashSet<String>();
values.add("https://example.org");
assertEquals(values, concepts.get("annotation_property_uri"));
assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}
@Test
public void testECSOMeasurementTypeExpansion() {
/**
*
*/
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("http://purl.dataone.org/odo/ECSO_00000543");
// Assert on Solr fields returend
Set<String> fields = new HashSet<String>();
fields.add("annotation_property_uri");
fields.add("annotation_value_uri");
assertEquals(concepts.keySet(), fields);
// Assert on Solr field values returned
Set<String> values = new HashSet<String>();
values.add("http://purl.dataone.org/odo/ECSO_00000536");
values.add("http://purl.dataone.org/odo/ECSO_00000543");
values.add("http://purl.dataone.org/odo/ECSO_00001105");
values.add("http://purl.dataone.org/odo/ECSO_00000514");
values.add("http://ecoinformatics.org/oboe/oboe.1.2/oboe-core.owl#MeasurementType");
values.add("http://www.w3.org/2000/01/rdf-schema#Resource");
assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}
@Test
public void testPropertyExpansion() {
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("http://purl.obolibrary.org/obo/RO_0002352");
Set<String> values = new HashSet<String>();
values.add("http://purl.obolibrary.org/obo/RO_0002328");
values.add("http://purl.obolibrary.org/obo/RO_0002352");
values.add("http://purl.obolibrary.org/obo/RO_0000056");
assertEquals(values, concepts.get("annotation_property_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}
}