Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #139 #145

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package org.opengis.cite.ogcapiedr10.queries;

import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.opengis.cite.ogcapiedr10.util.JsonUtils;

import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import org.opengis.cite.ogcapiedr10.util.JsonUtils;

import java.net.URLEncoder;
import java.util.*;

public class PositionQueryProcessor extends AbstractProcessor{

public String validatePositionQueryUsingParameters(Set<String> collectionIds, String rootUri, int noOfCollections, RequestSpecification ini){
StringBuffer sb = new StringBuffer();
ArrayList<String> collectionsList = new ArrayList<String>();
collectionsList.addAll(collectionIds);

int numberOfCollectionsWithPositionSupport = 0;

//fix setting of maximum, see https://github.com/opengeospatial/ets-ogcapi-edr10/issues/133
int maximum = getMaximum(noOfCollections, collectionsList.size());

for (int c = 0; c < maximum; c++) {

String collectionId = collectionsList.get(c);
Expand All @@ -27,7 +34,7 @@ public String validatePositionQueryUsingParameters(Set<String> collectionIds, St
String url = JsonUtils.getCollectionURL(rootUri, collectionId);

Response response = JsonUtils.getCollectionResponse(rootUri, collectionId, ini);
JsonPath jsonResponse = response.jsonPath();
JsonPath jsonResponse = JsonPath.from(new java.io.File("D:\\52n\\Projekte\\CITE Consulting\\edr-issue-133-collection-response.json"));

HashMap<?,?> dataQueries = jsonResponse.getJsonObject("data_queries");

Expand All @@ -38,14 +45,16 @@ public String validatePositionQueryUsingParameters(Set<String> collectionIds, St
supportsPositionQuery = dataQueries != null && dataQueries.containsKey("position");

if(supportsPositionQuery==false) { //Avoids Nullpointer Exception
sb.append(" The position element is missing from the data_queries element of the collection "+collectionId+" .");
continue;
}


if (supportsPositionQuery) {

numberOfCollectionsWithPositionSupport++;

if(jsonResponse.getJsonObject("parameter_names")==null) { //Avoids Nullpointer Exception
sb.append(" The parameter_names element is missing from the collection "+collectionId+" .");
continue;
}

HashMap parameterNames = jsonResponse.getJsonObject("parameter_names");
Expand Down Expand Up @@ -230,13 +239,12 @@ else if(intervalEnv.get(0).getClass().toString().contains("java.util.ArrayList")
+ " was null. \n");
}




}

}


if(numberOfCollectionsWithPositionSupport==0) {
sb.append(queryTypeNotSupported+"\n");
}

return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ public void validatePositionQueryUsingParameters(Object collectionIdentifiers) {
PositionQueryProcessor processor = new PositionQueryProcessor();

String resultMessage = processor.validatePositionQueryUsingParameters(collectionIds,rootUri.toString(),this.noOfCollections,init());
if(resultMessage.contains(processor.queryTypeNotSupported)) {
throw new SkipException(processor.queryTypeNotSupported);
}
assertTrue(resultMessage.length()==0,
"Fails Abstract Test 37. Therefore could not verify the implementation passes Abstract Tests 39, 41, 43, 45, 47, and 49. Expected information that matches the selection criteria is returned for Position query. "
+ resultMessage);
Expand Down