Skip to content

Commit

Permalink
changed default description to empty string instead of null
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <[email protected]>
  • Loading branch information
amitgalitz committed Mar 15, 2022
1 parent 651bcae commit 19cafca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/ad/model/AnomalyDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public static AnomalyDetector parse(
TimeValue defaultDetectionWindowDelay
) throws IOException {
String name = null;
String description = null;
String description = "";
String timeField = null;
List<String> indices = new ArrayList<String>();
QueryBuilder filterQuery = QueryBuilders.matchAllQuery();
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/opensearch/ad/model/AnomalyDetectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,16 @@ public void testValidateResultIndex() {
errorMessage = AnomalyDetector.validateResultIndex(CUSTOM_RESULT_INDEX_PREFIX + "abc#");
assertEquals(INVALID_CHAR_IN_RESULT_INDEX_NAME, errorMessage);
}

public void testParseAnomalyDetectorWithNoDescription() throws IOException {
String detectorString = "{\"name\":\"todagtCMkwpcaedpyYUM\",\"time_field\":\"dJRwh\",\"indices\":[\"eIrgWMqAED\"],"
+ "\"feature_attributes\":[{\"feature_id\":\"lxYRN\",\"feature_name\":\"eqSeU\",\"feature_enabled\""
+ ":true,\"aggregation_query\":{\"aa\":{\"value_count\":{\"field\":\"ok\"}}}}],\"detection_interval\":"
+ "{\"period\":{\"interval\":425,\"unit\":\"Minutes\"}},\"window_delay\":{\"period\":{\"interval\":973,"
+ "\"unit\":\"Minutes\"}},\"shingle_size\":4,\"schema_version\":-1203962153,\"ui_metadata\":{\"JbAaV\":{\"feature_id\":"
+ "\"rIFjS\",\"feature_name\":\"QXCmS\",\"feature_enabled\":false,\"aggregation_query\":{\"aa\":"
+ "{\"value_count\":{\"field\":\"ok\"}}}}},\"last_update_time\":1568396089028}";
AnomalyDetector parsedDetector = AnomalyDetector.parse(TestHelpers.parser(detectorString), "id", 1L, null, null);
assertEquals(parsedDetector.getDescription(), "");
}
}

0 comments on commit 19cafca

Please sign in to comment.