Search in sources :

Example 1 with ListViewsResponse

use of com.google.logging.v2.ListViewsResponse in project java-logging by googleapis.

the class ConfigClientTest method listViewsTest.

@Test
public void listViewsTest() throws Exception {
    LogView responsesElement = LogView.newBuilder().build();
    ListViewsResponse expectedResponse = ListViewsResponse.newBuilder().setNextPageToken("").addAllViews(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListViewsPagedResponse pagedListResponse = client.listViews(parent);
    List<LogView> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getViewsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListViewsRequest actualRequest = ((ListViewsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListViewsRequest(com.google.logging.v2.ListViewsRequest) ListViewsResponse(com.google.logging.v2.ListViewsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListViewsPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListViewsPagedResponse) LogView(com.google.logging.v2.LogView) Test(org.junit.Test)

Example 2 with ListViewsResponse

use of com.google.logging.v2.ListViewsResponse in project gapic-generator-java by googleapis.

the class AsyncListViewsPaged method asyncListViewsPaged.

public static void asyncListViewsPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        ListViewsRequest request = ListViewsRequest.newBuilder().setParent("parent-995424086").setPageToken("pageToken873572522").setPageSize(883849137).build();
        while (true) {
            ListViewsResponse response = configClient.listViewsCallable().call(request);
            for (LogView element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : ListViewsRequest(com.google.logging.v2.ListViewsRequest) ListViewsResponse(com.google.logging.v2.ListViewsResponse) ConfigClient(com.google.cloud.logging.v2.ConfigClient) LogView(com.google.logging.v2.LogView)

Example 3 with ListViewsResponse

use of com.google.logging.v2.ListViewsResponse in project gapic-generator-java by googleapis.

the class ConfigClientTest method listViewsTest.

@Test
public void listViewsTest() throws Exception {
    LogView responsesElement = LogView.newBuilder().build();
    ListViewsResponse expectedResponse = ListViewsResponse.newBuilder().setNextPageToken("").addAllViews(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListViewsPagedResponse pagedListResponse = client.listViews(parent);
    List<LogView> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getViewsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListViewsRequest actualRequest = ((ListViewsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListViewsRequest(com.google.logging.v2.ListViewsRequest) ListViewsResponse(com.google.logging.v2.ListViewsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListViewsPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListViewsPagedResponse) LogView(com.google.logging.v2.LogView) Test(org.junit.Test)

Aggregations

ListViewsRequest (com.google.logging.v2.ListViewsRequest)3 ListViewsResponse (com.google.logging.v2.ListViewsResponse)3 LogView (com.google.logging.v2.LogView)3 ListViewsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListViewsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ConfigClient (com.google.cloud.logging.v2.ConfigClient)1