use of com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse in project java-spanner by googleapis.
the class MockDatabaseAdminServiceImplTest method listBackupOperations.
@Test
public void listBackupOperations() {
createTestDb();
createTestBackup();
ListBackupOperationsPagedResponse response = client.listBackupOperations(TEST_BCK_NAME);
List<Operation> operations = new ArrayList<>();
for (Operation op : response.iterateAll()) {
operations.add(op);
}
assertThat(operations).hasSize(1);
}
use of com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse in project java-spanner by googleapis.
the class DatabaseAdminClientTest method listBackupOperationsTest.
@Test
public void listBackupOperationsTest() throws Exception {
Operation responsesElement = Operation.newBuilder().build();
ListBackupOperationsResponse expectedResponse = ListBackupOperationsResponse.newBuilder().setNextPageToken("").addAllOperations(Arrays.asList(responsesElement)).build();
mockDatabaseAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
ListBackupOperationsPagedResponse pagedListResponse = client.listBackupOperations(parent);
List<Operation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getOperationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBackupOperationsRequest actualRequest = ((ListBackupOperationsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse in project java-spanner by googleapis.
the class DatabaseAdminClientTest method listBackupOperationsTest2.
@Test
public void listBackupOperationsTest2() throws Exception {
Operation responsesElement = Operation.newBuilder().build();
ListBackupOperationsResponse expectedResponse = ListBackupOperationsResponse.newBuilder().setNextPageToken("").addAllOperations(Arrays.asList(responsesElement)).build();
mockDatabaseAdmin.addResponse(expectedResponse);
String parent = "parent-995424086";
ListBackupOperationsPagedResponse pagedListResponse = client.listBackupOperations(parent);
List<Operation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getOperationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBackupOperationsRequest actualRequest = ((ListBackupOperationsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations