bitField0_ = (bitField0_ & ~0x00000001); } else { ensureSinksIsMutable(); sinks_.addAll(other.sinks_); onChanged(); sinksBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getSinksFieldBuilder() : null; } else { onChanged(); this.mergeUnknownFields(other.unknownFields); onChanged(); return this;
private com.google.protobuf.RepeatedFieldBuilderV3< com.google.logging.v2.LogSink, com.google.logging.v2.LogSink.Builder, com.google.logging.v2.LogSinkOrBuilder> getSinksFieldBuilder() { if (sinksBuilder_ == null) { sinksBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< com.google.logging.v2.LogSink, com.google.logging.v2.LogSink.Builder, com.google.logging.v2.LogSinkOrBuilder>( sinks_, ((bitField0_ & 0x00000001) == 0x00000001), getParentForChildren(), isClean()); sinks_ = null; } return sinksBuilder_; }
@java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.logging.v2.ListSinksResponse parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.logging.v2.ListSinksResponse) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
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);
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);
@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)); }
@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)); }
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder setSinks(int index, com.google.logging.v2.LogSink value) { if (sinksBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureSinksIsMutable(); sinks_.set(index, value); onChanged(); } else { sinksBuilder_.setMessage(index, value); } return this; } /**
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder addSinks(com.google.logging.v2.LogSink value) { if (sinksBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureSinksIsMutable(); sinks_.add(value); onChanged(); } else { sinksBuilder_.addMessage(value); } return this; } /**
@Test @SuppressWarnings("all") public void listSinksTest() { String nextPageToken = ""; LogSink sinksElement = LogSink.newBuilder().build(); List<LogSink> sinks = Arrays.asList(sinksElement); ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken(nextPageToken).addAllSinks(sinks).build(); mockConfigServiceV2.addResponse(expectedResponse); ParentName parent = ProjectName.of("[PROJECT]"); ListSinksPagedResponse pagedListResponse = client.listSinks(parent); List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0)); List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListSinksRequest actualRequest = (ListSinksRequest) actualRequests.get(0); Assert.assertEquals(parent, ParentNames.parse(actualRequest.getParent())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder addSinks(int index, com.google.logging.v2.LogSink.Builder builderForValue) { if (sinksBuilder_ == null) { ensureSinksIsMutable(); sinks_.add(index, builderForValue.build()); onChanged(); } else { sinksBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder setSinks(int index, com.google.logging.v2.LogSink.Builder builderForValue) { if (sinksBuilder_ == null) { ensureSinksIsMutable(); sinks_.set(index, builderForValue.build()); onChanged(); } else { sinksBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder addSinks(int index, com.google.logging.v2.LogSink value) { if (sinksBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureSinksIsMutable(); sinks_.add(index, value); onChanged(); } else { sinksBuilder_.addMessage(index, value); } return this; } /**
@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)); }
@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)); }
@Test public void testListSinksAsyncEmpty() throws ExecutionException, InterruptedException { EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListSinksRequest request = ListSinksRequest.newBuilder().setParent(PROJECT_PB).build(); List<Sink> sinkList = ImmutableList.of(); ListSinksResponse response = ListSinksResponse.newBuilder() .setNextPageToken("") .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(); assertNull(page.getNextPageToken()); assertNull(page.getNextPage()); assertArrayEquals(sinkList.toArray(), Iterables.toArray(page.getValues(), Sink.class)); }
@Test public void testListSinksEmpty() { EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListSinksRequest request = ListSinksRequest.newBuilder().setParent(PROJECT_PB).build(); List<Sink> sinkList = ImmutableList.of(); ListSinksResponse response = ListSinksResponse.newBuilder() .setNextPageToken("") .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(); assertNull(page.getNextPageToken()); assertNull(page.getNextPage()); assertArrayEquals(sinkList.toArray(), Iterables.toArray(page.getValues(), Sink.class)); }
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder removeSinks(int index) { if (sinksBuilder_ == null) { ensureSinksIsMutable(); sinks_.remove(index); onChanged(); } else { sinksBuilder_.remove(index); } return this; } /**
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder addAllSinks(java.lang.Iterable<? extends com.google.logging.v2.LogSink> values) { if (sinksBuilder_ == null) { ensureSinksIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll(values, sinks_); onChanged(); } else { sinksBuilder_.addAllMessages(values); } return this; } /**
/** * * * <pre> * A list of sinks. * </pre> * * <code>repeated .google.logging.v2.LogSink sinks = 1;</code> */ public Builder addSinks(com.google.logging.v2.LogSink.Builder builderForValue) { if (sinksBuilder_ == null) { ensureSinksIsMutable(); sinks_.add(builderForValue.build()); onChanged(); } else { sinksBuilder_.addMessage(builderForValue.build()); } return this; } /**