Refine search
static Sink fromPb(Logging logging, LogSink sinkPb) { SinkInfo sinkInfo = SinkInfo.fromPb(sinkPb); return new Sink(logging, new BuilderImpl(sinkInfo)); }
@Test public void testUpdate() { initializeExpectedSink(2); SinkInfo updatedInfo = SINK_INFO.toBuilder().setFilter(NEW_FILTER).build(); Sink expectedSink = new Sink(serviceMockReturnsOptions, new SinkInfo.BuilderImpl(updatedInfo)); expect(logging.getOptions()).andReturn(mockOptions).times(2); expect(logging.update(expectedSink)).andReturn(expectedSink); replay(logging); initializeSink(); Sink updatedSink = sink.toBuilder().setFilter(NEW_FILTER).build().update(); compareSink(expectedSink, updatedSink); }
@Test public void testUpdateAsync() throws ExecutionException, InterruptedException { initializeExpectedSink(2); SinkInfo updatedInfo = SINK_INFO.toBuilder().setFilter(NEW_FILTER).build(); Sink expectedSink = new Sink(serviceMockReturnsOptions, new SinkInfo.BuilderImpl(updatedInfo)); expect(logging.getOptions()).andReturn(mockOptions).times(2); expect(logging.updateAsync(expectedSink)).andReturn(ApiFutures.immediateFuture(expectedSink)); replay(logging); initializeSink(); Sink updatedSink = sink.toBuilder().setFilter(NEW_FILTER).build().updateAsync().get(); compareSink(expectedSink, updatedSink); }
@Test public void testReload() { initializeExpectedSink(2); SinkInfo updatedInfo = SINK_INFO.toBuilder().setFilter(NEW_FILTER).build(); Sink expectedSink = new Sink(serviceMockReturnsOptions, new SinkInfo.BuilderImpl(updatedInfo)); expect(logging.getOptions()).andReturn(mockOptions); expect(logging.getSink(NAME)).andReturn(expectedSink); replay(logging); initializeSink(); Sink updatedSink = sink.reload(); compareSink(expectedSink, updatedSink); }
@Test public void testReloadAsync() throws ExecutionException, InterruptedException { initializeExpectedSink(2); SinkInfo updatedInfo = SINK_INFO.toBuilder().setFilter(NEW_FILTER).build(); Sink expectedSink = new Sink(serviceMockReturnsOptions, new SinkInfo.BuilderImpl(updatedInfo)); expect(logging.getOptions()).andReturn(mockOptions); expect(logging.getSinkAsync(NAME)).andReturn(ApiFutures.immediateFuture(expectedSink)); replay(logging); initializeSink(); Sink updatedSink = sink.reloadAsync().get(); compareSink(expectedSink, updatedSink); }
@Override public Builder setFilter(String filter) { delegate.setFilter(filter); return this; }
@Override public Builder setDestination(Destination destination) { delegate.setDestination(destination); return this; }
/** * Returns a builder for {@code SinkInfo} objects given the name of the sink and its destination. */ public static Builder newBuilder(String name, Destination destination) { return new BuilderImpl(name, destination); }
@Override public Builder setName(String name) { delegate.setName(name); return this; }
@Override public Builder setVersionFormat(VersionFormat versionFormat) { delegate.setVersionFormat(versionFormat); return this; }
/** Creates a {@code SinkInfo} object given the name of the sink and its destination. */ public static SinkInfo of(String name, Destination destination) { return new BuilderImpl(name, destination).build(); }
private Builder(Sink sink) { logging = sink.logging; delegate = new BuilderImpl(sink); }
/** Returns a builder for this {@code SinkInfo} object. */ public Builder toBuilder() { return new BuilderImpl(this); }
@Override public Builder setFilter(String filter) { delegate.setFilter(filter); return this; }
@Override public Builder setVersionFormat(VersionFormat versionFormat) { delegate.setVersionFormat(versionFormat); return this; }
@Override public Builder setName(String name) { delegate.setName(name); return this; }
@Override public Builder setDestination(Destination destination) { delegate.setDestination(destination); return this; }
/** * Returns a builder for {@code SinkInfo} objects given the name of the sink and its destination. */ public static Builder newBuilder(String name, Destination destination) { return new BuilderImpl(name, destination); }
/** Creates a {@code SinkInfo} object given the name of the sink and its destination. */ public static SinkInfo of(String name, Destination destination) { return new BuilderImpl(name, destination).build(); }
private Builder(Sink sink) { logging = sink.logging; delegate = new BuilderImpl(sink); }