Search in sources :

Example 1 with GetSchemaRequest

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

the class SchemaServiceClientTest method getSchemaTest2.

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

Example 2 with GetSchemaRequest

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

the class SchemaServiceClientTest method getSchemaTest.

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

Example 3 with GetSchemaRequest

use of com.google.pubsub.v1.GetSchemaRequest in project java-pubsub by googleapis.

the class SchemaServiceClientTest method getSchemaTest.

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

Example 4 with GetSchemaRequest

use of com.google.pubsub.v1.GetSchemaRequest in project java-pubsub by googleapis.

the class SchemaServiceClientTest method getSchemaTest2.

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

Example 5 with GetSchemaRequest

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

the class AsyncGetSchema method asyncGetSchema.

public static void asyncGetSchema() throws Exception {
    // It may require modifications to work in your environment.
    try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
        GetSchemaRequest request = GetSchemaRequest.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setView(SchemaView.forNumber(0)).build();
        ApiFuture<Schema> future = schemaServiceClient.getSchemaCallable().futureCall(request);
        // Do something.
        Schema response = future.get();
    }
}
Also used : Schema(com.google.pubsub.v1.Schema) GetSchemaRequest(com.google.pubsub.v1.GetSchemaRequest) SchemaServiceClient(com.google.cloud.pubsub.v1.SchemaServiceClient)

Aggregations

GetSchemaRequest (com.google.pubsub.v1.GetSchemaRequest)6 Schema (com.google.pubsub.v1.Schema)6 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)2 ByteString (com.google.protobuf.ByteString)2 SchemaName (com.google.pubsub.v1.SchemaName)2