33 |
33 |
import org.junit.After;
|
34 |
34 |
import org.junit.AfterClass;
|
35 |
35 |
import org.junit.Before;
|
36 |
|
import org.junit.BeforeClass;
|
37 |
36 |
import org.junit.Test;
|
38 |
37 |
import org.unitils.spring.annotation.SpringBeanByType;
|
39 |
38 |
|
40 |
39 |
import eu.etaxonomy.cdm.common.CdmUtils;
|
41 |
40 |
import eu.etaxonomy.cdm.common.StreamUtils;
|
42 |
41 |
import eu.etaxonomy.cdm.common.UriUtils;
|
43 |
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
44 |
42 |
import eu.etaxonomy.cdm.model.common.Language;
|
45 |
43 |
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
46 |
44 |
import eu.etaxonomy.cdm.model.description.AbsenceTerm;
|
... | ... | |
60 |
58 |
* @version 1.0
|
61 |
59 |
*/
|
62 |
60 |
public class EditGeoServiceTest extends CdmIntegrationTest {
|
63 |
|
@SuppressWarnings("unused")
|
64 |
|
private static final Logger logger = Logger.getLogger(EditGeoServiceTest.class);
|
|
61 |
@SuppressWarnings("unused")
|
|
62 |
private static final Logger logger = Logger.getLogger(EditGeoServiceTest.class);
|
65 |
63 |
|
66 |
|
private static final String EDIT_MAPSERVICE_URI_STING = "http://edit.br.fgov.be/edit_wp5/v1/areas.php";
|
67 |
|
private static URI editMapServiceUri;
|
|
64 |
private static final String EDIT_MAPSERVICE_URI_STING = "http://edit.br.fgov.be/edit_wp5/v1/areas.php";
|
|
65 |
private static URI editMapServiceUri;
|
68 |
66 |
|
69 |
|
//@SpringBeanByType
|
70 |
|
private IDefinedTermDao termDao;
|
|
67 |
//@SpringBeanByType
|
|
68 |
private IDefinedTermDao termDao;
|
71 |
69 |
|
72 |
|
@SpringBeanByType
|
73 |
|
private GeoServiceAreaAnnotatedMapping mapping;
|
|
70 |
@SpringBeanByType
|
|
71 |
private GeoServiceAreaAnnotatedMapping mapping;
|
74 |
72 |
|
75 |
73 |
//
|
76 |
74 |
// /**
|
... | ... | |
82 |
80 |
// initializer.initialize();
|
83 |
81 |
// }
|
84 |
82 |
|
85 |
|
/**
|
86 |
|
* @throws java.lang.Exception
|
87 |
|
*/
|
88 |
|
@AfterClass
|
89 |
|
public static void tearDownAfterClass() throws Exception {
|
90 |
|
}
|
91 |
|
|
92 |
|
/**
|
93 |
|
* @throws java.lang.Exception
|
94 |
|
*/
|
95 |
|
@Before
|
96 |
|
public void setUp() throws Exception {
|
97 |
|
EditGeoServiceUtilities.setTermDao(termDao);
|
98 |
|
System.setProperty("ONLY-A-TEST", "TRUE"); // allows EditGeoServiceUtilities to skip some line of code
|
99 |
|
editMapServiceUri = new URI(EDIT_MAPSERVICE_URI_STING);
|
100 |
|
}
|
101 |
|
|
102 |
|
/**
|
103 |
|
* @throws java.lang.Exception
|
104 |
|
*/
|
105 |
|
@After
|
106 |
|
public void tearDown() throws Exception {
|
107 |
|
}
|
|
83 |
/**
|
|
84 |
* @throws java.lang.Exception
|
|
85 |
*/
|
|
86 |
@AfterClass
|
|
87 |
public static void tearDownAfterClass() throws Exception {
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* @throws java.lang.Exception
|
|
92 |
*/
|
|
93 |
@Before
|
|
94 |
public void setUp() throws Exception {
|
|
95 |
EditGeoServiceUtilities.setTermDao(termDao);
|
|
96 |
System.setProperty("ONLY-A-TEST", "TRUE"); // allows EditGeoServiceUtilities to skip some line of code
|
|
97 |
editMapServiceUri = new URI(EDIT_MAPSERVICE_URI_STING);
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
* @throws java.lang.Exception
|
|
102 |
*/
|
|
103 |
@After
|
|
104 |
public void tearDown() throws Exception {
|
|
105 |
}
|
108 |
106 |
|
109 |
107 |
//******************************************** TESTS**************
|
110 |
|
@Test
|
111 |
|
public void testGetWebServiceUrlTdwg() throws MalformedURLException, IOException {
|
112 |
|
//String webServiceUrl = "http://www.test.de/webservice";
|
113 |
|
Set<Distribution> distributions = new HashSet<Distribution>();
|
114 |
|
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("SPA"), PresenceTerm.PRESENT()));
|
115 |
|
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("GER"), PresenceTerm.INTRODUCED()));
|
116 |
|
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("14"), PresenceTerm.CULTIVATED()));
|
117 |
|
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("BGM"), AbsenceTerm.ABSENT()));
|
118 |
|
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("FRA"), AbsenceTerm.ABSENT()));
|
119 |
|
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("IND-AP"), PresenceTerm.PRESENT()));
|
120 |
|
|
121 |
|
Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
|
122 |
|
presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
|
123 |
|
presenceAbsenceColorMap.put(PresenceTerm.INTRODUCED(), Color.BLACK);
|
124 |
|
presenceAbsenceColorMap.put(PresenceTerm.CULTIVATED(), Color.YELLOW);
|
125 |
|
presenceAbsenceColorMap.put(AbsenceTerm.ABSENT(), Color.DARK_GRAY);
|
126 |
|
String backLayer ="";
|
127 |
|
presenceAbsenceColorMap = null;
|
128 |
|
String bbox="-20,0,120,70";
|
129 |
|
List<Language> languages = new ArrayList<Language>();
|
130 |
|
|
131 |
|
String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );
|
132 |
|
//TODO Set semantics is not determined
|
133 |
|
//String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
|
134 |
|
System.out.println(result);
|
135 |
|
assertTrue(result.matches(".*l=earth.*"));
|
136 |
|
assertTrue(result.matches(".*ms=600,300.*"));
|
137 |
|
assertTrue(result.matches(".*ad=tdwg[1-4].*"));
|
138 |
|
assertTrue(result.matches(".*tdwg2:[a-d]:14[\\|&].*") );
|
139 |
|
assertTrue(result.matches(".*[a-d]:FRA,BGM[\\|&].*") || result.matches(".*[a-d]:BGM,FRA[\\|&].*") );
|
140 |
|
assertTrue(result.matches(".*[a-d]:GER[\\|&].*") );
|
141 |
|
assertTrue(result.matches(".*[a-d]:SPA[\\|&].*") );
|
142 |
|
assertTrue(result.matches(".*tdwg4:[a-d]:INDAP[\\|&].*") );
|
143 |
|
//assertTrue(result.matches("0000ff"));
|
144 |
|
//TODO continue
|
145 |
|
|
146 |
|
// request map image from webservice
|
147 |
|
subTestWithEditMapService(result);
|
148 |
|
}
|
149 |
|
|
150 |
|
@Test
|
151 |
|
public void testGetWebServiceUrlCyprus() throws ClientProtocolException, IOException, URISyntaxException {
|
152 |
|
makeCyprusAreas();
|
153 |
|
Set<Distribution> distributions = new HashSet<Distribution>();
|
154 |
|
distributions.add(Distribution.NewInstance(divisions.get("1"), PresenceTerm.PRESENT()));
|
155 |
|
distributions.add(Distribution.NewInstance(divisions.get("2"), PresenceTerm.INTRODUCED()));
|
156 |
|
distributions.add(Distribution.NewInstance(divisions.get("3"), PresenceTerm.CULTIVATED()));
|
157 |
|
distributions.add(Distribution.NewInstance(divisions.get("4"), AbsenceTerm.ABSENT()));
|
158 |
|
distributions.add(Distribution.NewInstance(divisions.get("5"), AbsenceTerm.ABSENT()));
|
159 |
|
distributions.add(Distribution.NewInstance(divisions.get("6"), PresenceTerm.PRESENT()));
|
160 |
|
|
161 |
|
Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
|
162 |
|
presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
|
163 |
|
presenceAbsenceColorMap.put(PresenceTerm.INTRODUCED(), Color.BLACK);
|
164 |
|
presenceAbsenceColorMap.put(PresenceTerm.CULTIVATED(), Color.YELLOW);
|
165 |
|
presenceAbsenceColorMap.put(AbsenceTerm.ABSENT(), Color.DARK_GRAY);
|
166 |
|
String backLayer ="";
|
167 |
|
presenceAbsenceColorMap = null;
|
168 |
|
String bbox="-20,0,120,70";
|
169 |
|
List<Language> languages = new ArrayList<Language>();
|
170 |
|
|
171 |
|
String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );
|
172 |
|
//TODO Set semantics is not determined
|
173 |
|
//String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
|
174 |
|
assertTrue(result.matches(".*l=earth.*"));
|
175 |
|
assertTrue(result.matches(".*ms=600,300.*"));
|
176 |
|
assertTrue(result.matches(".*ad=cyprusdivs%3Abdcode:.*"));
|
177 |
|
assertTrue(result.matches(".*[a-d]:5,4[\\|&].*") || result.matches(".*[a-d]:4,5[\\|&].*") );
|
178 |
|
assertTrue(result.matches(".*[a-d]:1,6[\\|&].*") || result.matches(".*[a-d]:6,1[\\|&].*") );
|
179 |
|
assertTrue(result.matches(".*[a-d]:2[\\|&].*") );
|
180 |
|
assertTrue(result.matches(".*[a-d]:3[\\|&].*") );
|
181 |
|
|
182 |
|
// request map image from webservice
|
183 |
|
subTestWithEditMapService(result);
|
184 |
|
}
|
185 |
|
|
186 |
|
private void subTestWithEditMapService(String result)throws MalformedURLException, IOException {
|
187 |
|
if(UriUtils.isServiceAvailable(editMapServiceUri)){
|
188 |
|
URL requestUrl = new URL(editMapServiceUri.toString() + "?img=false&" + result);
|
189 |
|
HttpURLConnection connection = (HttpURLConnection) requestUrl.openConnection();
|
190 |
|
connection.connect();
|
191 |
|
assertTrue(connection.getResponseCode() == 200);
|
192 |
|
InputStream contentStream = connection.getInputStream();
|
193 |
|
String content = StreamUtils.readToString(contentStream);
|
194 |
|
System.out.println(content);
|
195 |
|
assertTrue(content.startsWith("[{"));
|
196 |
|
assertTrue(content.endsWith("}]"));
|
197 |
|
assertTrue(content.matches(".*\"bbox\":.*"));
|
198 |
|
assertTrue(content.matches(".*\"legend\":.*"));
|
199 |
|
assertTrue(content.matches(".*\"layers\":.*"));
|
200 |
|
assertTrue(content.matches(".*\"sld\":.*"));
|
201 |
|
assertTrue(content.matches(".*\"geoserver\":.*"));
|
202 |
|
}
|
203 |
|
}
|
204 |
|
|
205 |
|
public static final UUID uuidCyprusDivisionsVocabulary = UUID.fromString("2119f610-1f93-4d87-af28-40aeefaca100");
|
206 |
|
private Map<String, NamedArea> divisions = new HashMap<String, NamedArea>();
|
207 |
|
|
208 |
|
private boolean makeCyprusAreas() {
|
209 |
|
//divisions
|
210 |
|
|
211 |
|
|
212 |
|
NamedAreaType areaType = NamedAreaType.NATURAL_AREA();
|
213 |
|
NamedAreaLevel areaLevel = NamedAreaLevel.NewInstance("Cyprus Division", "Cyprus Division", null);
|
214 |
|
|
215 |
|
TermVocabulary areaVocabulary = TermVocabulary.NewInstance("Cyprus devisions", "Cyprus divisions", null, null);
|
216 |
|
areaVocabulary.setUuid(uuidCyprusDivisionsVocabulary);
|
217 |
|
|
218 |
|
for(int i = 1; i <= 8; i++){
|
219 |
|
UUID divisionUuid = getNamedAreaUuid(String.valueOf(i));
|
220 |
|
NamedArea division = this.getNamedArea(divisionUuid, "Division " + i, "Cyprus: Division " + i, String.valueOf(i), areaType, areaLevel, areaVocabulary);
|
221 |
|
divisions.put(String.valueOf(i), division);
|
222 |
|
}
|
|
108 |
@Test
|
|
109 |
public void testGetWebServiceUrlTdwg() throws MalformedURLException, IOException {
|
|
110 |
//String webServiceUrl = "http://www.test.de/webservice";
|
|
111 |
Set<Distribution> distributions = new HashSet<Distribution>();
|
|
112 |
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("SPA"), PresenceTerm.PRESENT()));
|
|
113 |
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("GER"), PresenceTerm.INTRODUCED()));
|
|
114 |
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("14"), PresenceTerm.CULTIVATED()));
|
|
115 |
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("BGM"), AbsenceTerm.ABSENT()));
|
|
116 |
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("FRA"), AbsenceTerm.ABSENT()));
|
|
117 |
distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("IND-AP"), PresenceTerm.PRESENT()));
|
|
118 |
|
|
119 |
Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
|
|
120 |
presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
|
|
121 |
presenceAbsenceColorMap.put(PresenceTerm.INTRODUCED(), Color.BLACK);
|
|
122 |
presenceAbsenceColorMap.put(PresenceTerm.CULTIVATED(), Color.YELLOW);
|
|
123 |
presenceAbsenceColorMap.put(AbsenceTerm.ABSENT(), Color.DARK_GRAY);
|
|
124 |
String backLayer ="";
|
|
125 |
presenceAbsenceColorMap = null;
|
|
126 |
String bbox="-20,0,120,70";
|
|
127 |
List<Language> languages = new ArrayList<Language>();
|
|
128 |
|
|
129 |
String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );
|
|
130 |
//TODO Set semantics is not determined
|
|
131 |
//String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
|
|
132 |
System.out.println(result);
|
|
133 |
assertTrue(result.matches(".*l=earth.*"));
|
|
134 |
assertTrue(result.matches(".*ms=600,300.*"));
|
|
135 |
assertTrue(result.matches(".*ad=tdwg[1-4].*"));
|
|
136 |
assertTrue(result.matches(".*tdwg2:[a-d]:14[\\|&].*") );
|
|
137 |
assertTrue(result.matches(".*[a-d]:FRA,BGM[\\|&].*") || result.matches(".*[a-d]:BGM,FRA[\\|&].*") );
|
|
138 |
assertTrue(result.matches(".*[a-d]:GER[\\|&].*") );
|
|
139 |
assertTrue(result.matches(".*[a-d]:SPA[\\|&].*") );
|
|
140 |
assertTrue(result.matches(".*tdwg4:[a-d]:INDAP[\\|&].*") );
|
|
141 |
//assertTrue(result.matches("0000ff"));
|
|
142 |
//TODO continue
|
|
143 |
|
|
144 |
// request map image from webservice
|
|
145 |
subTestWithEditMapService(result);
|
|
146 |
}
|
|
147 |
|
|
148 |
@Test
|
|
149 |
public void testGetWebServiceUrlCyprus() throws ClientProtocolException, IOException, URISyntaxException {
|
|
150 |
makeCyprusAreas();
|
|
151 |
Set<Distribution> distributions = new HashSet<Distribution>();
|
|
152 |
distributions.add(Distribution.NewInstance(divisions.get("1"), PresenceTerm.PRESENT()));
|
|
153 |
distributions.add(Distribution.NewInstance(divisions.get("2"), PresenceTerm.INTRODUCED()));
|
|
154 |
distributions.add(Distribution.NewInstance(divisions.get("3"), PresenceTerm.CULTIVATED()));
|
|
155 |
distributions.add(Distribution.NewInstance(divisions.get("4"), AbsenceTerm.ABSENT()));
|
|
156 |
distributions.add(Distribution.NewInstance(divisions.get("5"), AbsenceTerm.ABSENT()));
|
|
157 |
distributions.add(Distribution.NewInstance(divisions.get("6"), PresenceTerm.PRESENT()));
|
|
158 |
|
|
159 |
Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
|
|
160 |
presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
|
|
161 |
presenceAbsenceColorMap.put(PresenceTerm.INTRODUCED(), Color.BLACK);
|
|
162 |
presenceAbsenceColorMap.put(PresenceTerm.CULTIVATED(), Color.YELLOW);
|
|
163 |
presenceAbsenceColorMap.put(AbsenceTerm.ABSENT(), Color.DARK_GRAY);
|
|
164 |
String backLayer ="";
|
|
165 |
presenceAbsenceColorMap = null;
|
|
166 |
String bbox="-20,0,120,70";
|
|
167 |
List<Language> languages = new ArrayList<Language>();
|
|
168 |
|
|
169 |
String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );
|
|
170 |
//TODO Set semantics is not determined
|
|
171 |
//String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
|
|
172 |
assertTrue(result.matches(".*l=earth.*"));
|
|
173 |
assertTrue(result.matches(".*ms=600,300.*"));
|
|
174 |
assertTrue(result.matches(".*ad=cyprusdivs%3Abdcode:.*"));
|
|
175 |
assertTrue(result.matches(".*[a-d]:5,4[\\|&].*") || result.matches(".*[a-d]:4,5[\\|&].*") );
|
|
176 |
assertTrue(result.matches(".*[a-d]:1,6[\\|&].*") || result.matches(".*[a-d]:6,1[\\|&].*") );
|
|
177 |
assertTrue(result.matches(".*[a-d]:2[\\|&].*") );
|
|
178 |
assertTrue(result.matches(".*[a-d]:3[\\|&].*") );
|
|
179 |
|
|
180 |
// request map image from webservice
|
|
181 |
subTestWithEditMapService(result);
|
|
182 |
}
|
|
183 |
|
|
184 |
private void subTestWithEditMapService(String result)throws MalformedURLException, IOException {
|
|
185 |
if(UriUtils.isServiceAvailable(editMapServiceUri)){
|
|
186 |
URL requestUrl = new URL(editMapServiceUri.toString() + "?img=false&" + result);
|
|
187 |
HttpURLConnection connection = (HttpURLConnection) requestUrl.openConnection();
|
|
188 |
connection.connect();
|
|
189 |
assertTrue(connection.getResponseCode() == 200);
|
|
190 |
InputStream contentStream = connection.getInputStream();
|
|
191 |
String content = StreamUtils.readToString(contentStream);
|
|
192 |
System.out.println(content);
|
|
193 |
assertTrue(content.startsWith("[{"));
|
|
194 |
assertTrue(content.endsWith("}]"));
|
|
195 |
assertTrue(content.matches(".*\"bbox\":.*"));
|
|
196 |
assertTrue(content.matches(".*\"legend\":.*"));
|
|
197 |
assertTrue(content.matches(".*\"layers\":.*"));
|
|
198 |
assertTrue(content.matches(".*\"sld\":.*"));
|
|
199 |
assertTrue(content.matches(".*\"geoserver\":.*"));
|
|
200 |
}
|
|
201 |
}
|
|
202 |
|
|
203 |
public static final UUID uuidCyprusDivisionsVocabulary = UUID.fromString("2119f610-1f93-4d87-af28-40aeefaca100");
|
|
204 |
private Map<String, NamedArea> divisions = new HashMap<String, NamedArea>();
|
|
205 |
|
|
206 |
private boolean makeCyprusAreas() {
|
|
207 |
//divisions
|
|
208 |
|
|
209 |
|
|
210 |
NamedAreaType areaType = NamedAreaType.NATURAL_AREA();
|
|
211 |
NamedAreaLevel areaLevel = NamedAreaLevel.NewInstance("Cyprus Division", "Cyprus Division", null);
|
|
212 |
|
|
213 |
TermVocabulary areaVocabulary = TermVocabulary.NewInstance("Cyprus devisions", "Cyprus divisions", null, null);
|
|
214 |
areaVocabulary.setUuid(uuidCyprusDivisionsVocabulary);
|
|
215 |
|
|
216 |
for(int i = 1; i <= 8; i++){
|
|
217 |
UUID divisionUuid = getNamedAreaUuid(String.valueOf(i));
|
|
218 |
NamedArea division = this.getNamedArea(divisionUuid, "Division " + i, "Cyprus: Division " + i, String.valueOf(i), areaType, areaLevel, areaVocabulary);
|
|
219 |
divisions.put(String.valueOf(i), division);
|
|
220 |
}
|
223 |
221 |
|
224 |
222 |
// indigenousStatus = (PresenceTerm)getTermService().find(CyprusTransformer.indigenousUuid);
|
225 |
223 |
// casualStatus = (PresenceTerm)getTermService().find(CyprusTransformer.casualUuid);
|
... | ... | |
227 |
225 |
// invasiveStatus = (PresenceTerm)getTermService().find(CyprusTransformer.invasiveUuid);
|
228 |
226 |
// questionableStatus = (PresenceTerm)getTermService().find(CyprusTransformer.questionableUuid);
|
229 |
227 |
|
230 |
|
return true;
|
231 |
|
|
232 |
|
|
233 |
|
}
|
234 |
|
|
235 |
|
public static final UUID uuidDivision1 = UUID.fromString("ab17eee9-1abb-4ce9-a9a2-563f840cdbfc");
|
236 |
|
public static final UUID uuidDivision2 = UUID.fromString("c3606165-efb7-4224-a168-63e009eb4aa5");
|
237 |
|
public static final UUID uuidDivision3 = UUID.fromString("750d4e07-e34b-491f-a7b7-09723afdc960");
|
238 |
|
public static final UUID uuidDivision4 = UUID.fromString("8a858922-e8e5-4791-ad53-906e50633ec7");
|
239 |
|
public static final UUID uuidDivision5 = UUID.fromString("16057133-d541-4ebd-81d4-cb92265ec54c");
|
240 |
|
public static final UUID uuidDivision6 = UUID.fromString("fbf21230-4a42-4f4c-9af8-5da52123c264");
|
241 |
|
public static final UUID uuidDivision7 = UUID.fromString("d31dd96a-36ea-4428-871c-d8552a9565ca");
|
242 |
|
public static final UUID uuidDivision8 = UUID.fromString("236ea447-c3ab-486d-9e06-cc5907861acc");
|
243 |
|
|
244 |
|
|
245 |
|
public UUID getNamedAreaUuid(String key) {
|
246 |
|
if (CdmUtils.isEmpty(key)){return null;
|
247 |
|
}else if (key.equalsIgnoreCase("1")){return uuidDivision1;
|
248 |
|
}else if (key.equalsIgnoreCase("2")){return uuidDivision2;
|
249 |
|
}else if (key.equalsIgnoreCase("3")){return uuidDivision3;
|
250 |
|
}else if (key.equalsIgnoreCase("4")){return uuidDivision4;
|
251 |
|
}else if (key.equalsIgnoreCase("5")){return uuidDivision5;
|
252 |
|
}else if (key.equalsIgnoreCase("6")){return uuidDivision6;
|
253 |
|
}else if (key.equalsIgnoreCase("7")){return uuidDivision7;
|
254 |
|
}else if (key.equalsIgnoreCase("8")){return uuidDivision8;
|
255 |
|
}else{
|
256 |
|
return null;
|
257 |
|
}
|
258 |
|
}
|
259 |
|
|
260 |
|
protected NamedArea getNamedArea(UUID uuid, String label, String text, String labelAbbrev, NamedAreaType areaType, NamedAreaLevel level, TermVocabulary voc){
|
261 |
|
NamedArea namedArea = NamedArea.NewInstance(text, label, labelAbbrev);
|
262 |
|
voc.addTerm(namedArea);
|
263 |
|
namedArea.setType(areaType);
|
264 |
|
namedArea.setLevel(level);
|
265 |
|
namedArea.setUuid(uuid);
|
266 |
|
return namedArea;
|
267 |
|
}
|
268 |
|
|
269 |
|
@Test
|
270 |
|
public void testGetWebServiceUrlBangka() throws ClientProtocolException, IOException, URISyntaxException {
|
271 |
|
NamedArea areaBangka = NamedArea.NewInstance("Bangka", "Bangka", null);
|
272 |
|
TermVocabulary<NamedArea> voc = TermVocabulary.NewInstance("test Voc", "test voc", null, null);
|
273 |
|
voc.addTerm(areaBangka);
|
274 |
|
|
275 |
|
GeoServiceArea geoServiceArea = new GeoServiceArea();
|
276 |
|
String geoServiceLayer="vmap0_as_bnd_political_boundary_a";
|
277 |
|
String layerFieldName ="nam";
|
278 |
|
String areaValue = "PULAU BANGKA#SUMATERA SELATAN";
|
279 |
|
geoServiceArea.add(geoServiceLayer, layerFieldName, areaValue);
|
280 |
|
geoServiceArea.add(geoServiceLayer, layerFieldName, "BALI");
|
281 |
|
|
282 |
|
mapping.set(areaBangka, geoServiceArea);
|
283 |
|
Set<Distribution> distributions = new HashSet<Distribution>();
|
284 |
|
distributions.add(Distribution.NewInstance(areaBangka, PresenceTerm.PRESENT()));
|
285 |
|
|
286 |
|
Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
|
287 |
|
presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
|
288 |
|
|
289 |
|
String backLayer ="";
|
290 |
|
presenceAbsenceColorMap = null;
|
291 |
|
String bbox="90,-8,130,8";
|
292 |
|
List<Language> languages = new ArrayList<Language>();
|
293 |
|
|
294 |
|
String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );
|
295 |
|
//TODO Set semantics is not determined
|
296 |
|
//String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
|
297 |
|
|
298 |
|
System.out.println(result);
|
299 |
|
|
300 |
|
assertTrue(result.matches(".*l=earth.*"));
|
301 |
|
assertTrue(result.matches(".*ms=600,300.*"));
|
302 |
|
assertTrue(result.matches(".*ad=vmap0_as_bnd_political_boundary_a%3Anam:.*"));
|
303 |
|
assertTrue(result.matches(".*(PULAU\\+BANGKA%23SUMATERA\\+SELATAN).*") );
|
304 |
|
assertTrue(result.matches(".*(BALI).*") );
|
305 |
|
|
306 |
|
// request map image from webservice
|
307 |
|
subTestWithEditMapService(result);
|
308 |
|
}
|
|
228 |
return true;
|
|
229 |
|
|
230 |
|
|
231 |
}
|
|
232 |
|
|
233 |
public static final UUID uuidDivision1 = UUID.fromString("ab17eee9-1abb-4ce9-a9a2-563f840cdbfc");
|
|
234 |
public static final UUID uuidDivision2 = UUID.fromString("c3606165-efb7-4224-a168-63e009eb4aa5");
|
|
235 |
public static final UUID uuidDivision3 = UUID.fromString("750d4e07-e34b-491f-a7b7-09723afdc960");
|
|
236 |
public static final UUID uuidDivision4 = UUID.fromString("8a858922-e8e5-4791-ad53-906e50633ec7");
|
|
237 |
public static final UUID uuidDivision5 = UUID.fromString("16057133-d541-4ebd-81d4-cb92265ec54c");
|
|
238 |
public static final UUID uuidDivision6 = UUID.fromString("fbf21230-4a42-4f4c-9af8-5da52123c264");
|
|
239 |
public static final UUID uuidDivision7 = UUID.fromString("d31dd96a-36ea-4428-871c-d8552a9565ca");
|
|
240 |
public static final UUID uuidDivision8 = UUID.fromString("236ea447-c3ab-486d-9e06-cc5907861acc");
|
|
241 |
|
|
242 |
|
|
243 |
public UUID getNamedAreaUuid(String key) {
|
|
244 |
if (CdmUtils.isEmpty(key)){return null;
|
|
245 |
}else if (key.equalsIgnoreCase("1")){return uuidDivision1;
|
|
246 |
}else if (key.equalsIgnoreCase("2")){return uuidDivision2;
|
|
247 |
}else if (key.equalsIgnoreCase("3")){return uuidDivision3;
|
|
248 |
}else if (key.equalsIgnoreCase("4")){return uuidDivision4;
|
|
249 |
}else if (key.equalsIgnoreCase("5")){return uuidDivision5;
|
|
250 |
}else if (key.equalsIgnoreCase("6")){return uuidDivision6;
|
|
251 |
}else if (key.equalsIgnoreCase("7")){return uuidDivision7;
|
|
252 |
}else if (key.equalsIgnoreCase("8")){return uuidDivision8;
|
|
253 |
}else{
|
|
254 |
return null;
|
|
255 |
}
|
|
256 |
}
|
|
257 |
|
|
258 |
protected NamedArea getNamedArea(UUID uuid, String label, String text, String labelAbbrev, NamedAreaType areaType, NamedAreaLevel level, TermVocabulary voc){
|
|
259 |
NamedArea namedArea = NamedArea.NewInstance(text, label, labelAbbrev);
|
|
260 |
voc.addTerm(namedArea);
|
|
261 |
namedArea.setType(areaType);
|
|
262 |
namedArea.setLevel(level);
|
|
263 |
namedArea.setUuid(uuid);
|
|
264 |
return namedArea;
|
|
265 |
}
|
|
266 |
|
|
267 |
@Test
|
|
268 |
public void testGetWebServiceUrlBangka() throws ClientProtocolException, IOException, URISyntaxException {
|
|
269 |
NamedArea areaBangka = NamedArea.NewInstance("Bangka", "Bangka", null);
|
|
270 |
TermVocabulary<NamedArea> voc = TermVocabulary.NewInstance("test Voc", "test voc", null, null);
|
|
271 |
voc.addTerm(areaBangka);
|
|
272 |
|
|
273 |
GeoServiceArea geoServiceArea = new GeoServiceArea();
|
|
274 |
String geoServiceLayer="vmap0_as_bnd_political_boundary_a";
|
|
275 |
String layerFieldName ="nam";
|
|
276 |
String areaValue = "PULAU BANGKA#SUMATERA SELATAN";
|
|
277 |
geoServiceArea.add(geoServiceLayer, layerFieldName, areaValue);
|
|
278 |
geoServiceArea.add(geoServiceLayer, layerFieldName, "BALI");
|
|
279 |
|
|
280 |
mapping.set(areaBangka, geoServiceArea);
|
|
281 |
Set<Distribution> distributions = new HashSet<Distribution>();
|
|
282 |
distributions.add(Distribution.NewInstance(areaBangka, PresenceTerm.PRESENT()));
|
|
283 |
|
|
284 |
Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
|
|
285 |
presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
|
|
286 |
|
|
287 |
String backLayer ="";
|
|
288 |
presenceAbsenceColorMap = null;
|
|
289 |
String bbox="90,-8,130,8";
|
|
290 |
List<Language> languages = new ArrayList<Language>();
|
|
291 |
|
|
292 |
String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );
|
|
293 |
//TODO Set semantics is not determined
|
|
294 |
//String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
|
|
295 |
|
|
296 |
System.out.println(result);
|
|
297 |
|
|
298 |
assertTrue(result.matches(".*l=earth.*"));
|
|
299 |
assertTrue(result.matches(".*ms=600,300.*"));
|
|
300 |
assertTrue(result.matches(".*ad=vmap0_as_bnd_political_boundary_a%3Anam:.*"));
|
|
301 |
assertTrue(result.matches(".*(PULAU\\+BANGKA%23SUMATERA\\+SELATAN).*") );
|
|
302 |
assertTrue(result.matches(".*(BALI).*") );
|
|
303 |
|
|
304 |
// request map image from webservice
|
|
305 |
subTestWithEditMapService(result);
|
|
306 |
}
|
309 |
307 |
|
310 |
308 |
|
311 |
309 |
}
|