use of com.google.firestore.admin.v1.DatabaseName in project java-spanner by googleapis.
the class SpannerClientTest method batchCreateSessionsTest.
@Test
public void batchCreateSessionsTest() throws Exception {
BatchCreateSessionsResponse expectedResponse = BatchCreateSessionsResponse.newBuilder().addAllSession(new ArrayList<Session>()).build();
mockSpanner.addResponse(expectedResponse);
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 185691686;
BatchCreateSessionsResponse actualResponse = client.batchCreateSessions(database, sessionCount);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSpanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
BatchCreateSessionsRequest actualRequest = ((BatchCreateSessionsRequest) actualRequests.get(0));
Assert.assertEquals(database.toString(), actualRequest.getDatabase());
Assert.assertEquals(sessionCount, actualRequest.getSessionCount());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.DatabaseName in project java-spanner by googleapis.
the class SpannerClientTest method createSessionExceptionTest.
@Test
public void createSessionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSpanner.addException(exception);
try {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
client.createSession(database);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.firestore.admin.v1.DatabaseName in project java-firestore by googleapis.
the class FirestoreAdminClientTest method importDocumentsExceptionTest.
@Test
public void importDocumentsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockFirestoreAdmin.addException(exception);
try {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
client.importDocumentsAsync(name).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.firestore.admin.v1.DatabaseName in project java-firestore by googleapis.
the class FirestoreAdminClientTest method exportDocumentsExceptionTest.
@Test
public void exportDocumentsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockFirestoreAdmin.addException(exception);
try {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
client.exportDocumentsAsync(name).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.firestore.admin.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()));
}
Aggregations