@@ -313,6 +313,87 @@ void testUploadCallable_closesPayloadOnStartSyncFailure() {
313313 assertThat (stream .closed ).isTrue ();
314314 }
315315
316+ @ Test
317+ void testUploadCallable_withApiCallContext_mergesAndPassesContext () throws Exception {
318+ stubStartSession ("https://upload.url/context" );
319+ when (mockChunkCallable .futureCall (any (ChunkUploadRequest .class ), any ()))
320+ .thenReturn (ApiFutures .immediateFuture (ChunkUploadResponse .create (true , "done-ctx" )));
321+
322+ ApiCallContext customContext =
323+ FakeCallContext .createDefault ()
324+ .withExtraHeaders (
325+ java .util .Collections .singletonMap (
326+ "X-Custom" , java .util .Collections .singletonList ("val" )));
327+ ResumableUploadFuture <String > future =
328+ callable .futureCall ("resource-path" , streamOf ("data" ), customContext , null );
329+ assertThat (future .get ()).isEqualTo ("done-ctx" );
330+
331+ ArgumentCaptor <ApiCallContext > startContextCaptor =
332+ ArgumentCaptor .forClass (ApiCallContext .class );
333+ verify (mockStartCallable ).futureCall (any (), startContextCaptor .capture ());
334+ assertThat (startContextCaptor .getValue ()).isNotNull ();
335+ assertThat (((FakeCallContext ) startContextCaptor .getValue ()).getExtraHeaders ())
336+ .containsKey ("X-Custom" );
337+
338+ ArgumentCaptor <ApiCallContext > chunkContextCaptor =
339+ ArgumentCaptor .forClass (ApiCallContext .class );
340+ verify (mockChunkCallable ).futureCall (any (), chunkContextCaptor .capture ());
341+ assertThat (chunkContextCaptor .getValue ()).isNotNull ();
342+ assertThat (((FakeCallContext ) chunkContextCaptor .getValue ()).getExtraHeaders ())
343+ .doesNotContainKey ("X-Custom" );
344+ }
345+
346+ @ Test
347+ void testUploadCallable_withSettings_mergesAndAppliesSettings () throws Exception {
348+ stubStartSession ("https://upload.url/settings" );
349+ when (mockChunkCallable .futureCall (any (ChunkUploadRequest .class ), any ()))
350+ .thenReturn (ApiFutures .immediateFuture (ChunkUploadResponse .create (true , "done-settings" )));
351+
352+ ResumableUploadCallSettings customSettings =
353+ ResumableUploadCallSettings .newBuilder ().setChunkSize (16 ).build ();
354+
355+ ResumableUploadFuture <String > future =
356+ callable .futureCall ("resource-path" , streamOf ("data" ), null , customSettings );
357+ assertThat (future .get ()).isEqualTo ("done-settings" );
358+ }
359+
360+ @ Test
361+ void testUploadCallable_withSettings_delegatesWithNullContext () throws Exception {
362+ stubStartSession ("https://upload.url/settings-convenience" );
363+ when (mockChunkCallable .futureCall (any (ChunkUploadRequest .class ), any ()))
364+ .thenReturn (
365+ ApiFutures .immediateFuture (ChunkUploadResponse .create (true , "done-settings-conv" )));
366+
367+ ResumableUploadCallSettings customSettings =
368+ ResumableUploadCallSettings .newBuilder ().setChunkSize (16 ).build ();
369+
370+ ResumableUploadFuture <String > future =
371+ callable .futureCall ("resource-path" , streamOf ("data" ), customSettings );
372+ assertThat (future .get ()).isEqualTo ("done-settings-conv" );
373+ }
374+
375+ @ Test
376+ void testUploadCallable_withContextAndSettings_appliesBoth () throws Exception {
377+ stubStartSession ("https://upload.url/ctx-settings" );
378+ when (mockChunkCallable .futureCall (any (ChunkUploadRequest .class ), any ()))
379+ .thenReturn (ApiFutures .immediateFuture (ChunkUploadResponse .create (true , "done-both" )));
380+
381+ FakeCallContext customContext = FakeCallContext .createDefault ();
382+ ResumableUploadCallSettings customSettings =
383+ ResumableUploadCallSettings .newBuilder ().setChunkSize (16 ).build ();
384+
385+ ResumableUploadFuture <String > future =
386+ callable .futureCall ("resource-path" , streamOf ("data" ), customContext , customSettings );
387+ assertThat (future .get ()).isEqualTo ("done-both" );
388+ }
389+
390+ @ Test
391+ void testResumeCall_throwsUnsupportedOperationException () {
392+ assertThrows (
393+ UnsupportedOperationException .class ,
394+ () -> callable .resumeCall ("https://upload.url/session" , streamOf ("data" ), null ));
395+ }
396+
316397 private void stubStartSession (String uploadUrl ) {
317398 when (mockStartCallable .futureCall (any (), any ()))
318399 .thenReturn (
0 commit comments