Skip to content

Commit

Permalink
Handling on NullPointer exception resulting from crs element
Browse files Browse the repository at this point in the history
  • Loading branch information
ghobona committed Nov 1, 2022
1 parent bbb43cb commit 89b1a15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
16 changes: 5 additions & 11 deletions notes.txt
@@ -1,13 +1,7 @@
position,34,49
area,50,64
cube,66,81
trajectory,82,99
corridor,100,131
instances,132,135
locations,136,146
==================
curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/opengeospatial/ets-ogcapi-edr10/commits?until=2021-11-29T23:59:59Z" > commits_r1.json
_ttps://demo.pygeoapi.io/master

curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/opengeospatial/ets-ogcapi-edr10/commits?since=2021-11-29T23:59:59Z&until=2022-03-01T23:59:59Z" > commits_r2.json
_ttps://demo.pygeoapi.io/master/openapi

curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/opengeospatial/ets-ogcapi-edr10/commits?since=2022-03-01T23:59:59Z" > commits_r3.json
_ttp://labs.metoffice.gov.uk/edr

_ttp://labs.metoffice.gov.uk/edr/api
Expand Up @@ -165,7 +165,7 @@ public void validateRetrievalOfEnvironmentalDataCollections(Object collectionIde

@Test(description = "Implements Abstract Test 8 (/conf/core/crs84)")
public void collectionsCRS84() {

boolean compliesWithCRS84Requirement = true;
StringBuffer resultMessage = new StringBuffer();

Expand All @@ -175,21 +175,33 @@ public void collectionsCRS84() {
JsonPath jsonPath = response.jsonPath();

List<Object> collectionsList = jsonPath.getList("collections");





for (int t = 0; t < collectionsList.size(); t++) {
boolean supportsCRS84 = false;



HashMap collectionMap = (HashMap) collectionsList.get(t);

String crsText = collectionMap.get("crs").toString();
String crsText = null;

if(collectionMap.containsKey("crs")) {
crsText = collectionMap.get("crs").toString();
}
else {

if(collectionMap.containsKey("extent")) {

HashMap extentMap = (HashMap) collectionMap.get("extent");

HashMap spatialMap = (HashMap) extentMap.get("spatial");

crsText = spatialMap.get("crs").toString();


}

}


if (crsText.contains("CRS:84") || crsText.contains("CRS84") || crsText.contains("EPSG:4326") || crsText.contains("WGS84") || crsText.contains("www.opengis.net/def/crs/OGC/1.3/CRS84")){
compliesWithCRS84Requirement = true;
Expand All @@ -200,8 +212,7 @@ public void collectionsCRS84() {
}

}





org.testng.Assert.assertTrue(compliesWithCRS84Requirement,
Expand Down Expand Up @@ -369,16 +380,16 @@ public void verifyCollectionsMetadata() {


//Abstract Test 15
ArrayList linksList1 = (ArrayList) collectionMap.get("links");
List<Object> linksList1 = jsonPathCol.getList("links");
linksList1.addAll((ArrayList) collectionMap.get("links")); //in some cases, the links shown for the collection at /collections are a subset of those shown in /collections/collectionid

collectionHasDataOrCollectionLinks = checkDataOrCollectionLinksArePresentInCollectionMetadata(linksList1);




//Abstract Test 16
List<Object> linksList = jsonPathCol.getList("links");
collectionHasSelfAndAlternateLinks = checkSelfAndAlternateLinksArePresentInCollectionMetadata(linksList);
//Abstract Test 16
collectionHasSelfAndAlternateLinks = checkSelfAndAlternateLinksArePresentInCollectionMetadata(linksList1);


if(collectionHasSelfAndAlternateLinks==false) resultMessageForSelfAndAlternateLinks.append(collectionMap.get("id").toString()+" , ");
Expand Down

0 comments on commit 89b1a15

Please sign in to comment.