Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed default description to empty string instead of null #438

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(), "");
}
}