From 124d3ad750151769808ae8d4f47ab128b5b00ae5 Mon Sep 17 00:00:00 2001 From: Lyn Elisa Goltz Date: Wed, 15 Aug 2018 09:18:49 +0200 Subject: [PATCH] #36 - fixed test for links with media types --- .../opengis/cite/wfs30/CommonDataFixture.java | 55 ++++++++++++ .../opengis/cite/wfs30/SuiteAttribute.java | 5 ++ .../FeatureCollectionsMetadataOperation.java | 38 +++----- .../collections/GetFeatureOperation.java | 26 +----- .../collections/GetFeaturesOperation.java | 24 +----- .../conformance/ConformanceOperation.java | 29 +++++-- .../wfs30/conformance/RequirementClass.java | 86 +++++++++++++++++++ .../cite/wfs30/openapi3/TestPoint.java | 24 +----- .../conformance/ConformanceOperationTest.java | 15 ++-- 9 files changed, 193 insertions(+), 109 deletions(-) create mode 100644 src/main/java/org/opengis/cite/wfs30/CommonDataFixture.java create mode 100644 src/main/java/org/opengis/cite/wfs30/conformance/RequirementClass.java diff --git a/src/main/java/org/opengis/cite/wfs30/CommonDataFixture.java b/src/main/java/org/opengis/cite/wfs30/CommonDataFixture.java new file mode 100644 index 00000000..98bdc712 --- /dev/null +++ b/src/main/java/org/opengis/cite/wfs30/CommonDataFixture.java @@ -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 Lyn Goltz + */ +public class CommonDataFixture extends CommonFixture { + + private List requirementClasses; + + @BeforeClass + public void requirementClasses( ITestContext testContext ) { + this.requirementClasses = (List) testContext.getSuite().getAttribute( REQUIREMENTCLASSES.getName() ); + } + + protected List createListOfMediaTypesToSupportForOtherResources( Map linkToSelf ) { + if ( this.requirementClasses == null ) + throw new SkipException( "No requirement classes described in resource /conformance available" ); + List 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 createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures() { + if ( this.requirementClasses == null ) + throw new SkipException( "No requirement classes described in resource /conformance available" ); + List mediaTypesToSupport = new ArrayList<>(); + for ( RequirementClass requirementClass : this.requirementClasses ) + if ( requirementClass.hasMediaTypeForFeaturesAndCollections() ) + mediaTypesToSupport.add( requirementClass.getMediaTypeFeaturesAndCollections() ); + return mediaTypesToSupport; + } + + protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( Map linkToSelf ) { + List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(); + if ( linkToSelf != null ) + mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); + return mediaTypesToSupport; + } + +} diff --git a/src/main/java/org/opengis/cite/wfs30/SuiteAttribute.java b/src/main/java/org/opengis/cite/wfs30/SuiteAttribute.java index 56bcfaa8..86d33120 100644 --- a/src/main/java/org/opengis/cite/wfs30/SuiteAttribute.java +++ b/src/main/java/org/opengis/cite/wfs30/SuiteAttribute.java @@ -34,6 +34,11 @@ public enum SuiteAttribute { */ API_MODEL( "apiModel", OpenApi3.class ), + /** + * Requirement classes parsed from /conformance; Added during execution. + */ + REQUIREMENTCLASSES( "requirementclasses", List.class ), + /** * Parsed collections from resource /collections; Added during execution. */ diff --git a/src/main/java/org/opengis/cite/wfs30/collections/FeatureCollectionsMetadataOperation.java b/src/main/java/org/opengis/cite/wfs30/collections/FeatureCollectionsMetadataOperation.java index c623fc57..dc145544 100644 --- a/src/main/java/org/opengis/cite/wfs30/collections/FeatureCollectionsMetadataOperation.java +++ b/src/main/java/org/opengis/cite/wfs30/collections/FeatureCollectionsMetadataOperation.java @@ -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 Lyn Goltz */ -public class FeatureCollectionsMetadataOperation extends CommonFixture { +public class FeatureCollectionsMetadataOperation extends CommonDataFixture { private final Map 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 mediaTypesToSupport = createListOfMediaTypesToSupport( testPoint, linkToSelf ); + List mediaTypesToSupport = createListOfMediaTypesToSupportForOtherResources( linkToSelf ); List> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, "alternate" ); List 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 collection ) { String collectionName = (String) collection.get( "name" ); - List testPointsForNamedCollection = retrieveTestPointsForCollectionMetadata( apiModel, - collectionName ); - if ( testPointsForNamedCollection.isEmpty() ) - throw new SkipException( "Could not find collection with name " + collectionName - + " in the OpenAPI document" ); - List mediaTypesToSupport = createListOfMediaTypesToSupport( testPointsForNamedCollection.get( 0 ), null ); + List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(); List> links = (List>) collection.get( "links" ); - List> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, - "item" ); - List typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); + List> items = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, "item" ); + List 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 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 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> createCollectionsMap( List collections return collectionsMap; } - private List createListOfMediaTypesToSupport( TestPoint testPoint, Map linkToSelf ) { - Map contentMediaTypes = testPoint.getContentMediaTypes(); - List mediaTypesToSupport = new ArrayList<>(); - mediaTypesToSupport.addAll( contentMediaTypes.keySet() ); - if ( linkToSelf != null ) - mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); - return mediaTypesToSupport; - } - } \ No newline at end of file diff --git a/src/main/java/org/opengis/cite/wfs30/collections/GetFeatureOperation.java b/src/main/java/org/opengis/cite/wfs30/collections/GetFeatureOperation.java index 30488b3c..f8746094 100644 --- a/src/main/java/org/opengis/cite/wfs30/collections/GetFeatureOperation.java +++ b/src/main/java/org/opengis/cite/wfs30/collections/GetFeatureOperation.java @@ -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 Lyn Goltz */ -public class GetFeatureOperation extends CommonFixture { +public class GetFeatureOperation extends CommonDataFixture { private OpenApi3 apiModel; @@ -151,14 +148,6 @@ public void validateTheGetFeatureOperationResponse( Map collecti if ( response == null ) throw new SkipException( "Could not find a response for collection with name " + collectionName ); - List 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> links = jsonPath.getList( "links" ); @@ -179,7 +168,7 @@ public void validateTheGetFeatureOperationResponse( Map 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 mediaTypesToSupport = createListOfMediaTypesToSupport( testPoint, linkToSelf ); + List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( linkToSelf ); List> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, "alternate" ); List typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); @@ -194,15 +183,6 @@ public void validateTheGetFeatureOperationResponse( Map collecti + linksWithoutRelOrType ); } - private List createListOfMediaTypesToSupport( TestPoint testPoint, Map linkToSelf ) { - Map contentMediaTypes = testPoint.getContentMediaTypes(); - List mediaTypesToSupport = new ArrayList<>(); - mediaTypesToSupport.addAll( contentMediaTypes.keySet() ); - if ( linkToSelf != null ) - mediaTypesToSupport.remove( linkToSelf.get( "type" ) ); - return mediaTypesToSupport; - } - private String findGetFeatureUrlForGeoJson( Map collection ) { List links = (List) collection.get( "links" ); for ( Object linkObject : links ) { 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 682477de..2d029b22 100644 --- a/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java +++ b/src/main/java/org/opengis/cite/wfs30/collections/GetFeaturesOperation.java @@ -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 Lyn Goltz */ -public class GetFeaturesOperation extends CommonFixture { +public class GetFeaturesOperation extends CommonDataFixture { private final Map collectionNameAndResponse = new HashMap<>(); @@ -217,12 +214,6 @@ public void validateTheGetFeaturesOperationResponse_Links( Map c if ( response == null ) throw new SkipException( "Could not find a response for collection with name " + collectionName ); - List 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> links = jsonPath.getList( "links" ); @@ -233,7 +224,7 @@ public void validateTheGetFeaturesOperationResponse_Links( Map 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 mediaTypesToSupport = createListOfMediaTypesToSupport( testPoint, linkToSelf ); + List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( linkToSelf ); List> alternateLinks = findLinksWithSupportedMediaTypeByRel( links, mediaTypesToSupport, "alternate" ); List typesWithoutLink = findUnsupportedTypes( alternateLinks, mediaTypesToSupport ); @@ -735,15 +726,6 @@ private String findGetFeaturesUrlForGeoJson( Map collection ) { return null; } - private List createListOfMediaTypesToSupport( TestPoint testPoint, Map linkToSelf ) { - Map contentMediaTypes = testPoint.getContentMediaTypes(); - List 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 ); diff --git a/src/main/java/org/opengis/cite/wfs30/conformance/ConformanceOperation.java b/src/main/java/org/opengis/cite/wfs30/conformance/ConformanceOperation.java index 322d2c1d..925af121 100644 --- a/src/main/java/org/opengis/cite/wfs30/conformance/ConformanceOperation.java +++ b/src/main/java/org/opengis/cite/wfs30/conformance/ConformanceOperation.java @@ -3,6 +3,7 @@ import static io.restassured.http.ContentType.JSON; import static io.restassured.http.Method.GET; import static org.opengis.cite.wfs30.SuiteAttribute.API_MODEL; +import static org.opengis.cite.wfs30.SuiteAttribute.REQUIREMENTCLASSES; import static org.opengis.cite.wfs30.WFS3.PATH.CONFORMANCE; import static org.opengis.cite.wfs30.openapi3.OpenApiUtils.retrieveTestPoints; import static org.testng.Assert.assertNotNull; @@ -14,6 +15,7 @@ import org.opengis.cite.wfs30.openapi3.TestPoint; import org.opengis.cite.wfs30.openapi3.UriBuilder; import org.testng.ITestContext; +import org.testng.annotations.AfterClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -27,6 +29,8 @@ */ public class ConformanceOperation extends CommonFixture { + private List requirementClasses; + @DataProvider(name = "conformanceUris") public Object[][] conformanceUris( ITestContext testContext ) { OpenApi3 apiModel = (OpenApi3) testContext.getSuite().getAttribute( API_MODEL.getName() ); @@ -34,6 +38,11 @@ public Object[][] conformanceUris( ITestContext testContext ) { return new Object[][] { testPoints.toArray() }; } + @AfterClass + public void storeRequirementClassesInTestContext( ITestContext testContext ) { + testContext.getSuite().setAttribute( REQUIREMENTCLASSES.getName(), this.requirementClasses ); + } + /** * Implements A.4.4.2. Validate Conformance Operation and A.4.4.3. Validate Conformance Operation Response. * @@ -43,7 +52,7 @@ public Object[][] conformanceUris( ITestContext testContext ) { @Test(description = "Implements A.4.4.2. Validate Conformance Operation (Requirement 5) and A.4.4.3. Validate Conformance Operation Response (Requirement 6)", dataProvider = "conformanceUris", dependsOnGroups = "apidefinition") public void validateConformanceOperationAndResponse( TestPoint testPoint ) { Response response = validateConformanceOperation( testPoint ); - validateConformanceOperationResponse( testPoint, response ); + validateConformanceOperationResponse( response ); } /** @@ -88,12 +97,11 @@ private Response validateConformanceOperation( TestPoint testPoint ) { * * d) References: Requirement 6 */ - private void validateConformanceOperationResponse( TestPoint testPoint, Response response ) { + private void validateConformanceOperationResponse( Response response ) { response.then().statusCode( 200 ); JsonPath jsonPath = response.jsonPath(); - List requirementClasses = parseAndValidateRequirementClasses( jsonPath ); - testPoint.addRequirementClasses( requirementClasses ); + this.requirementClasses = parseAndValidateRequirementClasses( jsonPath ); } /** @@ -103,15 +111,18 @@ private void validateConformanceOperationResponse( TestPoint testPoint, Response * @throws AssertionError * if the json does not follow the expected structure */ - List parseAndValidateRequirementClasses( JsonPath jsonPath ) { - List requirementClasses = new ArrayList<>(); + List parseAndValidateRequirementClasses( JsonPath jsonPath ) { + List requirementClasses = new ArrayList<>(); List conformsTo = jsonPath.getList( "conformsTo" ); assertNotNull( conformsTo, "Missing member 'conformsTo'." ); for ( Object conformTo : conformsTo ) { - if ( conformTo instanceof String ) - requirementClasses.add( (String) conformTo ); - else + if ( conformTo instanceof String ) { + String conformanceClass = (String) conformTo; + RequirementClass requirementClass = RequirementClass.byConformanceClass( conformanceClass ); + if ( requirementClass != null ) + requirementClasses.add( requirementClass ); + } else throw new AssertionError( "At least one element array 'conformsTo' is not a string value (" + conformTo + ")" ); } diff --git a/src/main/java/org/opengis/cite/wfs30/conformance/RequirementClass.java b/src/main/java/org/opengis/cite/wfs30/conformance/RequirementClass.java new file mode 100644 index 00000000..ab97fca5 --- /dev/null +++ b/src/main/java/org/opengis/cite/wfs30/conformance/RequirementClass.java @@ -0,0 +1,86 @@ +package org.opengis.cite.wfs30.conformance; + +/** + * + * Encapsulates all known requirement classes. + * + * @author Lyn Goltz + */ +public enum RequirementClass { + + CORE( "http://www.opengis.net/spec/wfs-1/3.0/req/core" ), + + HTML( "http://www.opengis.net/spec/wfs-1/3.0/req/html", "text/html", "text/html" ), + + GEOJSON( "http://www.opengis.net/spec/wfs-1/3.0/req/geojson", "application/geo+json", "application/json" ), + + GMLSF0( "http://www.opengis.net/spec/wfs-1/3.0/req/gmlsf0", + "application/gml+xml;version=3.2;profile=http://www.opengis.net/def/profile/ogc/2.0/gml-sf0", + "application/xml" ), + + GMLSF2( "http://www.opengis.net/spec/wfs-1/3.0/req/gmlsf2", + "application/gml+xml;version=3.2;profile=http://www.opengis.net/def/profile/ogc/2.0/gml-sf2", + "application/xml" ), + + OPENAPI30( "http://www.opengis.net/spec/wfs-1/3.0/req/oas30" ); + + private final String conformanceClass; + + private final String mediaTypeFeaturesAndCollections; + + private final String mediaTypeOtherResources; + + RequirementClass( String conformanceClass ) { + this( conformanceClass, null, null ); + } + + RequirementClass( String conformanceClass, String mediaTypeFeaturesAndCollections, String mediaTypeOtherResources ) { + this.conformanceClass = conformanceClass; + this.mediaTypeFeaturesAndCollections = mediaTypeFeaturesAndCollections; + this.mediaTypeOtherResources = mediaTypeOtherResources; + } + + /** + * @return true if the RequirementClass has a media type for features and collections, + * true otherwise + */ + public boolean hasMediaTypeForFeaturesAndCollections() { + return mediaTypeFeaturesAndCollections != null; + } + + /** + * @return media type for features and collections, null if not available + */ + public String getMediaTypeFeaturesAndCollections() { + return mediaTypeFeaturesAndCollections; + } + + /** + * @return true if the RequirementClass has a media type for other resources, + * true otherwise + */ + public boolean hasMediaTypeForOtherResources() { + return mediaTypeOtherResources != null; + } + + /** + * @return media type of other resources, null if not available + */ + public String getMediaTypeOtherResources() { + return mediaTypeOtherResources; + } + + /** + * @param conformanceClass + * the conformance class of the RequirementClass to return. + * @return the RequirementClass with the passed conformance class, null if RequirementClass exists + */ + public static RequirementClass byConformanceClass( String conformanceClass ) { + for ( RequirementClass requirementClass : values() ) { + if ( requirementClass.conformanceClass.equals( conformanceClass ) ) + return requirementClass; + } + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/org/opengis/cite/wfs30/openapi3/TestPoint.java b/src/main/java/org/opengis/cite/wfs30/openapi3/TestPoint.java index 69d34d15..e413e351 100644 --- a/src/main/java/org/opengis/cite/wfs30/openapi3/TestPoint.java +++ b/src/main/java/org/opengis/cite/wfs30/openapi3/TestPoint.java @@ -1,7 +1,6 @@ package org.opengis.cite.wfs30.openapi3; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Objects; @@ -20,8 +19,6 @@ public class TestPoint { private Map predefinedTemplateReplacement; - private List requirementClasses; - private Map contentMediaTypes; /** @@ -80,24 +77,6 @@ public Map getPredefinedTemplateReplacement() { return predefinedTemplateReplacement; } - /** - * @return a list of requirement classes the server conforms to, null if the conformance classes are - * not requested - */ - public List getRequirementClasses() { - return requirementClasses; - } - - /** - * Adds the requirement classes the server conforms to - * - * @param requirementClasses - * never null - */ - public void addRequirementClasses( List requirementClasses ) { - this.requirementClasses = requirementClasses; - } - /** * @return the content media types for the GET operation with response "200", may be null */ @@ -120,13 +99,12 @@ public boolean equals( Object o ) { return Objects.equals( serverUrl, testPoint.serverUrl ) && Objects.equals( path, testPoint.predefinedTemplateReplacement ) && Objects.equals( predefinedTemplateReplacement, testPoint.path ) - && Objects.equals( requirementClasses, testPoint.requirementClasses ) && Objects.equals( contentMediaTypes, testPoint.contentMediaTypes ); } @Override public int hashCode() { - return Objects.hash( serverUrl, path, predefinedTemplateReplacement, requirementClasses, contentMediaTypes ); + return Objects.hash( serverUrl, path, predefinedTemplateReplacement, contentMediaTypes ); } } diff --git a/src/test/java/org/opengis/cite/wfs30/conformance/ConformanceOperationTest.java b/src/test/java/org/opengis/cite/wfs30/conformance/ConformanceOperationTest.java index 3d5f363d..0464e459 100644 --- a/src/test/java/org/opengis/cite/wfs30/conformance/ConformanceOperationTest.java +++ b/src/test/java/org/opengis/cite/wfs30/conformance/ConformanceOperationTest.java @@ -1,8 +1,13 @@ package org.opengis.cite.wfs30.conformance; -import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import static org.opengis.cite.wfs30.conformance.RequirementClass.CORE; +import static org.opengis.cite.wfs30.conformance.RequirementClass.GEOJSON; +import static org.opengis.cite.wfs30.conformance.RequirementClass.GMLSF2; +import static org.opengis.cite.wfs30.conformance.RequirementClass.HTML; +import static org.opengis.cite.wfs30.conformance.RequirementClass.OPENAPI30; import java.io.InputStream; import java.util.List; @@ -21,14 +26,10 @@ public void testParseAndValidateRequirementClasses() { ConformanceOperation conformanceOperationTest = new ConformanceOperation(); InputStream json = ConformanceOperationTest.class.getResourceAsStream( "req-classes.json" ); JsonPath jsonPath = new JsonPath( json ); - List requirementClasses = conformanceOperationTest.parseAndValidateRequirementClasses( jsonPath ); + List requirementClasses = conformanceOperationTest.parseAndValidateRequirementClasses( jsonPath ); assertThat( requirementClasses.size(), is( 5 ) ); - assertThat( requirementClasses, hasItem( "http://www.opengis.net/spec/wfs-1/3.0/req/core" ) ); - assertThat( requirementClasses, hasItem( "http://www.opengis.net/spec/wfs-1/3.0/req/oas30" ) ); - assertThat( requirementClasses, hasItem( "http://www.opengis.net/spec/wfs-1/3.0/req/html" ) ); - assertThat( requirementClasses, hasItem( "http://www.opengis.net/spec/wfs-1/3.0/req/geojson" ) ); - assertThat( requirementClasses, hasItem( "http://www.opengis.net/spec/wfs-1/3.0/req/gmlsf2" ) ); + assertThat( requirementClasses, hasItems( CORE, OPENAPI30, HTML, GEOJSON, GMLSF2 ) ); } @Test(expectedExceptions = AssertionError.class)