Changeset 425 for trunk/test/integration/gscf/OntologyTests.groovy
- Timestamp:
- May 18, 2010, 8:39:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/integration/gscf/OntologyTests.groovy
r398 r425 3 3 import grails.test.* 4 4 import dbnp.data.* 5 5 6 6 7 /** … … 31 32 protected void setUp() { 32 33 super.setUp() 33 }34 35 protected void tearDown() {36 super.tearDown()37 }38 39 /**40 * Test creation and saving of ontologies and terms41 * and giveTerms and giveTermByName methods42 */43 void testAll () {44 45 // === TEST Ontology46 34 47 35 def ontology = new Ontology( … … 57 45 assert ontology.validate() 58 46 assert ontology.save(flush:true) 47 } 48 49 protected void tearDown() { 50 super.tearDown() 51 } 52 53 /** 54 * Test if ontology was properly saved 55 */ 56 void testSave () { 59 57 60 58 // Try to retrieve the ontology and make sure it's the same … … 68 66 assert ontologyDB.ncboVersionedId.equals(testOntologyNcboVersionedId) 69 67 70 // Apparently, the saved ontology is not persisted between test methods :-( 71 // Otherwise, we could separate these parts into different tests 68 } 72 69 73 // === TEST Term and giveTermByName 70 71 /** 72 * Test saving and retrieving a term within the ontology and test giveTermByName(name) 73 */ 74 void testTermSave() { 74 75 75 76 // Find created ontology … … 92 93 assert termDB.accession.equals(testAccession) 93 94 assert termDB.ontology == testOntology 95 } 94 96 95 // === TEST giveTerms 96 97 98 /** 99 * Test giveTerms() method 100 */ 101 void testGiveTerms() { 102 103 // Find created ontology 104 def testOntology = Ontology.findByName(testOntologyName) 105 assert testOntology 106 97 107 def terms = testOntology.giveTerms() 98 108 assert terms 99 109 assert terms.size() == 1 100 110 assert terms.asList().first().name.equals(testTermName) 111 } 101 112 113 114 /** 115 * Ontocat test (Ontocat example 1) 116 * 117 * Shows how to list all the available ontologies in OLS 118 * 119 */ 120 void testOntocat() { 121 // Instantiate OLS service 122 uk.ac.ebi.ontocat.OntologyService os = new uk.ac.ebi.ontocat.bioportal.BioportalOntologyService() 123 // For all ontologies in OLS print their 124 // full label and abbreviation 125 uk.ac.ebi.ontocat.Ontology o = os.getOntology("1005") 126 StringBuilder sb = new StringBuilder(); 127 sb.append(o.getAbbreviation()); 128 sb.append("\t"); 129 sb.append(o.getLabel()); 130 sb.append("\t"); 131 sb.append(o.getOntologyAccession()); 132 sb.append("\t"); 133 o.getVersionNumber() + o.getMetaPropertyValues().each { 134 sb.append(it.dump()) 135 } 136 System.out.println(sb.toString()); 137 102 138 } 139 103 140 }
Note: See TracChangeset
for help on using the changeset viewer.