diff --git a/src/test/java/org/opensearch/agent/tools/SearchAnomalyResultsToolTests.java b/src/test/java/org/opensearch/agent/tools/SearchAnomalyResultsToolTests.java index 69d56394..0d3cc3d8 100644 --- a/src/test/java/org/opensearch/agent/tools/SearchAnomalyResultsToolTests.java +++ b/src/test/java/org/opensearch/agent/tools/SearchAnomalyResultsToolTests.java @@ -6,6 +6,7 @@ package org.opensearch.agent.tools; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; @@ -64,6 +65,15 @@ public void setup() { nonEmptyParams = Map.of("detectorId", "foo"); } + @Test + public void testRunWithInvalidAnomalyGradeParam() throws Exception { + Tool tool = SearchAnomalyResultsTool.Factory.getInstance().create(Collections.emptyMap()); + + @SuppressWarnings("unchecked") + ActionListener listener = Mockito.mock(ActionListener.class); + assertThrows(NumberFormatException.class, () -> tool.run(Map.of("anomalyGradeThreshold", "foo"), listener)); + } + @Test public void testRunWithNoResults() throws Exception { Tool tool = SearchAnomalyResultsTool.Factory.getInstance().create(Collections.emptyMap());