Commit 99642cfe08fb13b9e72099dd65c01103e7ee71b1
1 parent
35daa117
Exists in
master
Improve unit test for ADQL queries.
Showing
2 changed files
with
38 additions
and
20 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java
... | ... | @@ -31,6 +31,7 @@ import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException; |
31 | 31 | import eu.omp.irap.vespa.epntapclient.voresource.model.Resource; |
32 | 32 | import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; |
33 | 33 | import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; |
34 | +import eu.omp.irap.vespa.votable.controller.VOTableController; | |
34 | 35 | import eu.omp.irap.vespa.votable.utils.StringJoiner; |
35 | 36 | import eu.omp.irap.vespa.votable.votabledata.VOTableData; |
36 | 37 | |
... | ... | @@ -129,9 +130,10 @@ public class EpnTapConnection implements EpnTapInterface { |
129 | 130 | @Override |
130 | 131 | public List<Granule> sendADQLQuery(String tapURL, String adqlQuery) |
131 | 132 | throws CantGetVOTableException { |
132 | - EpnTapController epnTapCtrl = new EpnTapController(); | |
133 | - epnTapCtrl.sendQuery(adqlQuery, tapURL); | |
134 | - VOTableData data = epnTapCtrl.getResultsController().getVOTableData(); | |
133 | + VOTableController voTableCtrl = new VOTableController(tapURL, adqlQuery); | |
134 | + voTableCtrl.readTable(); | |
135 | + VOTableData data = voTableCtrl.getVOTableData(); | |
136 | + | |
135 | 137 | List<Granule> granules; |
136 | 138 | try { |
137 | 139 | GranuleCtrl gc = new GranuleCtrl(data); | ... | ... |
src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java
... | ... | @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull; |
21 | 21 | import static org.junit.Assert.assertTrue; |
22 | 22 | |
23 | 23 | import java.util.ArrayList; |
24 | +import java.util.Date; | |
24 | 25 | import java.util.List; |
25 | 26 | import java.util.Map; |
26 | 27 | import java.util.logging.Logger; |
... | ... | @@ -56,6 +57,11 @@ public class EpnTapConnectionTest { |
56 | 57 | |
57 | 58 | private static final String APIS_SHORT_NAME = "APIS"; |
58 | 59 | |
60 | + private static final String SERVICE_EPNCOREV2_ACCESS_URL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; | |
61 | + | |
62 | + private static final String SERVICE_EPNCOREV2_QUERY = "SELECT * FROM planets.epn_core"; | |
63 | + | |
64 | + private static final String SERVICE_EPNCOREV2_TABLE_NAME = "planets.epn_core"; | |
59 | 65 | // *** VOResources *** |
60 | 66 | |
61 | 67 | |
... | ... | @@ -251,32 +257,42 @@ public class EpnTapConnectionTest { |
251 | 257 | System.out.println("sendADQLQueryTest"); |
252 | 258 | EpnTapConnection facade = new EpnTapConnection(); |
253 | 259 | |
254 | - String tapURL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; | |
255 | - String query = "SELECT TOP 1 * FROM planets.epn_core"; | |
256 | - List<Granule> granules = facade.sendADQLQuery(tapURL, query); | |
260 | + List<Granule> granules = facade.sendADQLQuery(SERVICE_EPNCOREV2_ACCESS_URL, | |
261 | + SERVICE_EPNCOREV2_QUERY); | |
257 | 262 | |
258 | 263 | assertNotNull("Granules list not returned.", granules); |
259 | - assertTrue("No granules returned.", granules.size() > 0); | |
260 | - assertEquals("?", granules.get(0).granuleUid); | |
261 | - assertEquals("?", granules.get(0).timeMin); | |
262 | - assertEquals("?", granules.get(0).processingLevel); | |
263 | - assertEquals("?", granules.get(0).creationDate); | |
264 | + assertEquals(8, granules.size()); | |
265 | + Granule mars = null; | |
266 | + for (Granule granule : granules) { | |
267 | + if ("Mars".equals(granule.granuleUid)) { | |
268 | + mars = granule; | |
269 | + } | |
270 | + } | |
271 | + assertNotNull("granule 'Mars' is not found.", mars); | |
272 | + assertEquals("4", mars.obsId); | |
273 | + assertEquals(new Integer(5), mars.processingLevel); | |
274 | + assertEquals(mars.creationDate, new Date(2015, 8, 20)); | |
264 | 275 | } |
265 | 276 | |
266 | 277 | @Test |
267 | 278 | public void sendADQLQueryWithSchemaNameTest() throws CantGetVOTableException { |
268 | 279 | System.out.println("sendADQLQueryWithSchemaNameTest"); |
269 | 280 | EpnTapConnection facade = new EpnTapConnection(); |
270 | - String tapURL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; | |
271 | - String schemaName = "amdadb.epn_core"; | |
272 | - String query = "SELECT TOP 1 * FROM planets.epn_core"; | |
273 | - List<Granule> granules = facade.sendQuery(tapURL, schemaName, query); | |
281 | + List<Granule> granules = facade.sendQuery(SERVICE_EPNCOREV2_ACCESS_URL, | |
282 | + SERVICE_EPNCOREV2_TABLE_NAME, SERVICE_EPNCOREV2_QUERY); | |
274 | 283 | |
275 | 284 | assertNotNull("Granules list not returned.", granules); |
276 | - assertTrue("No granules returned.", granules.size() > 0); | |
277 | - assertEquals("?", granules.get(0).granuleUid); | |
278 | - assertEquals("?", granules.get(0).timeMin); | |
279 | - assertEquals("?", granules.get(0).processingLevel); | |
280 | - assertEquals("?", granules.get(0).creationDate); | |
285 | + assertEquals(8, granules.size()); | |
286 | + Granule mars = null; | |
287 | + for (Granule granule : granules) { | |
288 | + if ("Mars".equals(granule.granuleUid)) { | |
289 | + mars = granule; | |
290 | + } | |
291 | + } | |
292 | + assertNotNull("granule 'Mars' is not found.", mars); | |
293 | + assertEquals(mars.obsId, 4); | |
294 | + assertEquals((int) mars.processingLevel, 5); | |
295 | + assertEquals(mars.creationDate, "2015-08-20"); | |
296 | + | |
281 | 297 | } |
282 | 298 | } | ... | ... |