From b90d95e9ed2071ebc7b7aca67cde1fce9be36c09 Mon Sep 17 00:00:00 2001 From: Lyn Elisa Goltz Date: Mon, 2 Jul 2018 09:38:16 +0200 Subject: [PATCH] #8 - set bboxes out of the ats --- .../collections/GetFeaturesOperation.java | 47 ++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java b/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java index 87af11e1..f0fd167a 100644 --- a/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java +++ b/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java @@ -80,12 +80,20 @@ public Object[][] collectionItemUrisWithLimits( ITestContext testContext ) { @DataProvider(name = "collectionItemUrisWithBboxes") public Object[][] collectionItemUrisWithBboxes( ITestContext testContext ) { - // TODO: find values - Object[][] collectionsData = new Object[collections.size()][]; + // TODO: find example with values in extend + Object[][] collectionsData = new Object[collections.size() * 5][]; int i = 0; for ( Map collection : collections ) { - // Example 5. The bounding box of the New Zealand Exclusive Economic Zone - collectionsData[i++] = new Object[] { collection, "160.6,-55.95,-170,-25.89" }; + // These should include test cases which cross the + // meridian, + collectionsData[i++] = new Object[] { collection, new BBox( -1.5, 50.0, 1.5, 53.0 ) }; + // equator, + collectionsData[i++] = new Object[] { collection, new BBox( -80.0, -5.0, -70.0, 5.0 ) }; + // 180 longitude, + collectionsData[i++] = new Object[] { collection, new BBox( 177.0, 65.0, -177.0, 70.0 ) }; + // and polar regions. + collectionsData[i++] = new Object[] { collection, new BBox( -70.0, -20.0, -70.0, 160.0 ) }; + collectionsData[i++] = new Object[] { collection, new BBox( 70.0, -20.0, 70.0, 160.0 ) }; } return collectionsData; } @@ -484,7 +492,7 @@ public void validateBboxParameter( Map collection ) { * if the creation of a uri fails */ @Test(description = "Implements A.4.4.12. Bounding Box Parameter (Requirement 21)", dataProvider = "collectionItemUrisWithBboxes", dependsOnMethods = "validateGetFeaturesOperation") - public void validateBboxParameter_requests( Map collection, String bbox ) + public void validateBboxParameter_requests( Map collection, BBox bbox ) throws URISyntaxException { String collectionName = (String) collection.get( "name" ); @@ -493,7 +501,8 @@ public void validateBboxParameter_requests( Map collection, Stri throw new SkipException( "Could not find url for collection with name " + collectionName + " supporting GeoJson (type " + GEOJSON_MIME_TYPE + ")" ); Date timeStampBeforeResponse = new Date(); - Response response = init().baseUri( getFeaturesUrl ).accept( GEOJSON_MIME_TYPE ).param( "bbox", bbox ).when().request( GET ); + Response response = init().baseUri( getFeaturesUrl ).accept( GEOJSON_MIME_TYPE ).param( "bbox", + bbox.asQueryParameter() ).when().request( GET ); response.then().statusCode( 200 ); Date timeStampAfterResponse = new Date(); @@ -719,4 +728,30 @@ public JsonPath jsonPath() { return response.jsonPath(); } } + + private class BBox { + double minX; + + double minY; + + double maxX; + + double maxY; + + private BBox( double minX, double minY, double maxX, double maxY ) { + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + } + + private String asQueryParameter() { + StringBuilder sb = new StringBuilder(); + sb.append( minX ).append( "," ); + sb.append( minY ).append( "," ); + sb.append( maxX ).append( "," ); + sb.append( maxY ); + return sb.toString(); + } + } }