|
31 | 31 | import static java.util.concurrent.TimeUnit.SECONDS; |
32 | 32 | import static org.mockito.ArgumentMatchers.any; |
33 | 33 | import static org.mockito.ArgumentMatchers.anyString; |
| 34 | +import static org.mockito.ArgumentMatchers.eq; |
34 | 35 | import static org.mockito.Mockito.CALLS_REAL_METHODS; |
35 | 36 | import static org.mockito.Mockito.mock; |
36 | 37 | import static org.mockito.Mockito.never; |
@@ -370,6 +371,33 @@ public void afterRunCallback_error() { |
370 | 371 | verify(plugin).afterRunCallback(any()); |
371 | 372 | } |
372 | 373 |
|
| 374 | + @Test |
| 375 | + public void onRunErrorCallback_isCalled() { |
| 376 | + Exception exception = new Exception("test run error"); |
| 377 | + TestLlm failingTestLlm = createTestLlm(Flowable.error(exception)); |
| 378 | + LlmAgent failingAgent = createTestAgentBuilder(failingTestLlm).build(); |
| 379 | + |
| 380 | + Runner failingRunner = |
| 381 | + Runner.builder() |
| 382 | + .app( |
| 383 | + App.builder() |
| 384 | + .name("test") |
| 385 | + .rootAgent(failingAgent) |
| 386 | + .plugins(ImmutableList.of(plugin)) |
| 387 | + .build()) |
| 388 | + .sessionService(this.runner.sessionService()) |
| 389 | + .build(); |
| 390 | + |
| 391 | + when(plugin.onRunErrorCallback(any(), any())).thenReturn(Completable.complete()); |
| 392 | + |
| 393 | + failingRunner |
| 394 | + .runAsync("user", session.id(), createContent("from user")) |
| 395 | + .test() |
| 396 | + .assertError(exception); |
| 397 | + |
| 398 | + verify(plugin).onRunErrorCallback(any(), eq(exception)); |
| 399 | + } |
| 400 | + |
373 | 401 | @Test |
374 | 402 | public void onUserMessageCallback_success() { |
375 | 403 | when(plugin.onUserMessageCallback(any(), any())).thenReturn(Maybe.just(pluginContent)); |
|
0 commit comments