Search in sources :

Example 11 with Schema

use of com.google.pubsub.v1.Schema in project gapic-generator-java by googleapis.

the class SchemaServiceClientTest method createSchemaTest.

@Test
public void createSchemaTest() throws Exception {
    Schema expectedResponse = Schema.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setDefinition("definition-1014418093").build();
    mockSchemaService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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.toString(), 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) ProjectName(com.google.pubsub.v1.ProjectName) Schema(com.google.pubsub.v1.Schema) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 12 with Schema

use of com.google.pubsub.v1.Schema in project gapic-generator-java by googleapis.

the class SchemaServiceClientTest method validateSchemaTest.

@Test
public void validateSchemaTest() throws Exception {
    ValidateSchemaResponse expectedResponse = ValidateSchemaResponse.newBuilder().build();
    mockSchemaService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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.toString(), 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) ProjectName(com.google.pubsub.v1.ProjectName) Schema(com.google.pubsub.v1.Schema) ValidateSchemaRequest(com.google.pubsub.v1.ValidateSchemaRequest) Test(org.junit.Test)

Example 13 with Schema

use of com.google.pubsub.v1.Schema in project gapic-generator-java by googleapis.

the class SchemaServiceClientTest method createSchemaExceptionTest2.

@Test
public void createSchemaExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSchemaService.addException(exception);
    try {
        String parent = "parent-995424086";
        Schema schema = Schema.newBuilder().build();
        String schemaId = "schemaId-697673060";
        client.createSchema(parent, schema, schemaId);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) Schema(com.google.pubsub.v1.Schema) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 14 with Schema

use of com.google.pubsub.v1.Schema in project gapic-generator-java 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 15 with Schema

use of com.google.pubsub.v1.Schema in project gapic-generator-java by googleapis.

the class SchemaServiceClient method deleteSchema.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a schema.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * // This snippet has been automatically generated for illustrative purposes only.
 * // It may require modifications to work in your environment.
 * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
 *   String name = SchemaName.of("[PROJECT]", "[SCHEMA]").toString();
 *   schemaServiceClient.deleteSchema(name);
 * }
 * }</pre>
 *
 * @param name Required. Name of the schema to delete. Format is
 *     `projects/{project}/schemas/{schema}`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteSchema(String name) {
    DeleteSchemaRequest request = DeleteSchemaRequest.newBuilder().setName(name).build();
    deleteSchema(request);
}
Also used : DeleteSchemaRequest(com.google.pubsub.v1.DeleteSchemaRequest)

Aggregations

Test (org.junit.Test)65 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 ByteString (com.google.protobuf.ByteString)19 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)18 AbstractMessage (com.google.protobuf.AbstractMessage)18 QName (javax.xml.namespace.QName)16 SchemaName (com.google.pubsub.v1.SchemaName)15 File (java.io.File)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 ProjectName (com.google.pubsub.v1.ProjectName)14 IOException (java.io.IOException)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 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)12 StatusRuntimeException (io.grpc.StatusRuntimeException)12 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10