2121
2222import com .google .adk .agents .InvocationContext ;
2323import com .google .adk .agents .RunConfig ;
24+ import com .google .adk .events .ToolConfirmation ;
2425import com .google .adk .sessions .Session ;
2526import com .google .common .collect .ImmutableList ;
2627import com .google .common .collect .ImmutableMap ;
3435import java .util .HashMap ;
3536import java .util .List ;
3637import java .util .Map ;
37- import java .util .Optional ;
3838import org .junit .Test ;
3939import org .junit .runner .RunWith ;
4040import org .junit .runners .JUnit4 ;
@@ -236,18 +236,10 @@ public void call_withAllSupportedParameterTypes() throws Exception {
236236 FunctionTool tool = FunctionTool .create (Functions .class , "returnAllSupportedParametersAsMap" );
237237 ToolContext toolContext =
238238 ToolContext .builder (
239- new InvocationContext (
240- /* sessionService= */ null ,
241- /* artifactService= */ null ,
242- /* memoryService= */ null ,
243- /* liveRequestQueue= */ Optional .empty (),
244- /* branch= */ Optional .empty (),
245- /* invocationId= */ null ,
246- /* agent= */ null ,
247- /* session= */ Session .builder ("123" ).build (),
248- /* userContent= */ Optional .empty (),
249- /* runConfig= */ RunConfig .builder ().build (),
250- /* endInvocation= */ false ))
239+ InvocationContext .builder ()
240+ .session (Session .builder ("123" ).build ())
241+ .runConfig (RunConfig .builder ().build ())
242+ .build ())
251243 .functionCallId ("functionCallId" )
252244 .build ();
253245
@@ -593,18 +585,7 @@ public void call_nonStaticWithAllSupportedParameterTypes() throws Exception {
593585 FunctionTool .create (functions , "nonStaticReturnAllSupportedParametersAsMap" );
594586 ToolContext toolContext =
595587 ToolContext .builder (
596- new InvocationContext (
597- /* sessionService= */ null ,
598- /* artifactService= */ null ,
599- /* memoryService= */ null ,
600- /* liveRequestQueue= */ Optional .empty (),
601- /* branch= */ Optional .empty (),
602- /* invocationId= */ null ,
603- /* agent= */ null ,
604- /* session= */ Session .builder ("123" ).build (),
605- /* userContent= */ Optional .empty (),
606- /* runConfig= */ null ,
607- /* endInvocation= */ false ))
588+ InvocationContext .builder ().session (Session .builder ("123" ).build ()).build ())
608589 .functionCallId ("functionCallId" )
609590 .build ();
610591
@@ -655,18 +636,7 @@ public void runAsync_withRequireConfirmation() throws Exception {
655636 new FunctionTool (null , method , /* isLongRunning= */ false , /* requireConfirmation= */ true );
656637 ToolContext toolContext =
657638 ToolContext .builder (
658- new InvocationContext (
659- /* sessionService= */ null ,
660- /* artifactService= */ null ,
661- /* memoryService= */ null ,
662- /* liveRequestQueue= */ Optional .empty (),
663- /* branch= */ Optional .empty (),
664- /* invocationId= */ null ,
665- /* agent= */ null ,
666- /* session= */ Session .builder ("123" ).build (),
667- /* userContent= */ Optional .empty (),
668- /* runConfig= */ null ,
669- /* endInvocation= */ false ))
639+ InvocationContext .builder ().session (Session .builder ("123" ).build ()).build ())
670640 .functionCallId ("functionCallId" )
671641 .build ();
672642
@@ -699,18 +669,7 @@ public void create_instanceMethodWithConfirmation_requestsConfirmation() throws
699669 FunctionTool tool = FunctionTool .create (functions , method , /* requireConfirmation= */ true );
700670 ToolContext toolContext =
701671 ToolContext .builder (
702- new InvocationContext (
703- /* sessionService= */ null ,
704- /* artifactService= */ null ,
705- /* memoryService= */ null ,
706- /* liveRequestQueue= */ Optional .empty (),
707- /* branch= */ Optional .empty (),
708- /* invocationId= */ null ,
709- /* agent= */ null ,
710- /* session= */ Session .builder ("123" ).build (),
711- /* userContent= */ Optional .empty (),
712- /* runConfig= */ null ,
713- /* endInvocation= */ false ))
672+ InvocationContext .builder ().session (Session .builder ("123" ).build ()).build ())
714673 .functionCallId ("functionCallId" )
715674 .build ();
716675
@@ -727,18 +686,7 @@ public void create_staticMethodWithConfirmation_requestsConfirmation() throws Ex
727686 FunctionTool tool = FunctionTool .create (method , /* requireConfirmation= */ true );
728687 ToolContext toolContext =
729688 ToolContext .builder (
730- new InvocationContext (
731- /* sessionService= */ null ,
732- /* artifactService= */ null ,
733- /* memoryService= */ null ,
734- /* liveRequestQueue= */ Optional .empty (),
735- /* branch= */ Optional .empty (),
736- /* invocationId= */ null ,
737- /* agent= */ null ,
738- /* session= */ Session .builder ("123" ).build (),
739- /* userContent= */ Optional .empty (),
740- /* runConfig= */ null ,
741- /* endInvocation= */ false ))
689+ InvocationContext .builder ().session (Session .builder ("123" ).build ()).build ())
742690 .functionCallId ("functionCallId" )
743691 .build ();
744692
@@ -756,18 +704,7 @@ public void create_classMethodNameWithConfirmation_requestsConfirmation() throws
756704 Functions .class , "voidReturnWithoutSchema" , /* requireConfirmation= */ true );
757705 ToolContext toolContext =
758706 ToolContext .builder (
759- new InvocationContext (
760- /* sessionService= */ null ,
761- /* artifactService= */ null ,
762- /* memoryService= */ null ,
763- /* liveRequestQueue= */ Optional .empty (),
764- /* branch= */ Optional .empty (),
765- /* invocationId= */ null ,
766- /* agent= */ null ,
767- /* session= */ Session .builder ("123" ).build (),
768- /* userContent= */ Optional .empty (),
769- /* runConfig= */ null ,
770- /* endInvocation= */ false ))
707+ InvocationContext .builder ().session (Session .builder ("123" ).build ()).build ())
771708 .functionCallId ("functionCallId" )
772709 .build ();
773710
@@ -786,18 +723,7 @@ public void create_instanceMethodNameWithConfirmation_requestsConfirmation() thr
786723 functions , "nonStaticVoidReturnWithoutSchema" , /* requireConfirmation= */ true );
787724 ToolContext toolContext =
788725 ToolContext .builder (
789- new InvocationContext (
790- /* sessionService= */ null ,
791- /* artifactService= */ null ,
792- /* memoryService= */ null ,
793- /* liveRequestQueue= */ Optional .empty (),
794- /* branch= */ Optional .empty (),
795- /* invocationId= */ null ,
796- /* agent= */ null ,
797- /* session= */ Session .builder ("123" ).build (),
798- /* userContent= */ Optional .empty (),
799- /* runConfig= */ null ,
800- /* endInvocation= */ false ))
726+ InvocationContext .builder ().session (Session .builder ("123" ).build ()).build ())
801727 .functionCallId ("functionCallId" )
802728 .build ();
803729
0 commit comments