Search in sources :

Example 1 with CreateSchemaRequest

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

the class AsyncCreateSchema method asyncCreateSchema.

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

Example 2 with CreateSchemaRequest

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

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

use of com.google.pubsub.v1.CreateSchemaRequest in project java-pubsub 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 5 with CreateSchemaRequest

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

Aggregations

CreateSchemaRequest (com.google.pubsub.v1.CreateSchemaRequest)5 Schema (com.google.pubsub.v1.Schema)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 Test (org.junit.Test)4 ProjectName (com.google.pubsub.v1.ProjectName)2 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)1