Search in sources :

Example 1 with FakeApiClock

use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.

the class CancellationTest method resetClock.

@Before
public void resetClock() {
    fakeClock = new FakeApiClock(System.nanoTime());
    executor = RecordingScheduler.create(fakeClock);
    clientContext = ClientContext.newBuilder().setExecutor(executor).setClock(fakeClock).setDefaultCallContext(FakeCallContext.createDefault()).setTransportChannel(FakeTransportChannel.create(new FakeChannel())).build();
}
Also used : FakeApiClock(com.google.api.gax.core.FakeApiClock) FakeChannel(com.google.api.gax.rpc.testing.FakeChannel) Before(org.junit.Before)

Example 2 with FakeApiClock

use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.

the class OperationCallableImplTest method setUp.

@Before
public void setUp() throws IOException {
    initialChannel = mock(FakeChannel.class);
    pollTransportChannel = mock(TransportChannel.class);
    TransportChannelProvider operationsChannelProvider = mock(TransportChannelProvider.class);
    when(operationsChannelProvider.getTransportChannel()).thenReturn(pollTransportChannel);
    clock = new FakeApiClock(0L);
    executor = RecordingScheduler.create(clock);
    pollingAlgorithm = OperationTimedPollAlgorithm.create(FAST_RECHECKING_SETTINGS, clock);
    UnaryCallSettings<Integer, OperationSnapshot> initialCallSettings = UnaryCallSettings.<Integer, OperationSnapshot>newUnaryCallSettingsBuilder().setRetrySettings(FAST_RETRY_SETTINGS.toBuilder().setMaxAttempts(1).build()).build();
    callSettings = OperationCallSettings.<Integer, Color, Currency>newBuilder().setInitialCallSettings(initialCallSettings).setResponseTransformer(new ResponseTransformer()).setMetadataTransformer(new MetadataTransformer()).setPollingAlgorithm(pollingAlgorithm).build();
    initialContext = getClientContext(initialChannel, executor);
}
Also used : Color(java.awt.Color) Currency(java.util.Currency) FakeApiClock(com.google.api.gax.core.FakeApiClock) FakeTransportChannel(com.google.api.gax.rpc.testing.FakeTransportChannel) OperationSnapshot(com.google.api.gax.longrunning.OperationSnapshot) FakeOperationSnapshot(com.google.api.gax.rpc.testing.FakeOperationSnapshot) FakeChannel(com.google.api.gax.rpc.testing.FakeChannel) Before(org.junit.Before)

Example 3 with FakeApiClock

use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.

the class RetryingTest method resetClock.

@Before
public void resetClock() {
    fakeClock = new FakeApiClock(System.nanoTime());
    executor = RecordingScheduler.create(fakeClock);
    clientContext = ClientContext.newBuilder().setExecutor(executor).setClock(fakeClock).setDefaultCallContext(FakeCallContext.createDefault()).setTransportChannel(FakeTransportChannel.create(new FakeChannel())).build();
}
Also used : FakeApiClock(com.google.api.gax.core.FakeApiClock) FakeChannel(com.google.api.gax.rpc.testing.FakeChannel) Before(org.junit.Before)

Example 4 with FakeApiClock

use of com.google.api.gax.core.FakeApiClock 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)

Example 5 with FakeApiClock

use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.

the class WatchdogTest method setUp.

@Before
public void setUp() {
    clock = new FakeApiClock(0);
    watchdog = Watchdog.create(clock, checkInterval, EXECUTOR);
    callable = new MockServerStreamingCallable<>();
    innerObserver = new AccumulatingObserver<>();
    callable.call("request", watchdog.watch(innerObserver, waitTime, idleTime));
    call = callable.popLastCall();
}
Also used : FakeApiClock(com.google.api.gax.core.FakeApiClock) Before(org.junit.Before)

Aggregations

FakeApiClock (com.google.api.gax.core.FakeApiClock)6 Before (org.junit.Before)6 FakeChannel (com.google.api.gax.rpc.testing.FakeChannel)3 OperationSnapshot (com.google.api.gax.longrunning.OperationSnapshot)2 TransportChannel (com.google.api.gax.rpc.TransportChannel)1 TransportChannelProvider (com.google.api.gax.rpc.TransportChannelProvider)1 FakeOperationSnapshot (com.google.api.gax.rpc.testing.FakeOperationSnapshot)1 FakeTransportChannel (com.google.api.gax.rpc.testing.FakeTransportChannel)1 OperationsSettings (com.google.longrunning.OperationsSettings)1 Color (com.google.type.Color)1 Money (com.google.type.Money)1 ManagedChannel (io.grpc.ManagedChannel)1 Color (java.awt.Color)1 Currency (java.util.Currency)1