Search in sources :

Example 6 with Path

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()));
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Test(org.testng.annotations.Test)

Example 7 with Path

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;
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) ArrayList(java.util.ArrayList)

Example 8 with Path

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;
}
Also used : Server(com.reprezen.kaizen.oasparser.model3.Server) Matcher(java.util.regex.Matcher)

Example 9 with Path

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));
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Test(org.testng.annotations.Test)

Example 10 with Path

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");
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Test(org.testng.annotations.Test)

Aggregations

Path (com.reprezen.kaizen.oasparser.model3.Path)24 Parameter (com.reprezen.kaizen.oasparser.model3.Parameter)21 Operation (com.reprezen.kaizen.oasparser.model3.Operation)16 ArrayList (java.util.ArrayList)8 Path (org.dishevelled.bio.assembly.gfa1.Path)7 Schema (com.reprezen.kaizen.oasparser.model3.Schema)6 BufferedReader (java.io.BufferedReader)5 OpenApi3 (com.reprezen.kaizen.oasparser.model3.OpenApi3)4 PrintWriter (java.io.PrintWriter)4 HashMap (java.util.HashMap)4 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)4 OpenApi3Parser (com.reprezen.kaizen.oasparser.OpenApi3Parser)3 LinkedList (java.util.LinkedList)3 Traversal (org.dishevelled.bio.assembly.gfa1.Traversal)3 Test (org.testng.annotations.Test)3 HashBasedTable (com.google.common.collect.HashBasedTable)2 Table (com.google.common.collect.Table)2 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)2 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)2 TlvException (es.gob.jmulticard.asn1.TlvException)2