Search in sources :

Example 6 with DeleteIndexRequest

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());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) DeleteIndexRequest(com.google.datastore.admin.v1.DeleteIndexRequest) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 7 with DeleteIndexRequest

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) DeleteIndexRequest(com.google.datastore.admin.v1.DeleteIndexRequest) Index(com.google.datastore.admin.v1.Index) Operation(com.google.longrunning.Operation) Test(org.junit.Test)

Aggregations

DeleteIndexRequest (com.google.firestore.admin.v1.DeleteIndexRequest)4 Test (org.junit.Test)4 AbstractMessage (com.google.protobuf.AbstractMessage)3 DeleteIndexRequest (com.google.datastore.admin.v1.DeleteIndexRequest)2 Empty (com.google.protobuf.Empty)2 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)1 Index (com.google.datastore.admin.v1.Index)1 IndexName (com.google.firestore.admin.v1.IndexName)1 DeleteIndexRequest (com.google.firestore.admin.v1beta1.DeleteIndexRequest)1 FirestoreAdminBlockingStub (com.google.firestore.admin.v1beta1.FirestoreAdminGrpc.FirestoreAdminBlockingStub)1 Operation (com.google.longrunning.Operation)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ArrayList (java.util.ArrayList)1 Scanner (java.util.Scanner)1 ExecutionException (java.util.concurrent.ExecutionException)1 GRPCFirebaseAdminClientFactory (org.roguewave.grpc.util.GRPCFirebaseAdminClientFactory)1 Menu (org.roguewave.grpc.util.gfx.Menu)1