From 9d6bc8cb20c06494be49b30a50f291c4eeb7377f Mon Sep 17 00:00:00 2001 From: Lyn Elisa Goltz Date: Thu, 28 Jun 2018 16:38:33 +0200 Subject: [PATCH] #8 - implemented A.4.4.11. Limit Parameter, test method 1 --- .../collections/GetFeaturesOperation.java | 81 +++++++++++++++++-- .../collections/GetFeaturesOperationIT.java | 1 + 2 files changed, 76 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 b4c72d95..da96bd31 100644 --- a/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java +++ b/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java @@ -11,6 +11,7 @@ import static org.opengis.cite.wfs30.util.JsonUtils.findUnsupportedTypes; import static org.opengis.cite.wfs30.util.JsonUtils.hasProperty; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -35,6 +36,8 @@ import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.reprezen.kaizen.oasparser.model3.MediaType; import com.reprezen.kaizen.oasparser.model3.OpenApi3; +import com.reprezen.kaizen.oasparser.model3.Parameter; +import com.reprezen.kaizen.oasparser.model3.Schema; import io.restassured.path.json.JsonPath; import io.restassured.response.Response; @@ -91,7 +94,7 @@ public void retrieveRequiredInformationFromTestContext( ITestContext testContext * @param collection * the collection under test, never null */ - @Test(description = "Implements A.4.4.9. Validate the Get Features Operation (Requirement 17, 24)", dataProvider = "collectionItemUris", dependsOnGroups = "collections") + @Test(description = "Implements A.4.4.9. Validate the Get Features Operation (Requirement 17, 24)", groups = "getFeaturesBase", dataProvider = "collectionItemUris", dependsOnGroups = "collections") public void validateGetFeaturesOperation( Map collection ) { String collectionName = (String) collection.get( "name" ); @@ -127,7 +130,7 @@ public void validateGetFeaturesOperation( Map collection ) { * @param collection * the collection under test, never null */ - @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 25, 26)", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") + @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 25, 26)", groups = "getFeaturesBase", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") public void validateGetFeaturesOperationResponse_Links( Map collection ) { String collectionName = (String) collection.get( "name" ); ResponseData response = collectionNameAndResponse.get( collectionName ); @@ -181,7 +184,7 @@ public void validateGetFeaturesOperationResponse_Links( Map coll * @param collection * the collection under test, never null */ - @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 27)", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") + @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 27)", groups = "getFeaturesBase", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") public void validateGetFeaturesOperationResponse_property_timeStamp( Map collection ) { String collectionName = (String) collection.get( "name" ); ResponseData response = collectionNameAndResponse.get( collectionName ); @@ -222,7 +225,7 @@ public void validateGetFeaturesOperationResponse_property_timeStamp( Mapnull */ - @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 29)", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") + @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 29)", groups = "getFeaturesBase", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") public void validateGetFeaturesOperationResponse_property_numberReturned( Map collection ) { String collectionName = (String) collection.get( "name" ); ResponseData response = collectionNameAndResponse.get( collectionName ); @@ -259,10 +262,11 @@ public void validateGetFeaturesOperationResponse_property_numberReturned( Mapnull + * * @throws URISyntaxException * if the creation of a uri fails */ - @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 28)", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") + @Test(description = "Implements A.4.4.10. Validate the Get Features Operation Response (Requirement 28)", groups = "getFeaturesBase", dataProvider = "collectionItemUris", dependsOnMethods = "validateGetFeaturesOperation") public void validateGetFeaturesOperationResponse_property_numberMatched( Map collection ) throws URISyntaxException { String collectionName = (String) collection.get( "name" ); @@ -283,6 +287,54 @@ public void validateGetFeaturesOperationResponse_property_numberMatched( Map + * name: limit + * in: query + * required: false + * schema: + * type: integer + * minimum: 1 + * maximum: 10000 + * default: 10 + * style: form + * explode: false + * + */ + @Test(description = "Implements A.4.4.11. Limit Parameter (Requirement 18, 19)", dependsOnMethods = "validateGetFeaturesOperation") + public void validateLimitParameter() { + Parameter limit = apiModel.getParameter( "limit" ); + assertNotNull( limit, "Required limit parameter in OpenAPI document is missing" ); + + String msg = "Expected property '%s' with value '%s' but was '%s'"; + + assertEquals( limit.getName(), "limit", String.format( msg, "name", "limit", limit.getName() ) ); + assertEquals( limit.getIn(), "query", String.format( msg, "in", "query", limit.getIn() ) ); + assertFalse( limit.getRequired(), String.format( msg, "required", "false", limit.getRequired() ) ); + assertEquals( limit.getStyle(), "form", String.format( msg, "style", "form", limit.getStyle() ) ); + assertFalse( limit.getExplode(), String.format( msg, "explode", "false", limit.getExplode() ) ); + + Schema schema = limit.getSchema(); + assertEquals( schema.getType(), "integer", String.format( msg, "schema -> type", "integer", schema.getType() ) ); + assertEquals( schema.getMinimum(), 1, String.format( msg, "schema -> minimum", "1", schema.getMinimum() ) ); + assertIntegerGreaterZero( schema.getMinimum(), "schema -> minimum" ); + assertIntegerGreaterZero( schema.getDefault(), "schema -> default" ); + } + private String findGetFeatureUrlForGeoJson( Map collection ) { List links = (List) collection.get( "links" ); for ( Object linkObject : links ) { @@ -305,7 +357,6 @@ private List createListOfMediaTypesToSupport( TestPoint testPoint, Map 0, String.format( msg, propertyName, value ) ); + } + private class ResponseData { private final Response response; diff --git a/src/test/java/org/opengis/cite/wfs30/collections/GetFeaturesOperationIT.java b/src/test/java/org/opengis/cite/wfs30/collections/GetFeaturesOperationIT.java index 10d5875a..436d82af 100644 --- a/src/test/java/org/opengis/cite/wfs30/collections/GetFeaturesOperationIT.java +++ b/src/test/java/org/opengis/cite/wfs30/collections/GetFeaturesOperationIT.java @@ -67,6 +67,7 @@ public void testGetFeatureOperations() //getFeaturesOperation.validateGetFeaturesOperationResponse_property_numberReturned( parameter ); //getFeaturesOperation.validateGetFeaturesOperationResponse_property_numberMatched( parameter ); } + getFeaturesOperation.validateLimitParameter(); } }