Search in sources :

Example 1 with GetDatabaseDdlResponse

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");
}
Also used : Empty(com.google.protobuf.Empty) UpdateDatabaseDdlMetadata(com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata) GetDatabaseDdlResponse(com.google.spanner.admin.database.v1.GetDatabaseDdlResponse) UpdateDatabaseDdlRequest(com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest) Test(org.junit.Test)

Example 2 with GetDatabaseDdlResponse

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");
}
Also used : GetDatabaseDdlResponse(com.google.spanner.admin.database.v1.GetDatabaseDdlResponse) Test(org.junit.Test)

Example 3 with GetDatabaseDdlResponse

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()));
}
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 4 with GetDatabaseDdlResponse

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

Aggregations

GetDatabaseDdlResponse (com.google.spanner.admin.database.v1.GetDatabaseDdlResponse)4 Test (org.junit.Test)4 AbstractMessage (com.google.protobuf.AbstractMessage)2 GetDatabaseDdlRequest (com.google.spanner.admin.database.v1.GetDatabaseDdlRequest)2 ArrayList (java.util.ArrayList)2 ByteString (com.google.protobuf.ByteString)1 Empty (com.google.protobuf.Empty)1 DatabaseName (com.google.spanner.admin.database.v1.DatabaseName)1 UpdateDatabaseDdlMetadata (com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata)1 UpdateDatabaseDdlRequest (com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest)1