Skip to content

Commit

Permalink
Add UT for invalid anomaly grade
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Dec 26, 2023
1 parent 2f0ba1e commit 1bde0a6
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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());
Expand Down

0 comments on commit 1bde0a6

Please sign in to comment.