Search in sources :

Example 1 with ListViewsPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListViewsPagedResponse 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 ListViewsPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListViewsPagedResponse 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

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