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()));
}
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()));
}
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());
}
Aggregations