use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-features10 by opengeospatial.
the class FeaturesTime method timeParameterDefinition.
/**
* <pre>
* Abstract Test 18: /ats/core/fc-time-definition
* Test Purpose: Validate that the dateTime query parameters are constructed correctly.
* Requirement: /req/core/fc-time-definition
*
* Test Method: Verify that the datetime query parameter complies with the following definition (using an OpenAPI Specification 3.0 fragment):
*
* name: datetime
* in: query
* required: false
* schema:
* type: string
* style: form
* explode: false
* </pre>
*
* @param testPoint
* the testPoint under test, never <code>null</code>
*/
@Test(description = "A.2.7. Features {root}/collections/{collectionId}/items - Datetime, Abstract Test 18: (Requirement /req/core/fc-time-definition)", dataProvider = "collectionPaths", dependsOnGroups = "featuresBase", alwaysRun = true)
public void timeParameterDefinition(TestPoint testPoint) {
Parameter time = retrieveParameterByName(testPoint.getPath(), getApiModel(), "datetime");
assertNotNull(time, "Required datetime parameter for collections with path '" + testPoint.getPath() + "' in OpenAPI document is missing");
String msg = "Expected property '%s' with value '%s' but was '%s'";
assertEquals(time.getName(), "datetime", String.format(msg, "name", "datetime", time.getName()));
assertEquals(time.getIn(), "query", String.format(msg, "in", "query", time.getIn()));
assertFalse(isRequired(time), String.format(msg, "required", "false", time.getRequired()));
assertEquals(time.getStyle(), "form", String.format(msg, "style", "form", time.getStyle()));
assertFalse(isExplode(time), String.format(msg, "explode", "false", time.getExplode()));
Schema schema = time.getSchema();
assertEquals(schema.getType(), "string", String.format(msg, "schema -> type", "string", schema.getType()));
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-features10 by opengeospatial.
the class OpenApiUtils method identifyTestPoints.
private static List<Path> identifyTestPoints(OpenApi3 apiModel, String path, PathMatcherFunction<Boolean, String, String> pathMatch) {
List<Path> pathItems = new ArrayList<>();
Map<String, Path> pathItemObjects = apiModel.getPaths();
for (Path pathItemObject : pathItemObjects.values()) {
String pathString = pathItemObject.getPathString();
if (pathMatch.apply(pathString, path)) {
pathItems.add(pathItemObject);
}
}
return pathItems;
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-features10 by opengeospatial.
the class OpenApiUtils method findBasePath.
private static String findBasePath(OpenApi3 apiModel, URI iut) {
String basePath = "/";
List<Server> serverUrls = apiModel.getServers();
for (Server serverUrl : serverUrls) {
Matcher matcher = Pattern.compile(serverUrl.getUrl()).matcher(iut.toString());
if (matcher.find()) {
String path = iut.toString().substring(matcher.end(), iut.toString().length());
if (!path.isEmpty()) {
basePath = path;
}
}
}
return basePath;
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-features10 by opengeospatial.
the class FeaturesBBox method boundingBoxParameterDefinition.
/**
* <pre>
* Abstract Test 14: /ats/core/fc-bbox-definition
* Test Purpose: Validate that the bounding box query parameters are constructed correctly.
* Requirement: /req/core/fc-bbox-definition
*
* Test Method: Verify that the bbox query parameter complies with the following definition (using an OpenAPI Specification 3.0 fragment):
*
* name: bbox
* in: query
* required: false
* schema:
* type: array
* minItems: 4
* maxItems: 6
* items:
* type: number
* style: form
* explode: false
*
* Use a bounding box with four numbers in all requests:
* * Lower left corner, WGS 84 longitude
* * Lower left corner, WGS 84 latitude
* * Upper right corner, WGS 84 longitude
* * Upper right corner, WGS 84 latitude
* </pre>
*
* @param testPoint
* the testPoint under test, never <code>null</code>
*/
@Test(description = "A.2.7. Features {root}/collections/{collectionId}/items - BoundingBox, Abstract Test 14: (Requirement /req/core/fc-bbox-definition)", dataProvider = "collectionPaths", dependsOnGroups = "featuresBase", alwaysRun = true)
public void boundingBoxParameterDefinition(TestPoint testPoint) {
Parameter bbox = retrieveParameterByName(testPoint.getPath(), getApiModel(), "bbox");
assertNotNull(bbox, "Required bbox parameter for collections path '" + testPoint.getPath() + "' in OpenAPI document is missing");
String msg = "Expected property '%s' with value '%s' for collections path '" + testPoint.getPath() + "' but was '%s'.";
assertEquals(bbox.getName(), "bbox", String.format(msg, "name", "bbox", bbox.getName()));
assertEquals(bbox.getIn(), "query", String.format(msg, "in", "query", bbox.getIn()));
assertFalse(isRequired(bbox), String.format(msg, "required", "false", bbox.getRequired()));
assertEquals(bbox.getStyle(), "form", String.format(msg, "style", "form", bbox.getStyle()));
assertFalse(isExplode(bbox), String.format(msg, "explode", "false", bbox.getExplode()));
Schema schema = bbox.getSchema();
assertNotNull(schema, "Expected schema for bbox parameter for collections path '" + testPoint.getPath());
assertEquals(schema.getType(), "array", String.format(msg, "schema -> type", "array", schema.getType()));
assertNotNull(schema.getMinItems(), String.format(msg, "schema -> minItems", "null", schema.getMinItems()));
assertEquals(schema.getMinItems().intValue(), 4, String.format(msg, "schema -> minItems", "4", schema.getMinItems()));
assertNotNull(schema.getMaxItems(), String.format(msg, "schema -> maxItems", "null", schema.getMaxItems()));
assertEquals(schema.getMaxItems().intValue(), 6, String.format(msg, "schema -> maxItems", "6", schema.getMaxItems()));
String itemsType = schema.getItemsSchema().getType();
assertEquals(itemsType, "number", String.format(msg, "schema -> items -> type", "number", itemsType));
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-features10 by opengeospatial.
the class FeaturesLimit method limitParameterDefinition.
/**
* <pre>
* Abstract Test 16: /ats/core/fc-limit-definition
* Test Purpose: Validate that the bounding box query parameters are constructed corrrectly.
* Requirement: /req/core/fc-limit-definition
*
* Test Method: Verify that the limit query parameter complies with the following definition (using an OpenAPI Specification 3.0 fragment):
*
* name: limit
* in: query
* required: false
* schema:
* type: integer
* style: form
* explode: false
*
* Note that the API can define values for "minimum", "maximum" and "default".
* </pre>
*
* @param testPoint
* the testPoint under test, never <code>null</code>
*/
@Test(description = "A.2.7. Features {root}/collections/{collectionId}/items - Limit, Abstract Test 16: (Requirement /req/core/fc-limit-definition)", dataProvider = "collectionPaths", dependsOnGroups = "featuresBase", alwaysRun = true)
public void limitParameterDefinition(TestPoint testPoint) {
Parameter limit = retrieveParameterByName(testPoint.getPath(), getApiModel(), "limit");
assertNotNull(limit, "Required limit parameter for collections path '" + testPoint.getPath() + "' in OpenAPI document is missing");
String msg = "Expected property '%s' with value '%s' but was '%s'";
assertEquals(limit.getName(), "limit", String.format(msg, "name", "limit", limit.getName()));
assertEquals(limit.getIn(), "query", String.format(msg, "in", "query", limit.getIn()));
assertFalse(isRequired(limit), String.format(msg, "required", "false", limit.getRequired()));
assertEquals(limit.getStyle(), "form", String.format(msg, "style", "form", limit.getStyle()));
assertFalse(isExplode(limit), String.format(msg, "explode", "false", limit.getExplode()));
Schema schema = limit.getSchema();
assertEquals(schema.getType(), "integer", String.format(msg, "schema -> type", "integer", schema.getType()));
assertIntegerGreaterZero(schema.getMinimum(), "schema -> minimum");
assertIntegerGreaterZero(schema.getDefault(), "schema -> default");
}
Aggregations