use of com.google.spanner.admin.database.v1.GetDatabaseDdlResponse in project java-spanner by googleapis.
the class MockDatabaseAdminServiceImplTest method updateDatabaseDdl.
@Test
public void updateDatabaseDdl() throws InterruptedException, ExecutionException {
createTestDb();
UpdateDatabaseDdlRequest request = UpdateDatabaseDdlRequest.newBuilder().setDatabase(TEST_DB_NAME).addAllStatements(Arrays.asList("CREATE TABLE BAZ", "DROP TABLE FOO")).build();
OperationFuture<Empty, UpdateDatabaseDdlMetadata> op = client.updateDatabaseDdlOperationCallable().futureCall(request);
op.get();
GetDatabaseDdlResponse response = client.getDatabaseDdl(TEST_DB_NAME);
assertThat(response.getStatementsList()).containsExactly("CREATE TABLE FOO", "CREATE TABLE BAR", "CREATE TABLE BAZ", "DROP TABLE FOO");
}
use of com.google.spanner.admin.database.v1.GetDatabaseDdlResponse in project java-spanner by googleapis.
the class MockDatabaseAdminServiceImplTest method getDatabaseDdl.
@Test
public void getDatabaseDdl() {
createTestDb();
GetDatabaseDdlResponse ddl = client.getDatabaseDdl(TEST_DB_NAME);
assertThat(ddl.getStatementsList()).containsExactly("CREATE TABLE FOO", "CREATE TABLE BAR");
}
use of com.google.spanner.admin.database.v1.GetDatabaseDdlResponse 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.GetDatabaseDdlResponse 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()));
}
Aggregations