Search in sources :

Example 16 with Schema

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

Example 17 with Schema

use of com.google.cloud.datacatalog.v1beta1.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;
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) ArrayList(java.util.ArrayList) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with Schema

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

Example 19 with Schema

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

Example 20 with Schema

use of com.google.cloud.datacatalog.v1beta1.Schema in project beam by apache.

the class DataCatalogTableProvider method setSchemaIfNotPresent.

@Internal
public boolean setSchemaIfNotPresent(String resource, Schema schema) {
    com.google.cloud.datacatalog.v1beta1.Schema dcSchema = SchemaUtils.toDataCatalog(schema);
    Entry entry = dataCatalog.lookupEntry(LookupEntryRequest.newBuilder().setSqlResource(resource).build());
    if (entry.getSchema().getColumnsCount() == 0) {
        dataCatalog.updateEntry(UpdateEntryRequest.newBuilder().setEntry(entry.toBuilder().setSchema(dcSchema).build()).setUpdateMask(FieldMask.newBuilder().addPaths("schema").build()).build());
        return true;
    } else {
        LOG.info(String.format("Not updating schema for '%s' since it already has one.", resource));
        return false;
    }
}
Also used : Entry(com.google.cloud.datacatalog.v1beta1.Entry) Internal(org.apache.beam.sdk.annotations.Internal)

Aggregations

Test (org.junit.Test)57 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 AbstractMessage (com.google.protobuf.AbstractMessage)16 ByteString (com.google.protobuf.ByteString)16 QName (javax.xml.namespace.QName)16 File (java.io.File)15 IOException (java.io.IOException)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)14 ProjectName (com.google.pubsub.v1.ProjectName)14 URL (java.net.URL)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 ArrayList (java.util.ArrayList)10 JAXBElement (javax.xml.bind.JAXBElement)10 HashMap (java.util.HashMap)9 List (java.util.List)9