Skip to content

Commit

Permalink
Add more UT for params
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 1bde0a6 commit 5e68383
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

Expand Down Expand Up @@ -65,6 +67,25 @@ public void setup() {
nonEmptyParams = Map.of("detectorId", "foo");
}

@Test
public void testParseParams() throws Exception {
Tool tool = SearchAnomalyResultsTool.Factory.getInstance().create(Collections.emptyMap());
Map<String, String> validParams = new HashMap<String, String>();
validParams.put("detectorId", "foo");
validParams.put("realTime", "true");
validParams.put("anomalyGradethreshold", "-1");
validParams.put("dataStartTime", "1234");
validParams.put("dataEndTime", "5678");
validParams.put("sortOrder", "AsC");
validParams.put("sortString", "foo.bar");
validParams.put("size", "10");
validParams.put("startIndex", "0");

@SuppressWarnings("unchecked")
ActionListener<String> listener = Mockito.mock(ActionListener.class);
assertDoesNotThrow(() -> tool.run(validParams, listener));
}

@Test
public void testRunWithInvalidAnomalyGradeParam() throws Exception {
Tool tool = SearchAnomalyResultsTool.Factory.getInstance().create(Collections.emptyMap());
Expand Down

0 comments on commit 5e68383

Please sign in to comment.