Search in sources :

Example 1 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project policies-ui-backend by RedHatInsights.

the class OapiTest method validateOpenApi.

@Test
void validateOpenApi() throws Exception {
    OpenApi3 model = new OpenApi3Parser().parse(url, true);
    System.out.printf("OpenAPI Model at %s\n", url);
    if (!model.isValid()) {
        for (ValidationResults.ValidationItem item : model.getValidationItems()) {
            System.err.println(item);
        }
        fail("OpenAPI spec is not valid");
    }
    // 
    // Now that basic validation is done, we can add some of our own
    // 
    Map<String, Path> paths = model.getPaths();
    Map<String, Schema> schemas = model.getSchemas();
    // The base path filler. See also OASModifier.mangleName
    assertTrue(paths.containsKey("/"));
    // User config is private, so don't show it
    assertFalse(paths.containsKey("/user-config"));
    assertFalse(schemas.containsKey("SettingsValues"));
    // Check that openapi does not (again) collapse parameters
    assertEquals(9, paths.get("/policies").getOperation("get").getParameters().size());
    // Check that all properties are present ( https://github.com/smallrye/smallrye-open-api/issues/437 )
    Map<String, Schema> policyProperties = schemas.get("Policy").getProperties();
    assertEquals(9, policyProperties.size());
    assertTrue(policyProperties.containsKey("ctime"));
    assertTrue(policyProperties.containsKey("mtime"));
    // Now that the OpenAPI file has been validated, save a copy to the filesystem
    // This file is going to be uploaded in a regular CI build to know the API state
    // for a given build.
    InputStream in = url.openStream();
    Files.copy(in, Paths.get(TARGET_OPENAPI), StandardCopyOption.REPLACE_EXISTING);
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) ValidationResults(com.reprezen.kaizen.oasparser.val.ValidationResults) InputStream(java.io.InputStream) Schema(com.reprezen.kaizen.oasparser.model3.Schema) OpenApi3Parser(com.reprezen.kaizen.oasparser.OpenApi3Parser) OpenApi3(com.reprezen.kaizen.oasparser.model3.OpenApi3) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.

the class SchemaServiceClientTest method listSchemasTest2.

@Test
public void listSchemasTest2() throws Exception {
    Schema responsesElement = Schema.newBuilder().build();
    ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
    mockSchemaService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
    List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.

the class SchemaServiceClientTest method validateSchemaTest2.

@Test
public void validateSchemaTest2() throws Exception {
    ValidateSchemaResponse expectedResponse = ValidateSchemaResponse.newBuilder().build();
    mockSchemaService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    Schema schema = Schema.newBuilder().build();
    ValidateSchemaResponse actualResponse = client.validateSchema(parent, schema);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ValidateSchemaRequest actualRequest = ((ValidateSchemaRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(schema, actualRequest.getSchema());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ValidateSchemaResponse(com.google.pubsub.v1.ValidateSchemaResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Schema(com.google.pubsub.v1.Schema) ByteString(com.google.protobuf.ByteString) ValidateSchemaRequest(com.google.pubsub.v1.ValidateSchemaRequest) Test(org.junit.Test)

Example 4 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.

the class SchemaServiceClientTest method createSchemaTest2.

@Test
public void createSchemaTest2() throws Exception {
    Schema expectedResponse = Schema.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setDefinition("definition-1014418093").build();
    mockSchemaService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    Schema schema = Schema.newBuilder().build();
    String schemaId = "schemaId-697673060";
    Schema actualResponse = client.createSchema(parent, schema, schemaId);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSchemaRequest actualRequest = ((CreateSchemaRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(schema, actualRequest.getSchema());
    Assert.assertEquals(schemaId, actualRequest.getSchemaId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateSchemaRequest(com.google.pubsub.v1.CreateSchemaRequest) Schema(com.google.pubsub.v1.Schema) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 5 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.

the class SchemaServiceClientTest method listSchemasTest.

@Test
public void listSchemasTest() throws Exception {
    Schema responsesElement = Schema.newBuilder().build();
    ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
    mockSchemaService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
    List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.pubsub.v1.ProjectName) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)44 Schema (org.molgenis.emx2.Schema)34 Schema (com.google.pubsub.v1.Schema)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 File (java.io.File)14 QName (javax.xml.namespace.QName)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 URL (java.net.URL)12 IOException (java.io.IOException)11 GPWFSConnectorStore (org.geosdi.geoplatform.connector.GPWFSConnectorStore)10 WFSGetFeatureRequest (org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest)9 PrintWriter (java.io.PrintWriter)8 JAXBElement (javax.xml.bind.JAXBElement)8 FeatureCollectionDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO)8 WFSGetFeatureStaxReader (org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader)8 TEntityType (org.oasisopen.odata.csdl.v4.TEntityType)8 ProjectName (com.google.pubsub.v1.ProjectName)7 Ignore (org.junit.Ignore)7