Search in sources :

Example 1 with OperationsSettings

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();
}
Also used : Money(com.google.type.Money) Color(com.google.type.Color) ManagedChannel(io.grpc.ManagedChannel) FakeApiClock(com.google.api.gax.core.FakeApiClock) TransportChannel(com.google.api.gax.rpc.TransportChannel) TransportChannelProvider(com.google.api.gax.rpc.TransportChannelProvider) OperationSnapshot(com.google.api.gax.longrunning.OperationSnapshot) OperationsSettings(com.google.longrunning.OperationsSettings) Before(org.junit.Before)

Aggregations

FakeApiClock (com.google.api.gax.core.FakeApiClock)1 OperationSnapshot (com.google.api.gax.longrunning.OperationSnapshot)1 TransportChannel (com.google.api.gax.rpc.TransportChannel)1 TransportChannelProvider (com.google.api.gax.rpc.TransportChannelProvider)1 OperationsSettings (com.google.longrunning.OperationsSettings)1 Color (com.google.type.Color)1 Money (com.google.type.Money)1 ManagedChannel (io.grpc.ManagedChannel)1 Before (org.junit.Before)1