Search in sources :

Example 1 with ValidateSchemaResponse

use of com.google.pubsub.v1.ValidateSchemaResponse 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 2 with ValidateSchemaResponse

use of com.google.pubsub.v1.ValidateSchemaResponse 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 3 with ValidateSchemaResponse

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

the class AsyncValidateSchema method asyncValidateSchema.

public static void asyncValidateSchema() throws Exception {
    // It may require modifications to work in your environment.
    try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
        ValidateSchemaRequest request = ValidateSchemaRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setSchema(Schema.newBuilder().build()).build();
        ApiFuture<ValidateSchemaResponse> future = schemaServiceClient.validateSchemaCallable().futureCall(request);
        // Do something.
        ValidateSchemaResponse response = future.get();
    }
}
Also used : ValidateSchemaResponse(com.google.pubsub.v1.ValidateSchemaResponse) SchemaServiceClient(com.google.cloud.pubsub.v1.SchemaServiceClient) ValidateSchemaRequest(com.google.pubsub.v1.ValidateSchemaRequest)

Example 4 with ValidateSchemaResponse

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

the class SyncValidateSchema method syncValidateSchema.

public static void syncValidateSchema() throws Exception {
    // It may require modifications to work in your environment.
    try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
        ValidateSchemaRequest request = ValidateSchemaRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setSchema(Schema.newBuilder().build()).build();
        ValidateSchemaResponse response = schemaServiceClient.validateSchema(request);
    }
}
Also used : ValidateSchemaResponse(com.google.pubsub.v1.ValidateSchemaResponse) SchemaServiceClient(com.google.cloud.pubsub.v1.SchemaServiceClient) ValidateSchemaRequest(com.google.pubsub.v1.ValidateSchemaRequest)

Example 5 with ValidateSchemaResponse

use of com.google.pubsub.v1.ValidateSchemaResponse 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)

Aggregations

ValidateSchemaResponse (com.google.pubsub.v1.ValidateSchemaResponse)8 Schema (com.google.pubsub.v1.Schema)6 ValidateSchemaRequest (com.google.pubsub.v1.ValidateSchemaRequest)6 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ProjectName (com.google.pubsub.v1.ProjectName)3 ByteString (com.google.protobuf.ByteString)2