File tree Expand file tree Collapse file tree
test/java/com/google/adk/runner Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ public Builder plugins(List<? extends Plugin> plugins) {
104104 return this ;
105105 }
106106
107+ @ CanIgnoreReturnValue
108+ public Builder plugins (Plugin ... plugins ) {
109+ this .plugins = ImmutableList .copyOf (plugins );
110+ return this ;
111+ }
112+
107113 @ CanIgnoreReturnValue
108114 public Builder eventsCompactionConfig (EventsCompactionConfig eventsCompactionConfig ) {
109115 this .eventsCompactionConfig = eventsCompactionConfig ;
Original file line number Diff line number Diff line change 2323import com .google .adk .models .LlmResponse ;
2424import com .google .adk .tools .BaseTool ;
2525import com .google .adk .tools .ToolContext ;
26+ import com .google .common .annotations .VisibleForTesting ;
27+ import com .google .common .collect .ImmutableList ;
2628import com .google .genai .types .Content ;
2729import io .reactivex .rxjava3 .core .Completable ;
2830import io .reactivex .rxjava3 .core .Flowable ;
@@ -81,6 +83,21 @@ public Optional<Plugin> getPlugin(String pluginName) {
8183 return plugins .stream ().filter (p -> p .getName ().equals (pluginName )).findFirst ();
8284 }
8385
86+ /**
87+ * Returns the list of registered plugins.
88+ *
89+ * <p>This method is intended for testing purposes only.
90+ *
91+ * <p>Note that it returns a copy of the plugins list to prevent modification of the original
92+ * list.
93+ *
94+ * @return The list of registered plugins.
95+ */
96+ @ VisibleForTesting
97+ public List <Plugin > getPlugins () {
98+ return ImmutableList .copyOf (plugins );
99+ }
100+
84101 // --- Callback Runners ---
85102
86103 public Maybe <Content > runOnUserMessageCallback (
Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ public Builder plugins(List<? extends Plugin> plugins) {
132132 return this ;
133133 }
134134
135+ @ CanIgnoreReturnValue
136+ public Builder plugins (Plugin ... plugins ) {
137+ Preconditions .checkState (this .app == null , "plugins() cannot be called when app is set." );
138+ this .plugins = ImmutableList .copyOf (plugins );
139+ return this ;
140+ }
141+
135142 public Runner build () {
136143 BaseAgent buildAgent ;
137144 String buildAppName ;
Original file line number Diff line number Diff line change @@ -1188,6 +1188,14 @@ public void close_closesPluginsAndCodeExecutors() {
11881188 verify (plugin ).close ();
11891189 }
11901190
1191+ @ Test
1192+ public void buildRunnerWithPlugins_success () {
1193+ BasePlugin plugin1 = mockPlugin ("test1" );
1194+ BasePlugin plugin2 = mockPlugin ("test2" );
1195+ Runner runner = Runner .builder ().agent (agent ).appName ("test" ).plugins (plugin1 , plugin2 ).build ();
1196+ assertThat (runner .pluginManager ().getPlugins ()).containsExactly (plugin1 , plugin2 );
1197+ }
1198+
11911199 public static class Tools {
11921200 private Tools () {}
11931201
You can’t perform that action at this time.
0 commit comments