Search in sources :

Example 1 with ListIndexesResponse

use of com.google.firestore.admin.v1.ListIndexesResponse in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest.

@Test
public void listIndexesTest() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) CollectionGroupName(com.google.firestore.admin.v1.CollectionGroupName) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 2 with ListIndexesResponse

use of com.google.firestore.admin.v1.ListIndexesResponse in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest2.

@Test
public void listIndexesTest2() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 3 with ListIndexesResponse

use of com.google.firestore.admin.v1.ListIndexesResponse in project java-datastore by googleapis.

the class DatastoreAdminClientTest method listIndexesTest.

@Test
public void listIndexesTest() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockDatastoreAdmin.addResponse(expectedResponse);
    ListIndexesRequest request = ListIndexesRequest.newBuilder().setProjectId("projectId-894832108").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(request);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDatastoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
    Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
    Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
    Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.datastore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.datastore.admin.v1.Index) ListIndexesRequest(com.google.datastore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 4 with ListIndexesResponse

use of com.google.firestore.admin.v1.ListIndexesResponse in project grpc-gcp-java by GoogleCloudPlatform.

the class ListIndexes method listIndexesCall.

public void listIndexesCall() {
    System.out.println(":: Listing All Indexes ::");
    FirestoreAdminBlockingStub blockingStub = new GRPCFirebaseAdminClientFactory().createFirebaseAdminClient().getBlockingStub();
    ListIndexesRequest listIndexesRequest = ListIndexesRequest.newBuilder().setParent("projects/firestoretestclient/databases/(default)").build();
    ListIndexesResponse response;
    try {
        response = blockingStub.listIndexes(listIndexesRequest);
    } catch (Exception e) {
        System.out.println("Error during call: " + e.getMessage() + e.getCause());
        return;
    }
    List<Index> indexList = response.getIndexesList();
    DrawIndex di = new DrawIndex();
    for (Index index : indexList) {
        di.drawIndex(index);
    }
    Menu menu = new Menu();
    menu.draw();
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1beta1.ListIndexesResponse) FirestoreAdminBlockingStub(com.google.firestore.admin.v1beta1.FirestoreAdminGrpc.FirestoreAdminBlockingStub) DrawIndex(org.roguewave.grpc.util.gfx.DrawIndex) Index(com.google.firestore.admin.v1beta1.Index) DrawIndex(org.roguewave.grpc.util.gfx.DrawIndex) Menu(org.roguewave.grpc.util.gfx.Menu) GRPCFirebaseAdminClientFactory(org.roguewave.grpc.util.GRPCFirebaseAdminClientFactory) ListIndexesRequest(com.google.firestore.admin.v1beta1.ListIndexesRequest)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)3 Test (org.junit.Test)3 ListIndexesPagedResponse (com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse)2 Index (com.google.firestore.admin.v1.Index)2 ListIndexesRequest (com.google.firestore.admin.v1.ListIndexesRequest)2 ListIndexesResponse (com.google.firestore.admin.v1.ListIndexesResponse)2 ListIndexesPagedResponse (com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse)1 Index (com.google.datastore.admin.v1.Index)1 ListIndexesRequest (com.google.datastore.admin.v1.ListIndexesRequest)1 ListIndexesResponse (com.google.datastore.admin.v1.ListIndexesResponse)1 CollectionGroupName (com.google.firestore.admin.v1.CollectionGroupName)1 FirestoreAdminBlockingStub (com.google.firestore.admin.v1beta1.FirestoreAdminGrpc.FirestoreAdminBlockingStub)1 Index (com.google.firestore.admin.v1beta1.Index)1 ListIndexesRequest (com.google.firestore.admin.v1beta1.ListIndexesRequest)1 ListIndexesResponse (com.google.firestore.admin.v1beta1.ListIndexesResponse)1 GRPCFirebaseAdminClientFactory (org.roguewave.grpc.util.GRPCFirebaseAdminClientFactory)1 DrawIndex (org.roguewave.grpc.util.gfx.DrawIndex)1 Menu (org.roguewave.grpc.util.gfx.Menu)1