UnaryCallable { public ResponseT call(RequestT request, ApiCallContext context) { return ApiExceptions.callAndTranslateApiException(futureCall(request, context)); } protected  UnaryCallable(); abstract ApiFuture<ResponseT> futureCall(RequestT request, ApiCallContext context); ApiFuture<ResponseT> futureCall(RequestT request); ResponseT call(RequestT request, ApiCallContext context); ResponseT call(RequestT request); UnaryCallable<RequestT, ResponseT> withDefaultCallContext(
      final ApiCallContext defaultCallContext);  }
@Test public void simpleCall() throws Exception { StashCallable<Integer, Integer> stashCallable = new StashCallable<>(1); Integer response = stashCallable.call(2, FakeCallContext.createDefault()); Truth.assertThat(response).isEqualTo(Integer.valueOf(1)); FakeCallContext callContext = (FakeCallContext) stashCallable.getContext(); Truth.assertThat(callContext.getChannel()).isNull(); Truth.assertThat(callContext.getCredentials()).isNull(); }
@Test public void call() throws Exception { ApiCallContext defaultCallContext = FakeCallContext.createDefault(); StashCallable<Integer, Integer> stashCallable = new StashCallable<>(1); UnaryCallable<Integer, Integer> callable = stashCallable.withDefaultCallContext(defaultCallContext); Integer response = callable.call(2); Truth.assertThat(response).isEqualTo(Integer.valueOf(1)); Truth.assertThat(stashCallable.getContext()).isNotNull(); Truth.assertThat(stashCallable.getContext()).isSameInstanceAs(defaultCallContext); }