use of com.google.api.gax.rpc.testing.FakeOperationApi.OperationStashCallable in project gax-java by googleapis.
the class OperationCallableImplTest method callResume.
@Test
public void callResume() throws Exception {
ApiCallContext defaultCallContext = FakeCallContext.createDefault();
OperationStashCallable stashCallable = new OperationStashCallable();
OperationCallable<Integer, String, Long> callable = stashCallable.withDefaultCallContext(defaultCallContext);
OperationFuture<String, Long> operationFuture = callable.futureCall(45);
String response = callable.resumeFutureCall(operationFuture.getName()).get();
Truth.assertThat(response).isEqualTo("45");
Truth.assertThat(stashCallable.getResumeContext()).isSameInstanceAs(defaultCallContext);
}
use of com.google.api.gax.rpc.testing.FakeOperationApi.OperationStashCallable in project gax-java by googleapis.
the class OperationCallableImplTest method callResumeWithContext.
@Test
public void callResumeWithContext() throws Exception {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
OperationStashCallable stashCallable = new OperationStashCallable();
OperationCallable<Integer, String, Long> callable = stashCallable.withDefaultCallContext(FakeCallContext.createDefault());
OperationFuture<String, Long> operationFuture = callable.futureCall(45);
String response = callable.resumeFutureCall(operationFuture.getName(), context).get();
Truth.assertThat(response).isEqualTo("45");
FakeCallContext actualContext = (FakeCallContext) stashCallable.getResumeContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
use of com.google.api.gax.rpc.testing.FakeOperationApi.OperationStashCallable in project gax-java by googleapis.
the class OperationCallableImplTest method callWithContext.
@Test
public void callWithContext() {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
OperationStashCallable stashCallable = new OperationStashCallable();
OperationCallable<Integer, String, Long> callable = stashCallable.withDefaultCallContext(FakeCallContext.createDefault());
String response = callable.call(2, context);
Truth.assertThat(response).isEqualTo("2");
FakeCallContext actualContext = (FakeCallContext) stashCallable.getContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
use of com.google.api.gax.rpc.testing.FakeOperationApi.OperationStashCallable in project gax-java by googleapis.
the class OperationCallableImplTest method callCancelWithContext.
@Test
public void callCancelWithContext() throws Exception {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
OperationStashCallable stashCallable = new OperationStashCallable();
OperationCallable<Integer, String, Long> callable = stashCallable.withDefaultCallContext(FakeCallContext.createDefault());
OperationFuture<String, Long> operationFuture = callable.futureCall(45);
callable.cancel(operationFuture.getName(), context).get();
Truth.assertThat(stashCallable.wasCancelCalled()).isTrue();
FakeCallContext actualContext = (FakeCallContext) stashCallable.getCancelContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
use of com.google.api.gax.rpc.testing.FakeOperationApi.OperationStashCallable in project gax-java by googleapis.
the class OperationCallableImplTest method call.
@Test
public void call() {
ApiCallContext defaultCallContext = FakeCallContext.createDefault();
OperationStashCallable stashCallable = new OperationStashCallable();
OperationCallable<Integer, String, Long> callable = stashCallable.withDefaultCallContext(defaultCallContext);
String response = callable.call(1);
Truth.assertThat(response).isEqualTo("1");
Truth.assertThat(stashCallable.getContext()).isSameInstanceAs(defaultCallContext);
}
Aggregations