use of com.google.spanner.admin.database.v1.DatabaseName in project java-firestore by googleapis.
the class FirestoreAdminClientTest method importDocumentsTest.
@Test
public void importDocumentsTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
Operation resultOperation = Operation.newBuilder().setName("importDocumentsTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockFirestoreAdmin.addResponse(resultOperation);
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
client.importDocumentsAsync(name).get();
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ImportDocumentsRequest actualRequest = ((ImportDocumentsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.admin.database.v1.DatabaseName in project cloud-spanner-r2dbc by GoogleCloudPlatform.
the class SessionCleanupUtils method getSessionNames.
private static List<String> getSessionNames() throws Exception {
String databaseName = DatabaseName.format(ServiceOptions.getDefaultProjectId(), DatabaseProperties.INSTANCE, DatabaseProperties.DATABASE);
String nextPageToken = null;
List<String> sessionNames = new ArrayList<>();
do {
ListSessionsRequest.Builder requestBuilder = ListSessionsRequest.newBuilder().setDatabase(databaseName);
if (nextPageToken != null) {
requestBuilder.setPageToken(nextPageToken);
}
ListSessionsResponse listSessionsResponse = ObservableReactiveUtil.<ListSessionsResponse>unaryCall(obs -> spannerStub.listSessions(requestBuilder.build(), obs)).block();
nextPageToken = listSessionsResponse.getNextPageToken();
sessionNames.addAll(listSessionsResponse.getSessionsList().stream().map(Session::getName).collect(Collectors.toList()));
} while (nextPageToken != null && !"".equals(nextPageToken));
return sessionNames;
}
Aggregations