Skip to content

Commit 88b554c

Browse files
committed
fix: test case
Signed-off-by: Pavan Yekbote <pybot@amazon.com>
1 parent 39ec7cb commit 88b554c

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutorTest.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,20 +1264,13 @@ public void test_ExistingConversation_MemoryCreationFailure() throws IOException
12641264
}).when(client).get(Mockito.any(GetRequest.class), Mockito.any(ActionListener.class));
12651265

12661266
// Mock memory factory failure for existing conversation
1267+
RuntimeException memoryException = new RuntimeException("Memory creation failed");
12671268
Mockito.doAnswer(invocation -> {
12681269
ActionListener<ConversationIndexMemory> listener = invocation.getArgument(3);
1269-
listener.onFailure(new RuntimeException("Memory creation failed"));
1270+
listener.onFailure(memoryException);
12701271
return null;
12711272
}).when(mockMemoryFactory).create(Mockito.eq(null), Mockito.eq("existing-memory"), Mockito.any(), Mockito.any());
12721273

1273-
// Mock agent runner to return success (should not be called due to memory failure)
1274-
ModelTensor modelTensor = ModelTensor.builder().name("response").result("test").build();
1275-
Mockito.doAnswer(invocation -> {
1276-
ActionListener<ModelTensor> listener = invocation.getArgument(2);
1277-
listener.onResponse(modelTensor);
1278-
return null;
1279-
}).when(mlAgentRunner).run(Mockito.any(), Mockito.any(), Mockito.any());
1280-
12811274
Map<String, String> params = new HashMap<>();
12821275
params.put(MEMORY_ID, "existing-memory");
12831276
params.put(MLAgentExecutor.PARENT_INTERACTION_ID, "existing-parent");
@@ -1287,10 +1280,9 @@ public void test_ExistingConversation_MemoryCreationFailure() throws IOException
12871280
Mockito.doReturn(mlAgentRunner).when(mlAgentExecutor).getAgentRunner(Mockito.any());
12881281
mlAgentExecutor.execute(agentMLInput, agentActionListener);
12891282

1290-
// Should still proceed without memory (fallback behavior)
1291-
Mockito.verify(agentActionListener).onResponse(objectCaptor.capture());
1292-
ModelTensorOutput output = (ModelTensorOutput) objectCaptor.getValue();
1293-
Assert.assertEquals(1, output.getMlModelOutputs().size());
1283+
Mockito.verify(agentActionListener).onFailure(exceptionCaptor.capture());
1284+
Exception exception = exceptionCaptor.getValue();
1285+
Assert.assertEquals(memoryException, exception);
12941286
}
12951287

12961288
@Test

0 commit comments

Comments
 (0)