-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from opengeospatial/fixValidateCollectionsMeta…
…dataDocument_Links-36 Fixed tests for links with media types of supported conformance classes
- Loading branch information
Showing
9 changed files
with
193 additions
and
109 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/main/java/org/opengis/cite/wfs30/CommonDataFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.opengis.cite.wfs30; | ||
|
||
import static org.opengis.cite.wfs30.SuiteAttribute.REQUIREMENTCLASSES; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.opengis.cite.wfs30.conformance.RequirementClass; | ||
import org.testng.ITestContext; | ||
import org.testng.SkipException; | ||
import org.testng.annotations.BeforeClass; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Lyn Goltz </a> | ||
*/ | ||
public class CommonDataFixture extends CommonFixture { | ||
|
||
private List<RequirementClass> requirementClasses; | ||
|
||
@BeforeClass | ||
public void requirementClasses( ITestContext testContext ) { | ||
this.requirementClasses = (List<RequirementClass>) testContext.getSuite().getAttribute( REQUIREMENTCLASSES.getName() ); | ||
} | ||
|
||
protected List<String> createListOfMediaTypesToSupportForOtherResources( Map<String, Object> linkToSelf ) { | ||
if ( this.requirementClasses == null ) | ||
throw new SkipException( "No requirement classes described in resource /conformance available" ); | ||
List<String> mediaTypesToSupport = new ArrayList<>(); | ||
for ( RequirementClass requirementClass : this.requirementClasses ) | ||
if ( requirementClass.hasMediaTypeForOtherResources() ) | ||
mediaTypesToSupport.add( requirementClass.getMediaTypeOtherResources() ); | ||
if ( linkToSelf != null ) | ||
mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); | ||
return mediaTypesToSupport; | ||
} | ||
|
||
protected List<String> createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures() { | ||
if ( this.requirementClasses == null ) | ||
throw new SkipException( "No requirement classes described in resource /conformance available" ); | ||
List<String> mediaTypesToSupport = new ArrayList<>(); | ||
for ( RequirementClass requirementClass : this.requirementClasses ) | ||
if ( requirementClass.hasMediaTypeForFeaturesAndCollections() ) | ||
mediaTypesToSupport.add( requirementClass.getMediaTypeFeaturesAndCollections() ); | ||
return mediaTypesToSupport; | ||
} | ||
|
||
protected List<String> createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( Map<String, Object> linkToSelf ) { | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(); | ||
if ( linkToSelf != null ) | ||
mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); | ||
return mediaTypesToSupport; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.opengis.cite.wfs30.CommonFixture; | ||
import org.opengis.cite.wfs30.CommonDataFixture; | ||
import org.opengis.cite.wfs30.SuiteAttribute; | ||
import org.opengis.cite.wfs30.openapi3.TestPoint; | ||
import org.opengis.cite.wfs30.openapi3.UriBuilder; | ||
|
@@ -31,7 +31,6 @@ | |
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import com.reprezen.kaizen.oasparser.model3.MediaType; | ||
import com.reprezen.kaizen.oasparser.model3.OpenApi3; | ||
|
||
import io.restassured.path.json.JsonPath; | ||
|
@@ -40,7 +39,7 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Lyn Goltz </a> | ||
*/ | ||
public class FeatureCollectionsMetadataOperation extends CommonFixture { | ||
public class FeatureCollectionsMetadataOperation extends CommonDataFixture { | ||
|
||
private final Map<TestPoint, Response> testPointAndResponses = new HashMap<>(); | ||
|
||
|
@@ -149,7 +148,7 @@ public void validateFeatureCollectionsMetadataOperationResponse_Links( TestPoint | |
|
||
// Validate that the retrieved document includes links for: Itself, Alternate encodings of this document in | ||
// every other media type as identified by the compliance classes for this server. | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupport( testPoint, linkToSelf ); | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupportForOtherResources( linkToSelf ); | ||
List<Map<String, Object>> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, | ||
"alternate" ); | ||
List<String> typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); | ||
|
@@ -218,25 +217,21 @@ public void validateFeatureCollectionsMetadataOperationResponse_Collections( Tes | |
@Test(description = "Implements A.4.4.6. Validate a Collections Metadata document (Requirement 13)", groups = "collections", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections") | ||
public void validateCollectionsMetadataDocument_Links( TestPoint testPoint, Map<String, Object> collection ) { | ||
String collectionName = (String) collection.get( "name" ); | ||
List<TestPoint> testPointsForNamedCollection = retrieveTestPointsForCollectionMetadata( apiModel, | ||
collectionName ); | ||
if ( testPointsForNamedCollection.isEmpty() ) | ||
throw new SkipException( "Could not find collection with name " + collectionName | ||
+ " in the OpenAPI document" ); | ||
|
||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupport( testPointsForNamedCollection.get( 0 ), null ); | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(); | ||
List<Map<String, Object>> links = (List<Map<String, Object>>) collection.get( "links" ); | ||
|
||
List<Map<String, Object>> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, | ||
"item" ); | ||
List<String> typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); | ||
List<Map<String, Object>> items = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, "item" ); | ||
List<String> typesWithoutLink = findUnsupportedTypes( items, mediaTypesToSupport ); | ||
assertTrue( typesWithoutLink.isEmpty(), | ||
"Collections Metadata document must include links with relation 'item' for each supported encodings. Missing links for types " | ||
+ typesWithoutLink ); | ||
List<String> linksWithoutRelOrType = findLinksWithoutRelOrType( alternateLinks ); | ||
"Collections Metadata document for collection with name " | ||
+ collectionName | ||
+ " must include links with relation 'item' for each supported encodings. Missing links for types " | ||
+ String.join( ", ", typesWithoutLink ) ); | ||
List<String> linksWithoutRelOrType = findLinksWithoutRelOrType( items ); | ||
assertTrue( linksWithoutRelOrType.isEmpty(), | ||
"Links with relation 'item' for encodings must include a rel and type parameter. Missing for links " | ||
+ linksWithoutRelOrType ); | ||
+ String.join( ", ", linksWithoutRelOrType ) ); | ||
} | ||
|
||
/** | ||
|
@@ -351,13 +346,4 @@ private List<Map<String, Object>> createCollectionsMap( List<Object> collections | |
return collectionsMap; | ||
} | ||
|
||
private List<String> createListOfMediaTypesToSupport( TestPoint testPoint, Map<String, Object> linkToSelf ) { | ||
Map<String, MediaType> contentMediaTypes = testPoint.getContentMediaTypes(); | ||
List<String> mediaTypesToSupport = new ArrayList<>(); | ||
mediaTypesToSupport.addAll( contentMediaTypes.keySet() ); | ||
if ( linkToSelf != null ) | ||
mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); | ||
return mediaTypesToSupport; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
import static io.restassured.http.Method.GET; | ||
import static org.opengis.cite.wfs30.SuiteAttribute.API_MODEL; | ||
import static org.opengis.cite.wfs30.WFS3.GEOJSON_MIME_TYPE; | ||
import static org.opengis.cite.wfs30.openapi3.OpenApiUtils.retrieveTestPointsForFeature; | ||
import static org.opengis.cite.wfs30.util.JsonUtils.findLinkByRel; | ||
import static org.opengis.cite.wfs30.util.JsonUtils.findLinksWithSupportedMediaTypeByRel; | ||
import static org.opengis.cite.wfs30.util.JsonUtils.findLinksWithoutRelOrType; | ||
|
@@ -18,16 +17,14 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.opengis.cite.wfs30.CommonFixture; | ||
import org.opengis.cite.wfs30.CommonDataFixture; | ||
import org.opengis.cite.wfs30.SuiteAttribute; | ||
import org.opengis.cite.wfs30.openapi3.TestPoint; | ||
import org.testng.ITestContext; | ||
import org.testng.SkipException; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import com.reprezen.kaizen.oasparser.model3.MediaType; | ||
import com.reprezen.kaizen.oasparser.model3.OpenApi3; | ||
|
||
import io.restassured.path.json.JsonPath; | ||
|
@@ -36,7 +33,7 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Lyn Goltz </a> | ||
*/ | ||
public class GetFeatureOperation extends CommonFixture { | ||
public class GetFeatureOperation extends CommonDataFixture { | ||
|
||
private OpenApi3 apiModel; | ||
|
||
|
@@ -151,14 +148,6 @@ public void validateTheGetFeatureOperationResponse( Map<String, Object> collecti | |
if ( response == null ) | ||
throw new SkipException( "Could not find a response for collection with name " + collectionName ); | ||
|
||
List<TestPoint> testPointsForNamedCollection = retrieveTestPointsForFeature( apiModel, collectionName, | ||
featureId ); | ||
|
||
if ( testPointsForNamedCollection.isEmpty() ) | ||
throw new SkipException( "Could not find collection with name " + collectionName | ||
+ " in the OpenAPI document" ); | ||
TestPoint testPoint = testPointsForNamedCollection.get( 0 ); | ||
|
||
JsonPath jsonPath = response.jsonPath(); | ||
|
||
List<Map<String, Object>> links = jsonPath.getList( "links" ); | ||
|
@@ -179,7 +168,7 @@ public void validateTheGetFeatureOperationResponse( Map<String, Object> collecti | |
// Validate that the retrieved document includes links for: | ||
// Alternate encodings of this document in every other media type as identified by the compliance classes for | ||
// this server | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupport( testPoint, linkToSelf ); | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( linkToSelf ); | ||
List<Map<String, Object>> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, | ||
"alternate" ); | ||
List<String> typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); | ||
|
@@ -194,15 +183,6 @@ public void validateTheGetFeatureOperationResponse( Map<String, Object> collecti | |
+ linksWithoutRelOrType ); | ||
} | ||
|
||
private List<String> createListOfMediaTypesToSupport( TestPoint testPoint, Map<String, Object> linkToSelf ) { | ||
Map<String, MediaType> contentMediaTypes = testPoint.getContentMediaTypes(); | ||
List<String> mediaTypesToSupport = new ArrayList<>(); | ||
mediaTypesToSupport.addAll( contentMediaTypes.keySet() ); | ||
if ( linkToSelf != null ) | ||
mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); | ||
return mediaTypesToSupport; | ||
} | ||
|
||
private String findGetFeatureUrlForGeoJson( Map<String, Object> collection ) { | ||
List<Object> links = (List<Object>) collection.get( "links" ); | ||
for ( Object linkObject : links ) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import static org.opengis.cite.wfs30.SuiteAttribute.API_MODEL; | ||
import static org.opengis.cite.wfs30.WFS3.GEOJSON_MIME_TYPE; | ||
import static org.opengis.cite.wfs30.WFS3.PATH.COLLECTIONS; | ||
import static org.opengis.cite.wfs30.openapi3.OpenApiUtils.retrieveTestPointsForCollection; | ||
import static org.opengis.cite.wfs30.util.JsonUtils.collectNumberOfAllReturnedFeatures; | ||
import static org.opengis.cite.wfs30.util.JsonUtils.findLinkByRel; | ||
import static org.opengis.cite.wfs30.util.JsonUtils.findLinksWithSupportedMediaTypeByRel; | ||
|
@@ -34,9 +33,8 @@ | |
import java.util.Map; | ||
import java.util.Random; | ||
|
||
import org.opengis.cite.wfs30.CommonFixture; | ||
import org.opengis.cite.wfs30.CommonDataFixture; | ||
import org.opengis.cite.wfs30.SuiteAttribute; | ||
import org.opengis.cite.wfs30.openapi3.TestPoint; | ||
import org.opengis.cite.wfs30.util.BBox; | ||
import org.opengis.cite.wfs30.util.TemporalExtent; | ||
import org.testng.ITestContext; | ||
|
@@ -45,7 +43,6 @@ | |
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import com.reprezen.kaizen.oasparser.model3.MediaType; | ||
import com.reprezen.kaizen.oasparser.model3.OpenApi3; | ||
import com.reprezen.kaizen.oasparser.model3.Operation; | ||
import com.reprezen.kaizen.oasparser.model3.Parameter; | ||
|
@@ -58,7 +55,7 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Lyn Goltz </a> | ||
*/ | ||
public class GetFeaturesOperation extends CommonFixture { | ||
public class GetFeaturesOperation extends CommonDataFixture { | ||
|
||
private final Map<String, ResponseData> collectionNameAndResponse = new HashMap<>(); | ||
|
||
|
@@ -217,12 +214,6 @@ public void validateTheGetFeaturesOperationResponse_Links( Map<String, Object> c | |
if ( response == null ) | ||
throw new SkipException( "Could not find a response for collection with name " + collectionName ); | ||
|
||
List<TestPoint> testPointsForNamedCollection = retrieveTestPointsForCollection( apiModel, collectionName ); | ||
if ( testPointsForNamedCollection.isEmpty() ) | ||
throw new SkipException( "Could not find collection with name " + collectionName | ||
+ " in the OpenAPI document" ); | ||
TestPoint testPoint = testPointsForNamedCollection.get( 0 ); | ||
|
||
JsonPath jsonPath = response.jsonPath(); | ||
|
||
List<Map<String, Object>> links = jsonPath.getList( "links" ); | ||
|
@@ -233,7 +224,7 @@ public void validateTheGetFeaturesOperationResponse_Links( Map<String, Object> c | |
|
||
// Validate that the retrieved document includes links for: Alternate encodings of this document in | ||
// every other media type as identified by the compliance classes for this server. | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupport( testPoint, linkToSelf ); | ||
List<String> mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( linkToSelf ); | ||
List<Map<String, Object>> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, | ||
"alternate" ); | ||
List<String> typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); | ||
|
@@ -735,15 +726,6 @@ private String findGetFeaturesUrlForGeoJson( Map<String, Object> collection ) { | |
return null; | ||
} | ||
|
||
private List<String> createListOfMediaTypesToSupport( TestPoint testPoint, Map<String, Object> linkToSelf ) { | ||
Map<String, MediaType> contentMediaTypes = testPoint.getContentMediaTypes(); | ||
List<String> mediaTypesToSupport = new ArrayList<>(); | ||
mediaTypesToSupport.addAll( contentMediaTypes.keySet() ); | ||
if ( linkToSelf != null ) | ||
mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); | ||
return mediaTypesToSupport; | ||
} | ||
|
||
private void assertIntegerGreaterZero( Object value, String propertyName ) { | ||
if ( value instanceof Number ) | ||
assertIntegerGreaterZero( ( (Number) value ).intValue(), propertyName ); | ||
|
Oops, something went wrong.