This is an automated email from the ASF dual-hosted git repository.

akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new fc12121  [TE][notification] Make alertScheme and alertSuppressor 
consistently use Map<String, Object> (#4892)
fc12121 is described below

commit fc12121c3246a4b511227c8741074eb61f753399
Author: Akshay Rai <[email protected]>
AuthorDate: Fri Dec 6 10:00:44 2019 -0800

    [TE][notification] Make alertScheme and alertSuppressor consistently use 
Map<String, Object> (#4892)
---
 .../datalayer/pojo/DetectionAlertConfigBean.java   | 12 ++++----
 .../detection/alert/DetectionAlertTaskFactory.java | 15 ++++++----
 .../alert/StatefulDetectionAlertFilter.java        | 32 ++++++++++------------
 .../filter/DimensionsRecipientAlertFilter.java     |  4 +--
 .../detection/alert/filter/SubscriptionUtils.java  |  4 +--
 .../alert/scheme/DetectionEmailAlerter.java        |  2 +-
 .../alert/scheme/DetectionJiraAlerter.java         |  3 +-
 .../DetectionAlertTimeWindowSuppressor.java        |  2 +-
 .../translator/SubscriptionConfigTranslator.java   | 10 +++----
 .../alert/DetectionAlertTaskFactoryTest.java       |  4 +--
 .../detection/alert/filter/AlertFilterUtils.java   |  2 +-
 .../filter/DimensionsRecipientAlertFilterTest.java |  1 -
 .../filter/PerUserDimensionAlertFilterTest.java    |  1 -
 .../ToAllRecipientsDetectionAlertFilterTest.java   |  1 +
 .../DetectionTimeWindowSuppressorTest.java         |  8 +++---
 .../thirdeye/detection/yaml/YamlResourceTest.java  |  5 ++--
 .../YamlDetectionAlertConfigTranslatorTest.java    |  5 ++--
 17 files changed, 57 insertions(+), 54 deletions(-)

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
index 38bcf94..c655da4 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
@@ -41,8 +41,8 @@ public class DetectionAlertConfigBean extends AbstractBean {
   String application;
   String yaml;
 
-  Map<String, Map<String, Object>> alertSchemes;
-  Map<String, Map<String, Object>> alertSuppressors;
+  Map<String, Object> alertSchemes;
+  Map<String, Object> alertSuppressors;
   AlertConfigBean.SubjectType subjectType = AlertConfigBean.SubjectType.ALERT;
 
   Map<Long, Long> vectorClocks;
@@ -133,19 +133,19 @@ public class DetectionAlertConfigBean extends 
AbstractBean {
     this.subjectType = subjectType;
   }
 
-  public Map<String, Map<String, Object>> getAlertSchemes() {
+  public Map<String, Object> getAlertSchemes() {
     return alertSchemes;
   }
 
-  public void setAlertSchemes(Map<String, Map<String, Object>> alertSchemes) {
+  public void setAlertSchemes(Map<String, Object> alertSchemes) {
     this.alertSchemes = alertSchemes;
   }
 
-  public Map<String, Map<String, Object>> getAlertSuppressors() {
+  public Map<String, Object> getAlertSuppressors() {
     return alertSuppressors;
   }
 
-  public void setAlertSuppressors(Map<String, Map<String, Object>> 
alertSuppressors) {
+  public void setAlertSuppressors(Map<String, Object> alertSuppressors) {
     this.alertSuppressors = alertSuppressors;
   }
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactory.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactory.java
index ce5c17b..676aae4 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactory.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactory.java
@@ -34,6 +34,7 @@ import 
org.apache.pinot.thirdeye.datasource.loader.AggregationLoader;
 import org.apache.pinot.thirdeye.datasource.loader.DefaultAggregationLoader;
 import org.apache.pinot.thirdeye.datasource.loader.DefaultTimeSeriesLoader;
 import org.apache.pinot.thirdeye.datasource.loader.TimeSeriesLoader;
+import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import org.apache.pinot.thirdeye.detection.DataProvider;
 import org.apache.pinot.thirdeye.detection.DefaultDataProvider;
 import org.apache.pinot.thirdeye.detection.DetectionPipelineLoader;
@@ -88,7 +89,7 @@ public class DetectionAlertTaskFactory {
   public Set<DetectionAlertScheme> loadAlertSchemes(DetectionAlertConfigDTO 
alertConfig,
       ThirdEyeAnomalyConfiguration thirdeyeConfig, DetectionAlertFilterResult 
result) throws Exception {
     Preconditions.checkNotNull(alertConfig);
-    Map<String, Map<String, Object>> alertSchemes = 
alertConfig.getAlertSchemes();
+    Map<String, Object> alertSchemes = alertConfig.getAlertSchemes();
     if (alertSchemes == null || alertSchemes.isEmpty()) {
       Map<String, Object> emailScheme = new HashMap<>();
       emailScheme.put(PROP_CLASS_NAME, DEFAULT_ALERT_SCHEME);
@@ -98,8 +99,9 @@ public class DetectionAlertTaskFactory {
     for (String alertSchemeType : alertSchemes.keySet()) {
       LOG.debug("Loading Alert Scheme : {}", alertSchemeType);
       Preconditions.checkNotNull(alertSchemes.get(alertSchemeType));
-      
Preconditions.checkNotNull(alertSchemes.get(alertSchemeType).get(PROP_CLASS_NAME));
-      Constructor<?> constructor = 
Class.forName(alertSchemes.get(alertSchemeType).get(PROP_CLASS_NAME).toString().trim())
+      
Preconditions.checkNotNull(ConfigUtils.getMap(alertSchemes.get(alertSchemeType)).get(PROP_CLASS_NAME));
+      Constructor<?> constructor = 
Class.forName(ConfigUtils.getMap(alertSchemes.get(alertSchemeType))
+          .get(PROP_CLASS_NAME).toString().trim())
           .getConstructor(DetectionAlertConfigDTO.class, 
ThirdEyeAnomalyConfiguration.class, DetectionAlertFilterResult.class);
       detectionAlertSchemeSet.add((DetectionAlertScheme) 
constructor.newInstance(alertConfig, thirdeyeConfig, result));
     }
@@ -109,7 +111,7 @@ public class DetectionAlertTaskFactory {
   public Set<DetectionAlertSuppressor> 
loadAlertSuppressors(DetectionAlertConfigDTO alertConfig) throws Exception {
     Preconditions.checkNotNull(alertConfig);
     Set<DetectionAlertSuppressor> detectionAlertSuppressors = new HashSet<>();
-    Map<String, Map<String, Object>> alertSuppressors = 
alertConfig.getAlertSuppressors();
+    Map<String, Object> alertSuppressors = alertConfig.getAlertSuppressors();
     if (alertSuppressors == null || alertSuppressors.isEmpty()) {
       return detectionAlertSuppressors;
     }
@@ -117,8 +119,9 @@ public class DetectionAlertTaskFactory {
     for (String alertSuppressor : alertSuppressors.keySet()) {
       LOG.debug("Loading Alert Suppressor : {}", alertSuppressor);
       Preconditions.checkNotNull(alertSuppressors.get(alertSuppressor));
-      
Preconditions.checkNotNull(alertSuppressors.get(alertSuppressor).get(PROP_CLASS_NAME));
-      Constructor<?> constructor = 
Class.forName(alertSuppressors.get(alertSuppressor).get(PROP_CLASS_NAME).toString().trim())
+      
Preconditions.checkNotNull(ConfigUtils.getMap(alertSuppressors.get(alertSuppressor)).get(PROP_CLASS_NAME));
+      Constructor<?> constructor = 
Class.forName(ConfigUtils.getMap(alertSuppressors.get(alertSuppressor))
+          .get(PROP_CLASS_NAME).toString().trim())
           .getConstructor(DetectionAlertConfigDTO.class);
       detectionAlertSuppressors.add((DetectionAlertSuppressor) 
constructor.newInstance(alertConfig));
     }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
index 41b3df4..17c0364 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
@@ -114,27 +114,25 @@ public abstract class StatefulDetectionAlertFilter 
extends DetectionAlertFilter
     return filteredRecipients;
   }
 
-  protected Map<String, Map<String, Object>> 
generateNotificationSchemeProps(DetectionAlertConfigDTO config,
+  /**
+   * Extracts the alert schemes from config and also merges (overrides)
+   * recipients explicitly defined outside the scope of alert schemes.
+   */
+  protected Map<String, Object> 
generateNotificationSchemeProps(DetectionAlertConfigDTO config,
       Set<String> to, Set<String> cc, Set<String> bcc) {
-    Map<String, Map<String, Object>> notificationSchemeProps = new HashMap<>();
+    Map<String, Object> notificationSchemeProps = new HashMap<>();
 
-    if (config.getAlertSchemes() == null) {
-      Map<String, Map<String, Object>> alertSchemes = new HashMap<>();
-      alertSchemes.put(PROP_EMAIL_SCHEME, new HashMap<>());
-      config.setAlertSchemes(alertSchemes);
+    if (config.getAlertSchemes() != null) {
+      notificationSchemeProps.putAll(config.getAlertSchemes());
     }
 
-    for (Map.Entry<String, Map<String, Object>> schemeProps : 
config.getAlertSchemes().entrySet()) {
-      notificationSchemeProps.put(schemeProps.getKey(), new 
HashMap<>(schemeProps.getValue()));
-    }
-
-    if (notificationSchemeProps.get(PROP_EMAIL_SCHEME) != null) {
-      Map<String, Set<String>> recipients = new HashMap<>();
-      recipients.put(PROP_TO, cleanupRecipients(to));
-      recipients.put(PROP_CC, cleanupRecipients(cc));
-      recipients.put(PROP_BCC, cleanupRecipients(bcc));
-      ((Map<String, Object>) 
notificationSchemeProps.get(PROP_EMAIL_SCHEME)).put(PROP_RECIPIENTS, 
recipients);
-    }
+    Map<String, Object> recipients = new HashMap<>();
+    recipients.put(PROP_TO, cleanupRecipients(to));
+    recipients.put(PROP_CC, cleanupRecipients(cc));
+    recipients.put(PROP_BCC, cleanupRecipients(bcc));
+    Map<String, Object> recipientsHolder = new HashMap<>();
+    recipientsHolder.put(PROP_RECIPIENTS, recipients);
+    notificationSchemeProps.put(PROP_EMAIL_SCHEME, recipientsHolder);
 
     return notificationSchemeProps;
   }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
index 4f7c70d..2200465 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
@@ -98,8 +98,8 @@ public class DimensionsRecipientAlertFilter extends 
StatefulDetectionAlertFilter
       Multimap<String, String> dimensionFilters = 
ConfigUtils.getMultimap(dimensionRecipient.get(PROP_DIMENSION));
       Set<MergedAnomalyResultDTO> notifyAnomalies = new HashSet<>();
       for (MergedAnomalyResultDTO anomaly : anomalies) {
-        Multimap<String, String> anamolousDims = 
MetricEntity.fromURN(anomaly.getMetricUrn()).getFilters();
-        if (anamolousDims.entries().containsAll(dimensionFilters.entries())) {
+        Multimap<String, String> anomalousDims = 
MetricEntity.fromURN(anomaly.getMetricUrn()).getFilters();
+        if (anomalousDims.entries().containsAll(dimensionFilters.entries())) {
           notifyAnomalies.add(anomaly);
         }
       }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
index f513e89..e283b15 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
@@ -25,7 +25,7 @@ import 
org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 
 public class SubscriptionUtils {
 
-  public static DetectionAlertConfigDTO 
makeChildSubscriptionConfig(Map<String, Map<String, Object>> alertSchemes) {
+  public static DetectionAlertConfigDTO 
makeChildSubscriptionConfig(Map<String, Object> alertSchemes) {
     return SubscriptionUtils.makeChildSubscriptionConfig(new 
DetectionAlertConfigDTO(), alertSchemes, null);
   }
 
@@ -36,7 +36,7 @@ public class SubscriptionUtils {
    */
   public static DetectionAlertConfigDTO makeChildSubscriptionConfig(
       DetectionAlertConfigDTO parentConfig,
-      Map<String, Map<String, Object>> alertSchemes,
+      Map<String, Object> alertSchemes,
       Map<String, String> refLinks) {
     DetectionAlertConfigDTO subsConfig = new DetectionAlertConfigDTO();
     subsConfig.setId(parentConfig.getId());
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
index ffb1e45..f9ec55c 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
@@ -199,7 +199,7 @@ public class DetectionEmailAlerter extends 
DetectionAlertScheme {
         anomalyResultListOfGroup.sort(COMPARATOR_DESC);
 
         Properties emailClientConfigs = new Properties();
-        
emailClientConfigs.putAll(subsConfig.getAlertSchemes().get(PROP_EMAIL_SCHEME));
+        
emailClientConfigs.putAll(ConfigUtils.getMap(subsConfig.getAlertSchemes().get(PROP_EMAIL_SCHEME)));
 
         if (emailClientConfigs.get(PROP_RECIPIENTS) != null) {
           Map<String, Object> emailRecipients = 
ConfigUtils.getMap(emailClientConfigs.get(PROP_RECIPIENTS));
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
index d561ac3..b2b15ba 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
@@ -32,6 +32,7 @@ import 
org.apache.pinot.thirdeye.anomaly.ThirdEyeAnomalyConfiguration;
 import org.apache.pinot.thirdeye.anomalydetection.context.AnomalyResult;
 import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 import org.apache.pinot.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
+import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 import org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterResult;
 import org.apache.pinot.thirdeye.detection.annotation.AlertScheme;
@@ -124,7 +125,7 @@ public class DetectionJiraAlerter extends 
DetectionAlertScheme {
     }
 
     Properties jiraClientConfig = new Properties();
-    
jiraClientConfig.putAll(subsetSubsConfig.getAlertSchemes().get(PROP_JIRA_SCHEME));
+    
jiraClientConfig.putAll(ConfigUtils.getMap(subsetSubsConfig.getAlertSchemes().get(PROP_JIRA_SCHEME)));
 
     List<AnomalyResult> anomalyResultListOfGroup = new ArrayList<>(anomalies);
     anomalyResultListOfGroup.sort(COMPARATOR_DESC);
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionAlertTimeWindowSuppressor.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionAlertTimeWindowSuppressor.java
index 402b04a..4d273e7 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionAlertTimeWindowSuppressor.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionAlertTimeWindowSuppressor.java
@@ -111,7 +111,7 @@ public class DetectionAlertTimeWindowSuppressor extends 
DetectionAlertSuppressor
     MergedAnomalyResultManager anomalyMergedResultDAO = 
DAORegistry.getInstance().getMergedAnomalyResultDAO();
 
     List<Map<String, Object>> suppressWindowPropsList
-        = 
ConfigUtils.getList(config.getAlertSuppressors().get(TIME_WINDOW_SUPPRESSOR_KEY).get(TIME_WINDOWS_KEY));
+        = 
ConfigUtils.getList(ConfigUtils.getMap(config.getAlertSuppressors().get(TIME_WINDOW_SUPPRESSOR_KEY)).get(TIME_WINDOWS_KEY));
 
     while (anomaliesIt.hasNext()) {
       MergedAnomalyResultDTO anomaly = anomaliesIt.next();
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/SubscriptionConfigTranslator.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/SubscriptionConfigTranslator.java
index 5dac69b..e2264f3 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/SubscriptionConfigTranslator.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/SubscriptionConfigTranslator.java
@@ -57,8 +57,8 @@ public class SubscriptionConfigTranslator extends 
ConfigTranslator<DetectionAler
   public static final String PROP_DETECTION_NAMES = "subscribedDetections";
   public static final String PROP_TYPE = "type";
   public static final String PROP_CLASS_NAME = "className";
+  public static final String PROP_PARAM = "params";
 
-  static final String PROP_PARAM = "params";
   static final String PROP_ALERT_SUPPRESSORS = "alertSuppressors";
   static final String PROP_REFERENCE_LINKS = "referenceLinks";
   static final String PROP_TIME_WINDOWS = "timeWindows";
@@ -108,9 +108,9 @@ public class SubscriptionConfigTranslator extends 
ConfigTranslator<DetectionAler
   }
 
   @SuppressWarnings("unchecked")
-  private Map<String,Map<String,Object>> 
buildAlertSuppressors(Map<String,Object> yamlAlertConfig) {
+  private Map<String, Object> buildAlertSuppressors(Map<String, Object> 
yamlAlertConfig) {
     List<Map<String, Object>> alertSuppressors = 
ConfigUtils.getList(yamlAlertConfig.get(PROP_ALERT_SUPPRESSORS));
-    Map<String, Map<String, Object>> alertSuppressorsHolder = new HashMap<>();
+    Map<String, Object> alertSuppressorsHolder = new HashMap<>();
     Map<String, Object> alertSuppressorsParsed = new HashMap<>();
     if (!alertSuppressors.isEmpty()) {
       for (Map<String, Object> alertSuppressor : alertSuppressors) {
@@ -137,9 +137,9 @@ public class SubscriptionConfigTranslator extends 
ConfigTranslator<DetectionAler
   }
 
   @SuppressWarnings("unchecked")
-  private Map<String,Map<String,Object>>  buildAlertSchemes(Map<String,Object> 
yamlAlertConfig) {
+  private Map<String, Object>  buildAlertSchemes(Map<String,Object> 
yamlAlertConfig) {
     List<Map<String, Object>> alertSchemes = 
ConfigUtils.getList(yamlAlertConfig.get(PROP_ALERT_SCHEMES));
-    Map<String, Map<String, Object>> alertSchemesHolder = new HashMap<>();
+    Map<String, Object> alertSchemesHolder = new HashMap<>();
     if (!alertSchemes.isEmpty()) {
       for (Map<String, Object> alertScheme : alertSchemes) {
         Map<String, Object> alertSchemesParsed = new HashMap<>();
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactoryTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactoryTest.java
index 6bbb58f..91846b7 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactoryTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertTaskFactoryTest.java
@@ -29,7 +29,7 @@ public class DetectionAlertTaskFactoryTest {
   private DAOTestBase testDAOProvider;
   private DetectionAlertConfigDTO alertConfigDTO;
   private DetectionAlertConfigManager alertConfigDAO;
-  private Map<String, Map<String, Object>> alerters;
+  private Map<String, Object> alerters;
 
   @BeforeMethod
   public void beforeClass() throws Exception {
@@ -53,7 +53,7 @@ public class DetectionAlertTaskFactoryTest {
     testDAOProvider.cleanup();
   }
 
-  private DetectionAlertConfigDTO createAlertConfig(Map<String, Map<String, 
Object>> schemes, String filter) {
+  private DetectionAlertConfigDTO createAlertConfig(Map<String, Object> 
schemes, String filter) {
     Map<String, Object> properties = new HashMap<>();
     properties.put("className", filter);
     properties.put("detectionConfigIds", Collections.singletonList(1000));
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
index 1282b94..9ea3533 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
@@ -51,7 +51,7 @@ public class AlertFilterUtils {
 
   static DetectionAlertFilterNotification 
makeEmailNotifications(DetectionAlertConfigDTO config,
       Set<String> toRecipients, Set<String> ccRecipients, Set<String> 
bccRecipients) {
-    Map<String, Map<String, Object>> alertProps = new HashMap<>();
+    Map<String, Object> alertProps = new HashMap<>();
 
     Map<String, Set<String>> recipients = new HashMap<>();
     recipients.put(PROP_TO, new HashSet<>(toRecipients));
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
index fa0d111..ebf07ad 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
@@ -42,7 +42,6 @@ import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilter;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 import org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterResult;
 import 
org.apache.pinot.thirdeye.detection.annotation.registry.DetectionAlertRegistry;
-import org.apache.pinot.thirdeye.detection.yaml.YamlResource;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilterTest.java
index 3c15dc8..740d588 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilterTest.java
@@ -51,7 +51,6 @@ public class PerUserDimensionAlertFilterTest {
   private static final String PROP_DIMENSION = "dimension";
   private static final String PROP_DIMENSION_VALUE = "key";
   private static final String PROP_DIMENSION_TO = "dimensionRecipients";
-  private static final Map<String, Object> ALERT_PROPS = new HashMap<>();
   private static final Map<String, Collection<String>> PROP_DIMENSION_TO_VALUE 
= new HashMap<>();
   static {
     PROP_DIMENSION_TO_VALUE.put("value", PROP_TO_FOR_VALUE);
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilterTest.java
index 3fccb91..9f026e7 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilterTest.java
@@ -169,6 +169,7 @@ public class ToAllRecipientsDetectionAlertFilterTest {
     DetectionAlertFilterResult result = this.alertFilter.run();
 
     DetectionAlertFilterNotification notification = 
AlertFilterUtils.makeEmailNotifications(PROP_TO_VALUE, PROP_CC_VALUE, 
PROP_BCC_VALUE);
+    Assert.assertTrue(result.getResult().containsKey(notification));
     Assert.assertEquals(result.getResult().get(notification).size(), 1);
     
Assert.assertTrue(result.getResult().get(notification).contains(existingFuture));
   }
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
index 025dc62..591c86b 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
@@ -63,7 +63,7 @@ public class DetectionTimeWindowSuppressorTest {
     Map<String, Object> params = new HashMap<>();
     params.put(TIME_WINDOWS_KEY, suppressWindowList);
 
-    Map<String, Map<String, Object>> alertSuppressors = new HashMap<>();
+    Map<String, Object> alertSuppressors = new HashMap<>();
     alertSuppressors.put(TIME_WINDOW_SUPPRESSOR_KEY, params);
     config.setAlertSuppressors(alertSuppressors);
   }
@@ -122,7 +122,7 @@ public class DetectionTimeWindowSuppressorTest {
     recipients.put("to", Collections.singleton("test@test"));
 
     DetectionAlertFilterResult result = new DetectionAlertFilterResult();
-    Map<String, Map<String, Object>> alertProps = new HashMap<>();
+    Map<String, Object> alertProps = new HashMap<>();
     alertProps.put("emailScheme", recipients);
     DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(alertProps);
     result.addMapping(new DetectionAlertFilterNotification(subsConfig), 
anomalies);
@@ -149,7 +149,7 @@ public class DetectionTimeWindowSuppressorTest {
     Map<String, Object> params = new HashMap<>();
     params.put(TIME_WINDOWS_KEY, suppressWindowList);
 
-    Map<String, Map<String, Object>> alertSuppressors = new HashMap<>();
+    Map<String, Object> alertSuppressors = new HashMap<>();
     alertSuppressors.put(TIME_WINDOW_SUPPRESSOR_KEY, params);
     config.setAlertSuppressors(alertSuppressors);
 
@@ -157,7 +157,7 @@ public class DetectionTimeWindowSuppressorTest {
     recipients.put("to", Collections.singleton("test@test"));
 
     DetectionAlertFilterResult result = new DetectionAlertFilterResult();
-    Map<String, Map<String, Object>> alertProps = new HashMap<>();
+    Map<String, Object> alertProps = new HashMap<>();
     alertProps.put("emailScheme", recipients);
     DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(alertProps);
     result.addMapping(new DetectionAlertFilterNotification(subsConfig), 
anomalies);
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/YamlResourceTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/YamlResourceTest.java
index 0352b2e..bf35a41 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/YamlResourceTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/YamlResourceTest.java
@@ -11,6 +11,7 @@ import 
org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 import org.apache.pinot.thirdeye.datalayer.dto.DetectionConfigDTO;
 import org.apache.pinot.thirdeye.datalayer.dto.MetricConfigDTO;
 import org.apache.pinot.thirdeye.datasource.DAORegistry;
+import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.annotation.registry.DetectionAlertRegistry;
 import java.io.IOException;
 import org.apache.commons.io.IOUtils;
@@ -241,8 +242,8 @@ public class YamlResourceTest {
       Assert.assertEquals(alertDTO.getName(), "Subscription Group Name");
       Assert.assertEquals(alertDTO.getApplication(), "test_application");
       Assert.assertNotNull(alertDTO.getAlertSchemes().get("emailScheme"));
-      
Assert.assertEquals(alertDTO.getAlertSchemes().get("emailScheme").get("template"),
 "ENTITY_GROUPBY_REPORT");
-      
Assert.assertEquals(alertDTO.getAlertSchemes().get("emailScheme").get("subject"),
 "METRICS");
+      
Assert.assertEquals(ConfigUtils.getMap(alertDTO.getAlertSchemes().get("emailScheme")).get("template"),
 "ENTITY_GROUPBY_REPORT");
+      
Assert.assertEquals(ConfigUtils.getMap(alertDTO.getAlertSchemes().get("emailScheme")).get("subject"),
 "METRICS");
 
       // Verify if the vector clock is updated with the updated detection
       Assert.assertEquals(alertDTO.getVectorClocks().keySet().size(), 1);
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/translator/YamlDetectionAlertConfigTranslatorTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/translator/YamlDetectionAlertConfigTranslatorTest.java
index b8acc01..3442cc7 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/translator/YamlDetectionAlertConfigTranslatorTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/yaml/translator/YamlDetectionAlertConfigTranslatorTest.java
@@ -87,10 +87,11 @@ public class YamlDetectionAlertConfigTranslatorTest {
 
     Assert.assertEquals(alertConfig.getAlertSchemes().size(), 1);
     Assert.assertNotNull(alertConfig.getAlertSchemes().get("emailScheme"));
-    
Assert.assertEquals(alertConfig.getAlertSchemes().get("emailScheme").get(PROP_CLASS_NAME),
 "EmailClass");
+    
Assert.assertEquals(ConfigUtils.getMap(alertConfig.getAlertSchemes().get("emailScheme")).get(PROP_CLASS_NAME),
+        "EmailClass");
 
     Assert.assertEquals(alertConfig.getAlertSuppressors().size(), 1);
-    Map<String, Object> timeWindowSuppressor = 
alertConfig.getAlertSuppressors().get("timeWindowSuppressor");
+    Map<String, Object> timeWindowSuppressor = 
ConfigUtils.getMap(alertConfig.getAlertSuppressors().get("timeWindowSuppressor"));
     Assert.assertEquals(timeWindowSuppressor.get(PROP_CLASS_NAME), 
"TimeWindowClass");
     Map<String, Object> timeWindow = ((ArrayList<Map<String, Object>>) 
timeWindowSuppressor.get(PROP_TIME_WINDOWS)).get(0);
     Assert.assertEquals(timeWindow.get("windowStartTime"), 1542888000000L);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to