Skip to content

Commit

Permalink
Merge pull request #211 from opengeospatial/issue#184
Browse files Browse the repository at this point in the history
Closing #184
  • Loading branch information
dstenger authored Jul 21, 2023
2 parents 44af353 + fd02bcb commit da968c7
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ public Iterator<Object[]> collectionIdAndJson( ITestContext testContext ) {
Map<String, JsonPath> collectionsResponses = (Map<String, JsonPath>) testContext.getSuite().getAttribute(
SuiteAttribute.COLLECTION_BY_ID.getName() );
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
collectionsData.add( new Object[] { collection.getKey(), collection.getValue() } );
try {
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
collectionsData.add( new Object[] { collection.getKey(), collection.getValue() } );
}
} catch (Exception e) {
collectionsData.add( new Object[] { null, null } );
}
return collectionsData.iterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,43 @@ public class DiscoveryCollectionCrsUri {

private Map<String, List<CoordinateSystem>> collectionIdAndValidCrs = new HashMap<>();

@DataProvider(name = "collectionIdAndJsonAndCrs")
public Iterator<Object[]> collectionIdAndJsonAndCrs( ITestContext testContext ) {
Map<String, JsonPath> collectionsResponses = (Map<String, JsonPath>) testContext.getSuite().getAttribute( SuiteAttribute.COLLECTION_BY_ID.getName() );
@SuppressWarnings("unchecked")
@DataProvider(
name = "collectionIdAndJsonAndCrs")
public Iterator<Object[]> collectionIdAndJsonAndCrs(ITestContext testContext) throws AssertionError {
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
List<CoordinateSystem> crs = parseCrs( collection.getValue() );
int count = 0;
for ( CoordinateSystem coordinateSystem : crs ) {
if(count >= OgcApiFeatures10.CRS_LIMIT) {
break;
try {
Map<String, JsonPath> collectionsResponses = (Map<String, JsonPath>) testContext.getSuite()
.getAttribute(SuiteAttribute.COLLECTION_BY_ID.getName());
for (Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet()) {
List<CoordinateSystem> crs = parseCrs(collection.getValue());
int count = 0;
for (CoordinateSystem coordinateSystem : crs) {
if (count >= OgcApiFeatures10.CRS_LIMIT) {
break;
}
collectionsData.add(new Object[] { collection.getKey(), coordinateSystem });
count++;
}
collectionsData.add( new Object[] { collection.getKey(), coordinateSystem } );
count++;
}
} catch (Exception e) {
collectionsData.add(new Object[] { null, null });
}
return collectionsData.iterator();
}

@DataProvider(name = "collectionIdAndJsonAndStorageCrs")
public Iterator<Object[]> collectionIdAndJsonAndStorageCrs( ITestContext testContext ) {
Map<String, JsonPath> collectionsResponses = (Map<String, JsonPath>) testContext.getSuite().getAttribute( SuiteAttribute.COLLECTION_BY_ID.getName() );
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
CoordinateSystem storageCrs = parseStorageCrs( collection.getValue() );
if ( storageCrs != null )
collectionsData.add( new Object[] { collection.getKey(), storageCrs } );
try {
Map<String, JsonPath> collectionsResponses = (Map<String, JsonPath>) testContext.getSuite().getAttribute( SuiteAttribute.COLLECTION_BY_ID.getName() );
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
CoordinateSystem storageCrs = parseStorageCrs( collection.getValue() );
if ( storageCrs != null )
collectionsData.add( new Object[] { collection.getKey(), storageCrs } );
}
} catch (Exception e) {
collectionsData.add( new Object[] { null, null } );
}
return collectionsData.iterator();
}
Expand All @@ -88,6 +99,9 @@ public void storeCollectionInTestContext( ITestContext testContext ) {
@Test(description = "Implements A.1 Discovery, Abstract Test 1 (Requirement /req/crs/crs-uri, /req/crs/fc-md-crs-list A, /req/crs/fc-md-storageCrs, /req/crs/fc-md-crs-list-global), "
+ "crs property in the collection object in the path /collection", dataProvider = "collectionIdAndJsonAndCrs", dependsOnGroups = "crs-conformance", groups = "crs-discovery")
public void verifyCollectionCrsIdentifierOfCrsProperty( String collectionId, CoordinateSystem crs ) {
if((collectionId == null) & (crs == null)) {
throw new AssertionError("No crs information for collection available.");
}
addCrs( collectionId, crs );
assertValidCrsIdentifier( crs,
String.format( "Collection with id '%s' contains invalid CRS identifier property 'crs': '%s'",
Expand All @@ -105,6 +119,9 @@ public void verifyCollectionCrsIdentifierOfCrsProperty( String collectionId, Coo
@Test(description = "Implements A.1 Discovery, Abstract Test 1 (Requirement /req/crs/crs-uri, /req/crs/fc-md-crs-list A, /req/crs/fc-md-storageCrs, /req/crs/fc-md-crs-list-global), "
+ "storageCrs property in the collection object in the path /collection", dataProvider = "collectionIdAndJsonAndStorageCrs", dependsOnGroups = "crs-conformance", groups = "crs-discovery")
public void verifyCollectionCrsIdentifierOfStorageCrsProperty( String collectionId, CoordinateSystem storageCrs ) {
if((collectionId == null) & (storageCrs == null)) {
throw new AssertionError("No crs information for collection available.");
}
assertValidCrsIdentifier( storageCrs,
String.format( "Collection with id '%s' contains invalid CRS identifier property 'storageCrs': '%s'",
collectionId, storageCrs ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,37 @@ public class BBoxCrsParameter extends AbstractBBoxCrs {
@DataProvider(name = "collectionDefaultCrs")
public Iterator<Object[]> collectionDefaultCrs( ITestContext testContext ) {
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
JsonPath json = collection.getValue();
CoordinateSystem defaultCrs = collectionIdToDefaultCrs.get( collectionId );
if ( defaultCrs != null ) {
collectionsData.add( new Object[] { collectionId, json, defaultCrs } );
try {
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
JsonPath json = collection.getValue();
CoordinateSystem defaultCrs = collectionIdToDefaultCrs.get( collectionId );
if ( defaultCrs != null ) {
collectionsData.add( new Object[] { collectionId, json, defaultCrs } );
}
}
} catch (Exception e) {
collectionsData.add( new Object[] { null, null, null } );
}
return collectionsData.iterator();
}

@DataProvider(name = "collectionCrsAndDefaultCrs")
public Iterator<Object[]> collectionCrs( ITestContext testContext ) {
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
JsonPath json = collection.getValue();
CoordinateSystem defaultCrs = collectionIdToDefaultCrs.get( collectionId );
if ( defaultCrs != null ) {
for ( CoordinateSystem crs : collectionIdToCrs.get( collectionId ) ) {
collectionsData.add( new Object[] { collectionId, json, crs, defaultCrs } );
try {
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
JsonPath json = collection.getValue();
CoordinateSystem defaultCrs = collectionIdToDefaultCrs.get( collectionId );
if ( defaultCrs != null ) {
for ( CoordinateSystem crs : collectionIdToCrs.get( collectionId ) ) {
collectionsData.add( new Object[] { collectionId, json, crs, defaultCrs } );
}
}
}
} catch (Exception e) {
collectionsData.add( new Object[] { null, null, null, null } );
}
return collectionsData.iterator();
}
Expand All @@ -82,6 +90,9 @@ public Iterator<Object[]> collectionCrs( ITestContext testContext ) {
@Test(description = "Implements A.2.2 Query, Parameter bbox-crs, Abstract Test 8 (Requirement /req/crs/fc-bbox-crs-definition, /req/crs/bbox-crs-action)", dataProvider = "collectionDefaultCrs", dependsOnGroups = "crs-conformance", priority = 1)
public void verifyBboxCrsParameterWithDefaultCrs( String collectionId, JsonPath collection,
CoordinateSystem defaultCrs ) {
if((collectionId == null) & (collection == null) & (defaultCrs == null)) {
throw new AssertionError("No crs information for collection available.");
}
String featuredUrl = JsonUtils.findFeaturesUrlForGeoJson( rootUri, collection );
if ( featuredUrl == null )
throw new SkipException( String.format( "Could not find url for collection with id %s supporting GeoJson (type 5s)",
Expand Down Expand Up @@ -114,6 +125,9 @@ public void verifyBboxCrsParameterWithDefaultCrs( String collectionId, JsonPath
@Test(description = "Implements A.2.2 Query, Parameter bbox-crs, Abstract Test 8 (Requirement /req/crs/fc-bbox-crs-definition, /req/crs/bbox-crs-action)", dataProvider = "collectionCrsAndDefaultCrs", dependsOnGroups = "crs-conformance", dependsOnMethods = "verifyBboxCrsParameterWithDefaultCrs", priority = 1)
public void verifyBboxCrsParameter( String collectionId, JsonPath collection, CoordinateSystem crs,
CoordinateSystem defaultCrs ) {
if((collectionId == null) & (collection == null) & (crs == null) & (defaultCrs == null)) {
throw new AssertionError("No crs information for collection available.");
}
if ( !collectionIdToResponseWithDefaultCRs.containsKey( collectionId ) )
throw new SkipException( String.format( "Collection with id %s could not be requested with bbox in default crs",
collectionId ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ public void retrieveRequiredInformationFromTestContext( ITestContext testContext
@DataProvider(name = "collectionFeatureId")
public Iterator<Object[]> collectionFeatureId( ITestContext testContext ) {
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
if ( collectionIdToFeatureId != null && collectionIdToFeatureId.containsKey( collectionId ) ) {
String featureId = collectionIdToFeatureId.get( collectionId );
JsonPath json = collection.getValue();
collectionsData.add( new Object[] { collectionId, json, featureId } );
try {
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
if ( collectionIdToFeatureId != null && collectionIdToFeatureId.containsKey( collectionId ) ) {
String featureId = collectionIdToFeatureId.get( collectionId );
JsonPath json = collection.getValue();
collectionsData.add( new Object[] { collectionId, json, featureId } );
}
}
} catch (Exception e) {
collectionsData.add( new Object[] { null, null, null } );
}
return collectionsData.iterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ public class FeatureCrsParameter extends AbstractFeatureCrs {
@DataProvider(name = "collectionFeatureIdCrs")
public Iterator<Object[]> collectionFeatureIdCrs( ITestContext testContext ) {
List<Object[]> collectionsData = new ArrayList<>();
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
String featureId = collectionIdToFeatureId.get( collectionId );
JsonPath json = collection.getValue();
for ( CoordinateSystem crs : collectionIdToCrs.get( collectionId ) ) {
collectionsData.add( new Object[] { collectionId, json, featureId, crs } );
try {
for ( Map.Entry<String, JsonPath> collection : collectionsResponses.entrySet() ) {
String collectionId = collection.getKey();
String featureId = collectionIdToFeatureId.get( collectionId );
JsonPath json = collection.getValue();
for ( CoordinateSystem crs : collectionIdToCrs.get( collectionId ) ) {
collectionsData.add( new Object[] { collectionId, json, featureId, crs } );
}
}
} catch (Exception e) {
collectionsData.add( new Object[] { null, null, null, null } );
}
return collectionsData.iterator();
}
Expand All @@ -76,6 +80,9 @@ public Iterator<Object[]> collectionFeatureIdCrs( ITestContext testContext ) {
+ "Content-Crs header in the path /collections/{collectionId}/items/{featureId}", dataProvider = "collectionFeatureIdCrs", dependsOnGroups = "crs-conformance", priority = 1)
public void verifyFeatureCrsParameter( String collectionId, JsonPath collection, String featureId,
CoordinateSystem crs ) {
if((collectionId == null) & (collection == null) & (featureId == null) & (crs == null)) {
throw new AssertionError("No crs information for collection available.");
}
String featureUrl = findFeatureUrlForGeoJson( rootUri, collection, featureId );
if ( featureUrl == null )
throw new SkipException( "Could not find url for collection with id " + collectionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class FeatureCrsParameterDefault extends AbstractFeatureCrs {
@Test(description = "Implements A.2.1 Query, Parameter crs, Abstract Test 6 (Requirement /req/crs/fc-crs-default-value, /req/crs/ogc-crs-header, /req/crs/ogc-crs-header-value), "
+ "Default CRS requesting path /collections/{collectionId}/items/{featureId}", dataProvider = "collectionFeatureId", dependsOnGroups = "crs-conformance", priority = 1)
public void verifyFeatureCrsParameterDefault( String collectionId, JsonPath collection, String featureId ) {
if((collectionId == null) & (collection == null) & (featureId == null)) {
throw new AssertionError("No crs information for collection available.");
}
String featureUrl = findFeatureUrlForGeoJson( rootUri, collection, featureId );
if ( featureUrl == null )
throw new SkipException( "Could not find url for collection with id " + collectionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class FeatureCrsParameterInvalid extends AbstractFeatureCrs {
@Test(description = "Implements A.2.1 Query, Parameter crs, Abstract Test 1 (Requirement /req/crs/fc-crs-valid-value), "
+ "Invalid CRS requesting path /collections/{collectionId}/items/{featureId}", dataProvider = "collectionFeatureId", dependsOnGroups = "crs-conformance", priority = 1)
public void verifyFeatureCrsParameterInvalid( String collectionId, JsonPath collection, String featureId ) {
if((collectionId == null) & (collection == null) & (featureId == null)) {
throw new AssertionError("No crs information for collection available.");
}
String featureUrl = findFeatureUrlForGeoJson( rootUri, collection, featureId );
if ( featureUrl == null )
throw new SkipException( String.format( "Could not find url for collection with id %s supporting GeoJson (type %s)",
Expand Down
Loading

0 comments on commit da968c7

Please sign in to comment.