use of com.google.logging.v2.ListSinksResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testListSinksAsyncNextPage.
@Test
public void testListSinksAsyncNextPage() throws ExecutionException, InterruptedException {
String cursor1 = "cursor";
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListSinksRequest request1 = ListSinksRequest.newBuilder().setParent(PROJECT_PB).build();
ListSinksRequest request2 = ListSinksRequest.newBuilder().setParent(PROJECT_PB).setPageToken(cursor1).build();
List<Sink> sinkList1 = ImmutableList.of(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)));
List<Sink> sinkList2 = ImmutableList.of(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)));
ListSinksResponse response1 = ListSinksResponse.newBuilder().setNextPageToken(cursor1).addAllSinks(Lists.transform(sinkList1, SINK_TO_PB_FUNCTION)).build();
String cursor2 = "nextCursor";
ListSinksResponse response2 = ListSinksResponse.newBuilder().setNextPageToken(cursor2).addAllSinks(Lists.transform(sinkList2, SINK_TO_PB_FUNCTION)).build();
ApiFuture<ListSinksResponse> futureResponse1 = ApiFutures.immediateFuture(response1);
ApiFuture<ListSinksResponse> futureResponse2 = ApiFutures.immediateFuture(response2);
EasyMock.expect(loggingRpcMock.list(request1)).andReturn(futureResponse1);
EasyMock.expect(loggingRpcMock.list(request2)).andReturn(futureResponse2);
EasyMock.replay(loggingRpcMock);
AsyncPage<Sink> page = logging.listSinksAsync().get();
assertEquals(cursor1, page.getNextPageToken());
assertArrayEquals(sinkList1.toArray(), Iterables.toArray(page.getValues(), Sink.class));
page = page.getNextPageAsync().get();
assertEquals(cursor2, page.getNextPageToken());
assertArrayEquals(sinkList2.toArray(), Iterables.toArray(page.getValues(), Sink.class));
}
use of com.google.logging.v2.ListSinksResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testListSinks.
@Test
public void testListSinks() {
String cursor = "cursor";
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListSinksRequest request = ListSinksRequest.newBuilder().setParent(PROJECT_PB).build();
List<Sink> sinkList = ImmutableList.of(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)));
ListSinksResponse response = ListSinksResponse.newBuilder().setNextPageToken(cursor).addAllSinks(Lists.transform(sinkList, SINK_TO_PB_FUNCTION)).build();
ApiFuture<ListSinksResponse> futureResponse = ApiFutures.immediateFuture(response);
EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse);
EasyMock.replay(loggingRpcMock);
Page<Sink> page = logging.listSinks();
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(sinkList.toArray(), Iterables.toArray(page.getValues(), Sink.class));
}
use of com.google.logging.v2.ListSinksResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testListSinksAsync.
@Test
public void testListSinksAsync() throws ExecutionException, InterruptedException {
String cursor = "cursor";
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListSinksRequest request = ListSinksRequest.newBuilder().setParent(PROJECT_PB).build();
List<Sink> sinkList = ImmutableList.of(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)));
ListSinksResponse response = ListSinksResponse.newBuilder().setNextPageToken(cursor).addAllSinks(Lists.transform(sinkList, SINK_TO_PB_FUNCTION)).build();
ApiFuture<ListSinksResponse> futureResponse = ApiFutures.immediateFuture(response);
EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse);
EasyMock.replay(loggingRpcMock);
AsyncPage<Sink> page = logging.listSinksAsync().get();
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(sinkList.toArray(), Iterables.toArray(page.getValues(), Sink.class));
}
use of com.google.logging.v2.ListSinksResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testListSinksWithOptionsAsync.
@Test
public void testListSinksWithOptionsAsync() throws ExecutionException, InterruptedException {
String cursor = "cursor";
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListSinksRequest request = ListSinksRequest.newBuilder().setPageToken(cursor).setPageSize(42).setParent(PROJECT_PB).build();
List<Sink> sinkList = ImmutableList.of(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)));
ListSinksResponse response = ListSinksResponse.newBuilder().setNextPageToken(cursor).addAllSinks(Lists.transform(sinkList, SINK_TO_PB_FUNCTION)).build();
ApiFuture<ListSinksResponse> futureResponse = ApiFutures.immediateFuture(response);
EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse);
EasyMock.replay(loggingRpcMock);
AsyncPage<Sink> page = logging.listSinksAsync(ListOption.pageSize(42), ListOption.pageToken(cursor)).get();
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(sinkList.toArray(), Iterables.toArray(page.getValues(), Sink.class));
}
use of com.google.logging.v2.ListSinksResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testListSinksWithOptions.
@Test
public void testListSinksWithOptions() {
String cursor = "cursor";
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListSinksRequest request = ListSinksRequest.newBuilder().setPageToken(cursor).setPageSize(42).setParent(PROJECT_PB).build();
List<Sink> sinkList = ImmutableList.of(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)));
ListSinksResponse response = ListSinksResponse.newBuilder().setNextPageToken(cursor).addAllSinks(Lists.transform(sinkList, SINK_TO_PB_FUNCTION)).build();
ApiFuture<ListSinksResponse> futureResponse = ApiFutures.immediateFuture(response);
EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse);
EasyMock.replay(loggingRpcMock);
Page<Sink> page = logging.listSinks(ListOption.pageSize(42), ListOption.pageToken(cursor));
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(sinkList.toArray(), Iterables.toArray(page.getValues(), Sink.class));
}
Aggregations