use of com.google.longrunning.OperationsSettings in project gax-java by googleapis.
the class GrpcLongRunningTest method setUp.
@Before
public void setUp() throws IOException {
channel = mock(ManagedChannel.class);
TransportChannelProvider operationsChannelProvider = mock(TransportChannelProvider.class);
TransportChannel transportChannel = GrpcTransportChannel.newBuilder().setManagedChannel(channel).build();
when(operationsChannelProvider.getTransportChannel()).thenReturn(transportChannel);
clock = new FakeApiClock(0L);
executor = RecordingScheduler.create(clock);
pollingAlgorithm = OperationTimedPollAlgorithm.create(FAST_RETRY_SETTINGS, clock);
OperationsSettings.Builder settingsBuilder = OperationsSettings.newBuilder();
settingsBuilder.getOperationSettings().setRetrySettings(FAST_RETRY_SETTINGS.toBuilder().setMaxAttempts(1).build());
OperationsSettings settings = OperationsSettings.newBuilder().setTransportChannelProvider(operationsChannelProvider).build();
operationsStub = GrpcOperationsStub.create(((OperationsStubSettings) settings.getStubSettings()));
UnaryCallSettings<Integer, OperationSnapshot> initialCallSettings = UnaryCallSettings.<Integer, OperationSnapshot>newUnaryCallSettingsBuilder().setRetrySettings(FAST_RETRY_SETTINGS.toBuilder().setMaxAttempts(1).build()).build();
callSettings = OperationCallSettings.<Integer, Color, Money>newBuilder().setInitialCallSettings(initialCallSettings).setResponseTransformer(ProtoOperationTransformers.ResponseTransformer.create(Color.class)).setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Money.class)).setPollingAlgorithm(pollingAlgorithm).build();
initialContext = ClientContext.newBuilder().setTransportChannel(GrpcTransportChannel.newBuilder().setManagedChannel(channel).build()).setExecutor(executor).setDefaultCallContext(GrpcCallContext.of(channel, CallOptions.DEFAULT)).setClock(clock).build();
}
Aggregations