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 #13 and #28 #29

Merged
merged 1 commit into from
Aug 26, 2024
Merged
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
12 changes: 12 additions & 0 deletions src/main/java/org/opengis/cite/ogcapitiles10/CommonFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.PrintStream;
import java.net.URI;

import org.opengis.cite.ogcapitiles10.conformance.RequirementClass;
import org.opengis.cite.ogcapitiles10.util.ClientUtils;
import org.testng.ITestContext;
import org.testng.annotations.BeforeClass;
Expand All @@ -25,6 +26,8 @@ public class CommonFixture {

private ByteArrayOutputStream responseOutputStream = new ByteArrayOutputStream();

private final String conformance_class_not_implemented = "Skipped because Conformance Class %s is not implemented.";

protected RequestLoggingFilter requestLoggingFilter;

protected ResponseLoggingFilter responseLoggingFilter;
Expand All @@ -35,6 +38,15 @@ public class CommonFixture {

protected final String missing_api_definition_error_message = "Skipped because the API definition could not be retrieved";

protected final String dataset_tilesets_conformance_class_not_implemented = String
.format(conformance_class_not_implemented, RequirementClass.DATASET_TILES.getConformanceClass());

protected final String geodata_tilesets_conformance_class_not_implemented = String
.format(conformance_class_not_implemented, RequirementClass.GEODATA_TILESETS.getConformanceClass());

protected final String tilesets_lists_conformance_class_not_implemented = String
.format(conformance_class_not_implemented, RequirementClass.TILESETS_LIST.getConformanceClass());

/**
* Initializes the common test fixture with a client component for interacting with
* HTTP endpoints.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ public Object[][] conformanceUris(ITestContext testContext) {

OpenApi3 apiModel = (OpenApi3) testContext.getSuite().getAttribute(API_MODEL.getName());
URI iut = (URI) testContext.getSuite().getAttribute(IUT.getName());

TestPoint tp = new TestPoint(rootUri.toString(), "/conformance", null);
String rootUriString = rootUri.toString();
rootUriString = rootUriString.endsWith("/") ? rootUriString.substring(0, rootUriString.length() - 1)
: rootUriString;
TestPoint tp = new TestPoint(rootUriString, "/conformance", null);

List<TestPoint> testPoints = new ArrayList<TestPoint>();
testPoints.add(tp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
*/
public enum RequirementClass {

CORE("http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core");
CORE("http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core"), DATASET_TILES(
"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/dataset-tilesets"), GEODATA_TILESETS(
"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/geodata-tilesets"), TILESETS_LIST(
"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tilesets-list");

private final String conformanceClass;

Expand Down Expand Up @@ -70,4 +73,8 @@ public static RequirementClass byConformanceClass(String conformanceClass) {
return null;
}

public String getConformanceClass() {
return this.conformanceClass;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import static io.restassured.http.ContentType.JSON;
import static io.restassured.http.Method.GET;
import static org.opengis.cite.ogcapitiles10.EtsAssert.assertTrue;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.REQUIREMENTCLASSES;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.opengis.cite.ogcapitiles10.CommonFixture;
import org.opengis.cite.ogcapitiles10.conformance.RequirementClass;
import org.testng.ITestContext;
import org.testng.SkipException;
import org.testng.annotations.Test;

Expand All @@ -34,8 +37,15 @@ public class LandingPage extends CommonFixture {
* </pre>
*/
@Test(description = "Implements Abstract test A.10, addresses Requirement 11", groups = "landingpage")
public void landingPageRetrieval() {

public void landingPageRetrieval(ITestContext testContext) {

Object requirementsClassesObject = testContext.getSuite().getAttribute(REQUIREMENTCLASSES.getName());
if (requirementsClassesObject instanceof List<?>) {
List<?> requirementsClassesList = (List<?>) requirementsClassesObject;
if (!requirementsClassesList.contains(RequirementClass.DATASET_TILES)) {
throw new SkipException(dataset_tilesets_conformance_class_not_implemented);
}
}
if (rootUri == null) {
throw new SkipException(missing_landing_page_error_message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static io.restassured.http.ContentType.JSON;
import static io.restassured.http.Method.GET;
import static org.opengis.cite.ogcapitiles10.EtsAssert.assertTrue;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.REQUIREMENTCLASSES;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -12,7 +13,9 @@
import java.util.Set;

import org.opengis.cite.ogcapitiles10.CommonFixture;
import org.opengis.cite.ogcapitiles10.conformance.RequirementClass;
import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.SkipException;
import org.testng.annotations.Test;

Expand All @@ -37,12 +40,20 @@ public class GeospatialDataResource extends CommonFixture {
* </pre>
*/
@Test(description = "Implements Abstract test A.12, addresses Requirement 13", groups = "geodata")
public void geospatialResourceTilesetsLinksCheck() {
public void geospatialResourceTilesetsLinksCheck(ITestContext testContext) {

if (rootUri == null) {
throw new SkipException(missing_landing_page_error_message);
}

Object requirementsClassesObject = testContext.getSuite().getAttribute(REQUIREMENTCLASSES.getName());
if (requirementsClassesObject instanceof List<?>) {
List<?> requirementsClassesList = (List<?>) requirementsClassesObject;
if (!requirementsClassesList.contains(RequirementClass.GEODATA_TILESETS)) {
throw new SkipException(geodata_tilesets_conformance_class_not_implemented);
}
}

Response request = init().baseUri(rootUri.toString()).accept(JSON).when().request(GET, "/collections");
request.then().statusCode(200);
response = request.jsonPath();
Expand All @@ -64,8 +75,15 @@ public void geospatialResourceTilesetsLinksCheck() {
* </pre>
*/
@Test(description = "Implements Abstract test A.13, addresses Requirement 14", groups = "geodata")
public void geospatialResourceTilesetsRetrieval() {
public void geospatialResourceTilesetsRetrieval(ITestContext testContext) {

Object requirementsClassesObject = testContext.getSuite().getAttribute(REQUIREMENTCLASSES.getName());
if (requirementsClassesObject instanceof List<?>) {
List<?> requirementsClassesList = (List<?>) requirementsClassesObject;
if (!requirementsClassesList.contains(RequirementClass.GEODATA_TILESETS)) {
throw new SkipException(geodata_tilesets_conformance_class_not_implemented);
}
}
if (rootUri == null) {
throw new SkipException(missing_landing_page_error_message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static io.restassured.http.Method.GET;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.API_MODEL;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.IUT;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.REQUIREMENTCLASSES;
import static org.testng.Assert.assertTrue;

import java.net.URI;
Expand All @@ -13,6 +14,7 @@
import java.util.Map;

import org.opengis.cite.ogcapitiles10.CommonFixture;
import org.opengis.cite.ogcapitiles10.conformance.RequirementClass;
import org.opengis.cite.ogcapitiles10.openapi3.TestPoint;
import org.testng.ITestContext;
import org.testng.SkipException;
Expand Down Expand Up @@ -51,18 +53,30 @@ public Object[][] tilesetUris(ITestContext testContext) {
*/
@Test(description = "Implements Abstract test A.9, addresses Requirement 10 (/req/tilesets-list/tileset-links)",
groups = "tilesetsLists", dataProvider = "tilesetListsURIs")
public void validateTilesetsListResponse(TestPoint testPoint) {
public void validateTilesetsListResponse(ITestContext testContext, TestPoint testPoint) {

if (rootUri == null) {
throw new SkipException(missing_landing_page_error_message);
}

Object requirementsClassesObject = testContext.getSuite().getAttribute(REQUIREMENTCLASSES.getName());
boolean implementsGeoDataTilesets = false;
if (requirementsClassesObject instanceof List<?>) {
List<?> requirementsClassesList = (List<?>) requirementsClassesObject;
if (!requirementsClassesList.contains(RequirementClass.TILESETS_LIST)) {
throw new SkipException(tilesets_lists_conformance_class_not_implemented);
}
if (requirementsClassesList.contains(RequirementClass.GEODATA_TILESETS)) {
implementsGeoDataTilesets = true;
}
}
StringBuffer errorMessagesRoot = new StringBuffer();
StringBuffer errorMessagesCollection = new StringBuffer();

errorMessagesRoot.append(tilesetsListResponseFromRoot());

errorMessagesCollection.append(tilesetsListResponseFromCollections());
if (implementsGeoDataTilesets) {
errorMessagesCollection.append(tilesetsListResponseFromCollections());
}

assertTrue(errorMessagesRoot.toString().length() == 0 && errorMessagesCollection.toString().length() == 0,
errorMessagesRoot.toString() + " \n" + errorMessagesCollection.toString());
Expand Down