1 |
8717
|
leinfelder
|
/** '$RCSfile$'
|
2 |
|
|
* Copyright: 2010 Regents of the University of California and the
|
3 |
|
|
* National Center for Ecological Analysis and Synthesis
|
4 |
|
|
*
|
5 |
|
|
* This program is free software; you can redistribute it and/or modify
|
6 |
|
|
* it under the terms of the GNU General Public License as published by
|
7 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
* (at your option) any later version.
|
9 |
|
|
*
|
10 |
|
|
* This program is distributed in the hope that it will be useful,
|
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
* GNU General Public License for more details.
|
14 |
|
|
*
|
15 |
|
|
* You should have received a copy of the GNU General Public License
|
16 |
|
|
* along with this program; if not, write to the Free Software
|
17 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
*/
|
19 |
|
|
package edu.ucsb.nceas.metacat.annotation;
|
20 |
|
|
|
21 |
|
|
import com.hp.hpl.jena.ontology.OntClass;
|
22 |
|
|
import com.hp.hpl.jena.ontology.OntModel;
|
23 |
|
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
24 |
|
|
import com.hp.hpl.jena.rdf.model.Resource;
|
25 |
|
|
|
26 |
|
|
import junit.framework.Test;
|
27 |
|
|
import junit.framework.TestSuite;
|
28 |
|
|
import edu.ucsb.nceas.MCTestCase;
|
29 |
|
|
|
30 |
|
|
public class BioPortalServiceTest extends MCTestCase {
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**
|
34 |
|
|
* constructor for the test
|
35 |
|
|
*/
|
36 |
|
|
public BioPortalServiceTest(String name) {
|
37 |
|
|
super(name);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
/**
|
41 |
|
|
* Establish a testing framework by initializing appropriate objects
|
42 |
|
|
*/
|
43 |
|
|
public void setUp() throws Exception {
|
44 |
|
|
super.setUp();
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* Release any objects after tests are complete
|
49 |
|
|
*/
|
50 |
|
|
public void tearDown() {
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Create a suite of tests to be run together
|
55 |
|
|
*/
|
56 |
|
|
public static Test suite() {
|
57 |
|
|
TestSuite suite = new TestSuite();
|
58 |
|
|
suite.addTest(new BioPortalServiceTest("testLookup"));
|
59 |
|
|
return suite;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
public void testLookup() {
|
63 |
|
|
// set up our simple model for testing: Characteristic <- Temperature
|
64 |
|
|
OntModel m = ModelFactory.createOntologyModel();
|
65 |
|
|
OntClass characteristicClass = m.createClass(DatapackageSummarizer.oboe_core + "Characteristic");
|
66 |
|
|
OntClass temperatureClass = m.createClass(DatapackageSummarizer.oboe_characteristics + "Temperature");
|
67 |
|
|
temperatureClass.addSuperClass(characteristicClass);
|
68 |
|
|
|
69 |
|
|
// look up the annotation recommendation from BioPortal
|
70 |
|
|
String text = "Air temperature";
|
71 |
|
|
Resource retClass = BioPortalService.lookupAnnotationClass(characteristicClass, text, DatapackageSummarizer.OBOE_SBC);
|
72 |
|
|
assertEquals(DatapackageSummarizer.oboe_characteristics + "Temperature", retClass.getURI());
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
}
|