use of com.reprezen.kaizen.oasparser.model3.Schema 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.Schema in project ets-ogcapi-features10 by opengeospatial.
the class OpenApiUtils method collectTemplateReplacements.
private static List<Map<String, String>> collectTemplateReplacements(PathItemAndServer pathItemAndServer, UriTemplate uriTemplate) {
List<Map<String, String>> templateReplacements = new ArrayList<>();
Collection<Parameter> parameters = pathItemAndServer.operationObject.getParameters();
for (String templateVariable : uriTemplate.getTemplateVariables()) {
for (Parameter parameter : parameters) {
if (templateVariable.equals(parameter.getName())) {
Schema schema = parameter.getSchema();
if (schema.hasEnums()) {
addEnumTemplateValues(templateReplacements, templateVariable, schema);
} else if (schema.getDefault() != null) {
addDefaultTemplateValue(templateReplacements, templateVariable, schema);
} else {
// TODO: What should be done if the parameter does not have a default value and no
// enumerated set of valid values?
}
}
}
}
return templateReplacements;
}
use of com.reprezen.kaizen.oasparser.model3.Schema 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.Schema 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");
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestCohortCatalogue method importStagingSchemas.
@Test
public void importStagingSchemas() {
// import cdm that uses schemaRef to ontologies
Schema cdmSchema = database.dropCreateSchema("Catalogue_cdm");
MolgenisIO.fromDirectory(new File("../../data/datacatalogue/Catalogue_cdm").toPath(), cdmSchema, true);
// export cdm and then import again, to validate it works
List<Row> metadata = Emx2.toRowList(cdmSchema.getMetadata());
Schema cdmSchema2 = database.dropCreateSchema("Catalogue_cdm2");
cdmSchema2.migrate(Emx2.fromRowList(metadata));
}
Aggregations