@@ -67,4 +67,69 @@ class SpeciesReMatchServiceSpec extends Specification implements ServiceUnitTest
67
67
result2 == resp2
68
68
}
69
69
70
+ void " search name server by name" () {
71
+ setup :
72
+ grailsApplication. config. namesmatching. url = " http://localhost:8080/"
73
+ grailsApplication. config. namesmatching. strategy = [" exactMatch" , " vernacularMatch" ]
74
+ def resp = [
75
+ " success" : true ,
76
+ " scientificName" : " Red" ,
77
+ " taxonConceptID" : " ALA_DR22913_1168_0" ,
78
+ " rank" : " genus" ,
79
+ " rankID" : 6000 ,
80
+ " lft" : 24693 ,
81
+ " rgt" : 24693 ,
82
+ " matchType" : " higherMatch" ,
83
+ " nameType" : " SCIENTIFIC" ,
84
+ " kingdom" : " Bamfordvirae" ,
85
+ " kingdomID" : " https://www.catalogueoflife.org/data/taxon/8TRHY" ,
86
+ " phylum" : " Nucleocytoviricota" ,
87
+ " phylumID" : " https://www.catalogueoflife.org/data/taxon/5G" ,
88
+ " classs" : " Megaviricetes" ,
89
+ " classID" : " https://www.catalogueoflife.org/data/taxon/6224M" ,
90
+ " order" : " Pimascovirales" ,
91
+ " orderID" : " https://www.catalogueoflife.org/data/taxon/623FC" ,
92
+ " family" : " Iridoviridae" ,
93
+ " familyID" : " https://www.catalogueoflife.org/data/taxon/BFM" ,
94
+ " genus" : " Red" ,
95
+ " genusID" : " ALA_DR22913_1168_0" ,
96
+ " issues" : [
97
+ " noIssue"
98
+ ]
99
+ ]
100
+ service. webService. getJson({it. contains(" search?q=" )}) >> resp
101
+ when :
102
+ def result = service. searchByName(" name" )
103
+
104
+ then :
105
+ result == null
106
+
107
+ when :
108
+ resp. matchType = " exactMatch"
109
+ def result2 = service. searchByName(" name" )
110
+
111
+ then :
112
+ service. webService. getJson({it. contains(" search?q=" )}) >> resp
113
+ result2 == [
114
+ scientificName : " Red" ,
115
+ commonName : null ,
116
+ guid : " ALA_DR22913_1168_0" ,
117
+ taxonRank : " genus"
118
+ ]
119
+
120
+ when :
121
+ resp. matchType = " vernacularMatch"
122
+ def result3 = service. searchByName(" name" , false , true )
123
+
124
+ then :
125
+ service. webService. getJson({it. contains(" searchByVernacularName" )}) >> resp
126
+ result3 == [
127
+ scientificName : " Red" ,
128
+ commonName : null ,
129
+ guid : " ALA_DR22913_1168_0" ,
130
+ taxonRank : " genus"
131
+ ]
132
+
133
+ }
134
+
70
135
}
0 commit comments