use of com.google.logging.v2.ListViewsRequest 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()));
}
use of com.google.logging.v2.ListViewsRequest in project gapic-generator-java by googleapis.
the class AsyncListViews method asyncListViews.
public static void asyncListViews() 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();
ApiFuture<LogView> future = configClient.listViewsPagedCallable().futureCall(request);
// Do something.
for (LogView element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
}
use of com.google.logging.v2.ListViewsRequest 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;
}
}
}
}
use of com.google.logging.v2.ListViewsRequest 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()));
}
Aggregations