Search in sources :

Example 1 with GetDatabaseDdlRequest

use of com.google.spanner.admin.database.v1.GetDatabaseDdlRequest in project java-spanner by googleapis.

the class DatabaseAdminClientTest method getDatabaseDdlTest.

@Test
public void getDatabaseDdlTest() throws Exception {
    GetDatabaseDdlResponse expectedResponse = GetDatabaseDdlResponse.newBuilder().addAllStatements(new ArrayList<String>()).build();
    mockDatabaseAdmin.addResponse(expectedResponse);
    DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
    GetDatabaseDdlResponse actualResponse = client.getDatabaseDdl(database);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetDatabaseDdlRequest actualRequest = ((GetDatabaseDdlRequest) actualRequests.get(0));
    Assert.assertEquals(database.toString(), actualRequest.getDatabase());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) DatabaseName(com.google.spanner.admin.database.v1.DatabaseName) GetDatabaseDdlResponse(com.google.spanner.admin.database.v1.GetDatabaseDdlResponse) GetDatabaseDdlRequest(com.google.spanner.admin.database.v1.GetDatabaseDdlRequest) Test(org.junit.Test)

Example 2 with GetDatabaseDdlRequest

use of com.google.spanner.admin.database.v1.GetDatabaseDdlRequest in project java-spanner by googleapis.

the class DatabaseAdminClientTest method getDatabaseDdlTest2.

@Test
public void getDatabaseDdlTest2() throws Exception {
    GetDatabaseDdlResponse expectedResponse = GetDatabaseDdlResponse.newBuilder().addAllStatements(new ArrayList<String>()).build();
    mockDatabaseAdmin.addResponse(expectedResponse);
    String database = "database1789464955";
    GetDatabaseDdlResponse actualResponse = client.getDatabaseDdl(database);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetDatabaseDdlRequest actualRequest = ((GetDatabaseDdlRequest) actualRequests.get(0));
    Assert.assertEquals(database, actualRequest.getDatabase());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) GetDatabaseDdlResponse(com.google.spanner.admin.database.v1.GetDatabaseDdlResponse) ByteString(com.google.protobuf.ByteString) GetDatabaseDdlRequest(com.google.spanner.admin.database.v1.GetDatabaseDdlRequest) Test(org.junit.Test)

Example 3 with GetDatabaseDdlRequest

use of com.google.spanner.admin.database.v1.GetDatabaseDdlRequest in project java-spanner by googleapis.

the class GapicSpannerRpc method getDatabaseDdl.

@Override
public List<String> getDatabaseDdl(String databaseName) throws SpannerException {
    acquireAdministrativeRequestsRateLimiter();
    final GetDatabaseDdlRequest request = GetDatabaseDdlRequest.newBuilder().setDatabase(databaseName).build();
    final GrpcCallContext context = newCallContext(null, databaseName, request, DatabaseAdminGrpc.getGetDatabaseDdlMethod());
    return runWithRetryOnAdministrativeRequestsExceeded(() -> get(databaseAdminStub.getDatabaseDdlCallable().futureCall(request, context)).getStatementsList());
}
Also used : GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) GetDatabaseDdlRequest(com.google.spanner.admin.database.v1.GetDatabaseDdlRequest)

Aggregations

GetDatabaseDdlRequest (com.google.spanner.admin.database.v1.GetDatabaseDdlRequest)3 AbstractMessage (com.google.protobuf.AbstractMessage)2 GetDatabaseDdlResponse (com.google.spanner.admin.database.v1.GetDatabaseDdlResponse)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ByteString (com.google.protobuf.ByteString)1 DatabaseName (com.google.spanner.admin.database.v1.DatabaseName)1