From 36ab02a0fc416afafba7d05da927b9b038db29e0 Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Tue, 12 Dec 2023 14:00:05 +0800 Subject: [PATCH] fix unit tests for abstract retriever tool Signed-off-by: yuye-aws --- .../engine/tools/AbstractRetrieverToolTests.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/AbstractRetrieverToolTests.java b/ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/AbstractRetrieverToolTests.java index f885a4867c..7f5b94f3cd 100644 --- a/ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/AbstractRetrieverToolTests.java +++ b/ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/AbstractRetrieverToolTests.java @@ -125,27 +125,23 @@ public void testRunAsyncWithEmptySearchResponse() { } @Test - @SneakyThrows public void testRunAsyncWithIllegalQueryThenThrowException() { Client client = mock(Client.class); mockedImpl.setClient(client); - assertThrows( - "[input] is null or empty, can not process it.", + Exception exception = assertThrows( IllegalArgumentException.class, () -> mockedImpl.run(Map.of(AbstractRetrieverTool.INPUT_FIELD, ""), null) ); + assertEquals("[input] is null or empty, can not process it.", exception.getMessage()); - assertThrows( - "[input] is null or empty, can not process it.", + exception = assertThrows( IllegalArgumentException.class, () -> mockedImpl.run(Map.of(AbstractRetrieverTool.INPUT_FIELD, " "), null) ); + assertEquals("[input] is null or empty, can not process it.", exception.getMessage()); - assertThrows( - "[input] is null or empty, can not process it.", - IllegalArgumentException.class, - () -> mockedImpl.run(Map.of("test", "hello world"), null) - ); + exception = assertThrows(IllegalArgumentException.class, () -> mockedImpl.run(Map.of("test", "hello world"), null)); + assertEquals("[input] is null or empty, can not process it.", exception.getMessage()); } }