use of com.google.firestore.admin.v1.DeleteIndexRequest in project java-datastore by googleapis.
the class DatastoreAdminClientTest method deleteIndexExceptionTest.
@Test
public void deleteIndexExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDatastoreAdmin.addException(exception);
try {
DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setProjectId("projectId-894832108").setIndexId("indexId1943291277").build();
client.deleteIndexAsync(request).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.DeleteIndexRequest in project java-datastore by googleapis.
the class DatastoreAdminClientTest method deleteIndexTest.
@Test
public void deleteIndexTest() throws Exception {
Index expectedResponse = Index.newBuilder().setProjectId("projectId-894832108").setIndexId("indexId1943291277").setKind("kind3292052").addAllProperties(new ArrayList<Index.IndexedProperty>()).build();
Operation resultOperation = Operation.newBuilder().setName("deleteIndexTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockDatastoreAdmin.addResponse(resultOperation);
DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setProjectId("projectId-894832108").setIndexId("indexId1943291277").build();
Index actualResponse = client.deleteIndexAsync(request).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDatastoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0));
Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
Assert.assertEquals(request.getIndexId(), actualRequest.getIndexId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations