You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2018/12/10 20:02:32 UTC

[incubator-pinot] branch master updated: [TE] Translator - Yaml Alert Config to DetectionAlertConfigDTO (#3595)

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 9fc6e02  [TE] Translator - Yaml Alert Config to DetectionAlertConfigDTO (#3595)
9fc6e02 is described below

commit 9fc6e027e73fe99149b8f6651b2339415ebc6636
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Mon Dec 10 12:02:28 2018 -0800

    [TE] Translator - Yaml Alert Config to DetectionAlertConfigDTO (#3595)
---
 .../registry/DetectionAlertRegistry.java           |   8 +
 .../yaml/YamlDetectionAlertConfigTranslator.java   | 162 ++++++++++++++++++---
 .../thirdeye/detection/yaml/YamlResource.java      |   2 +-
 .../YamlDetectionAlertConfigTranslatorTest.java    |  97 +++++++++++-
 4 files changed, 238 insertions(+), 31 deletions(-)

diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/annotation/registry/DetectionAlertRegistry.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/annotation/registry/DetectionAlertRegistry.java
index 83efc22..f56e336 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/annotation/registry/DetectionAlertRegistry.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/annotation/registry/DetectionAlertRegistry.java
@@ -81,6 +81,14 @@ public class DetectionAlertRegistry {
     }
   }
 
+  public void registerAlertScheme(String type, String className) {
+    ALERT_SCHEME_MAP.put(type, className);
+  }
+
+  public void registerAlertSuppressor(String type, String className) {
+    ALERT_SUPPRESSOR_MAP.put(type, className);
+  }
+
   /**
    * Look up the {@link #ALERT_SCHEME_MAP} for the Alert scheme class name from the type
    */
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslator.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslator.java
index 1caa94a..c47d6a7 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslator.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslator.java
@@ -1,31 +1,59 @@
 package com.linkedin.thirdeye.detection.yaml;
 
+import com.google.common.base.CaseFormat;
 import com.google.common.base.Preconditions;
 import com.linkedin.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+import com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean;
+import com.linkedin.thirdeye.detection.ConfigUtils;
+import com.linkedin.thirdeye.detection.annotation.registry.DetectionAlertRegistry;
 import com.linkedin.thirdeye.detection.annotation.registry.DetectionRegistry;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.commons.collections.MapUtils;
 
 
-
 /**
  * The translator converts the alert yaml config into a detection alert config
- * TODO Refactor this to support alert schemes
  */
 public class YamlDetectionAlertConfigTranslator {
-  private static final String PROP_NAME = "name";
-  private static final String PROP_CRON = "cron";
-  private static final String PROP_APPLICATION = "application";
-  private static final String PROP_TYPE = "type";
-  private static final String PROP_CLASS_NAME = "className";
-  private static final String PROP_DETECTION_CONFIG_ID = "detectionConfigIds";
-  private static final String CRON_SCHEDULE_DEFAULT = "0 21 * * * ? *";
+  static final String PROP_SUBS_GROUP_NAME = "subscriptionGroupName";
+  static final String PROP_CRON = "cron";
+  static final String PROP_ACTIVE = "active";
+  static final String PROP_APPLICATION = "application";
+  static final String PROP_FROM = "fromAddress";
+  static final String PROP_ONLY_FETCH_LEGACY_ANOMALIES = "onlyFetchLegacyAnomalies";
+  static final String PROP_EMAIL_SUBJECT_TYPE = "emailSubjectStyle";
+  static final String PROP_DETECTION_CONFIG_IDS = "detectionConfigIds";
+  static final String PROP_ALERT_SCHEMES = "alertSchemes";
+  static final String PROP_ALERT_SUPPRESSORS = "alertSuppressors";
+  static final String PROP_REFERENCE_LINKS = "referenceLinks";
+  static final String PROP_RECIPIENTS = "recipients";
+
+  static final String PROP_TYPE = "type";
+  static final String PROP_CLASS_NAME = "className";
+  static final String PROP_PARAM = "params";
+
+  static final String PROP_DIMENSION = "dimension";
+  static final String PROP_DIMENSION_RECIPIENTS = "dimensionRecipients";
+  static final String PROP_TIME_WINDOWS = "timeWindows";
+  static final String CRON_SCHEDULE_DEFAULT = "0 0/5 * * * ? *"; // Every 5 min
+
   private static final DetectionRegistry DETECTION_REGISTRY = DetectionRegistry.getInstance();
+  private static final DetectionAlertRegistry DETECTION_ALERT_REGISTRY = DetectionAlertRegistry.getInstance();
+  private static final Set<String> PROPERTY_KEYS = new HashSet<>(
+      Arrays.asList(PROP_DETECTION_CONFIG_IDS, PROP_RECIPIENTS, PROP_DIMENSION, PROP_DIMENSION_RECIPIENTS));
+
+  private static final YamlDetectionAlertConfigTranslator INSTANCE = new YamlDetectionAlertConfigTranslator();
+
+  public static YamlDetectionAlertConfigTranslator getInstance() {
+    return INSTANCE;
+  }
 
   /**
    * generate detection alerter from YAML
@@ -37,7 +65,7 @@ public class YamlDetectionAlertConfigTranslator {
   public DetectionAlertConfigDTO generateDetectionAlertConfig(Map<String, Object> alertYamlConfigs,
       Collection<Long> detectionConfigIds, Map<Long, Long> existingVectorClocks) {
     DetectionAlertConfigDTO alertConfigDTO = new DetectionAlertConfigDTO();
-    Preconditions.checkArgument(alertYamlConfigs.containsKey(PROP_NAME), "Alert property missing: " + PROP_NAME);
+    Preconditions.checkArgument(alertYamlConfigs.containsKey(PROP_SUBS_GROUP_NAME), "Alert property missing: " + PROP_SUBS_GROUP_NAME);
 
     if (existingVectorClocks == null) {
       existingVectorClocks = new HashMap<>();
@@ -49,7 +77,7 @@ public class YamlDetectionAlertConfigTranslator {
     }
     alertConfigDTO.setVectorClocks(existingVectorClocks);
 
-    alertConfigDTO.setName(MapUtils.getString(alertYamlConfigs, PROP_NAME));
+    alertConfigDTO.setName(MapUtils.getString(alertYamlConfigs, PROP_SUBS_GROUP_NAME));
     alertConfigDTO.setCronExpression(MapUtils.getString(alertYamlConfigs, PROP_CRON, CRON_SCHEDULE_DEFAULT));
     alertConfigDTO.setActive(true);
     alertConfigDTO.setApplication(MapUtils.getString(alertYamlConfigs, PROP_APPLICATION));
@@ -58,25 +86,113 @@ public class YamlDetectionAlertConfigTranslator {
   }
 
   private Map<String, Object> buildAlerterProperties(Map<String, Object> alertYamlConfigs, Collection<Long> detectionConfigIds) {
-    Map<String, Object> properties = new HashMap<>();
-    fillInProperties(properties, alertYamlConfigs);
-    properties.put(PROP_DETECTION_CONFIG_ID, detectionConfigIds);
+    Map<String, Object> properties = buildAlerterProperties(alertYamlConfigs);
+    properties.put(PROP_DETECTION_CONFIG_IDS, detectionConfigIds);
     return properties;
   }
 
-  private void fillInProperties(Map<String, Object> properties, Map<String, Object> alertYamlConfigs) {
-    // properties to ignore in the properties
-    Set<String> exclusionProperties = new HashSet();
-    exclusionProperties.addAll(Arrays.asList(PROP_NAME, PROP_CRON, PROP_APPLICATION));
+  private Map<String, Object> buildAlerterProperties(Map<String, Object> alertYamlConfigs) {
+    Map<String, Object> properties = new HashMap<>();
     for (Map.Entry<String, Object> entry : alertYamlConfigs.entrySet()) {
-      if (exclusionProperties.contains(entry.getKey())){
-        continue;
-      }
       if (entry.getKey().equals(PROP_TYPE)) {
         properties.put(PROP_CLASS_NAME, DETECTION_REGISTRY.lookup(MapUtils.getString(alertYamlConfigs, PROP_TYPE)));
       } else {
-        properties.put(entry.getKey(), entry.getValue());
+        if (PROPERTY_KEYS.contains(entry.getKey())) {
+          properties.put(entry.getKey(), entry.getValue());
+        }
+      }
+    }
+
+    return properties;
+  }
+
+  @SuppressWarnings("unchecked")
+  private Map<String,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> alertSuppressorsParsed = new HashMap<>();
+    if (!alertSuppressors.isEmpty()) {
+      for (Map<String, Object> alertSuppressor : alertSuppressors) {
+        Map<String, Object> alertSuppressorsTimeWindow = new HashMap<>();
+        if (alertSuppressor.get(PROP_TYPE) != null) {
+          alertSuppressorsTimeWindow.put(PROP_CLASS_NAME,
+              DETECTION_ALERT_REGISTRY.lookupAlertSuppressors(alertSuppressor.get(PROP_TYPE).toString()));
+        }
+
+        if (alertSuppressor.get(PROP_PARAM) != null) {
+          for (Map.Entry<String, Object> params : ((Map<String, Object>) alertSuppressor.get(PROP_PARAM)).entrySet()) {
+            alertSuppressorsParsed.put(params.getKey(), params.getValue());
+          }
+        }
+
+        String suppressorType =
+            CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, alertSuppressor.get(PROP_TYPE).toString());
+        alertSuppressorsTimeWindow.put(PROP_TIME_WINDOWS, new ArrayList<>(Arrays.asList(alertSuppressorsParsed)));
+        alertSuppressorsHolder.put(suppressorType + "Suppressor", alertSuppressorsTimeWindow);
+      }
+    }
+
+    return alertSuppressorsHolder;
+  }
+
+  @SuppressWarnings("unchecked")
+  private Map<String,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> alertSchemesParsed = new HashMap<>();
+    if (!alertSchemes.isEmpty()) {
+      for (Map<String, Object> alertScheme : alertSchemes) {
+        if (alertScheme.get(PROP_TYPE) != null) {
+          alertSchemesParsed.put(PROP_CLASS_NAME,
+              DETECTION_ALERT_REGISTRY.lookupAlertSchemes(alertScheme.get(PROP_TYPE).toString()));
+        }
+
+        if (alertScheme.get(PROP_PARAM) != null) {
+          for (Map.Entry<String, Object> params : ((Map<String, Object>) alertScheme.get(PROP_PARAM)).entrySet()) {
+            alertSchemesParsed.put(params.getKey(), params.getValue());
+          }
+        }
+
+        alertSchemesHolder.put(alertScheme.get(PROP_TYPE).toString().toLowerCase() + "Scheme", alertSchemesParsed);
       }
     }
+
+    return alertSchemesHolder;
+  }
+
+  /**
+   * Generates the {@link DetectionAlertConfigDTO} from the YAML Alert Map
+   */
+  @SuppressWarnings("unchecked")
+  public DetectionAlertConfigDTO translate(Map<String,Object> yamlAlertConfig) {
+    DetectionAlertConfigDTO alertConfigDTO = new DetectionAlertConfigDTO();
+
+    alertConfigDTO.setName(MapUtils.getString(yamlAlertConfig, PROP_SUBS_GROUP_NAME));
+    alertConfigDTO.setApplication(MapUtils.getString(yamlAlertConfig, PROP_APPLICATION));
+    alertConfigDTO.setFrom(MapUtils.getString(yamlAlertConfig, PROP_FROM));
+
+    alertConfigDTO.setCronExpression(MapUtils.getString(yamlAlertConfig, PROP_CRON, CRON_SCHEDULE_DEFAULT));
+    alertConfigDTO.setActive(MapUtils.getBooleanValue(yamlAlertConfig, PROP_ACTIVE, true));
+    alertConfigDTO.setOnlyFetchLegacyAnomalies(MapUtils.getBooleanValue(yamlAlertConfig, PROP_ONLY_FETCH_LEGACY_ANOMALIES, false));
+    alertConfigDTO.setSubjectType((AlertConfigBean.SubjectType) MapUtils.getObject(yamlAlertConfig, PROP_EMAIL_SUBJECT_TYPE, AlertConfigBean.SubjectType.METRICS));
+
+    MapUtils.getMap(yamlAlertConfig, PROP_REFERENCE_LINKS).put("ThirdEye User Guide", "https://go/thirdeyeuserguide");
+    MapUtils.getMap(yamlAlertConfig, PROP_REFERENCE_LINKS).put("Add Reference Links", "https://go/thirdeyealertreflink");
+    alertConfigDTO.setReferenceLinks(MapUtils.getMap(yamlAlertConfig, PROP_REFERENCE_LINKS));
+
+    alertConfigDTO.setAlertSchemes(buildAlertSchemes(yamlAlertConfig));
+    alertConfigDTO.setAlertSuppressors(buildAlertSuppressors(yamlAlertConfig));
+    alertConfigDTO.setProperties(buildAlerterProperties(yamlAlertConfig));
+
+    // NOTE: The below fields will/should be hidden from the YAML/UI. They will only be updated by the backend pipeline.
+    List<Long> detectionConfigIds = ConfigUtils.getList(yamlAlertConfig.get(PROP_DETECTION_CONFIG_IDS));
+    Map<Long, Long> vectorClocks = new HashMap<>();
+    for (long detectionConfigId : detectionConfigIds) {
+      vectorClocks.put(detectionConfigId, 0L);
+    }
+    alertConfigDTO.setHighWaterMark(0L);
+    alertConfigDTO.setVectorClocks(vectorClocks);
+
+    return alertConfigDTO;
   }
-}
\ No newline at end of file
+}
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
index 56c01b2..5ae893a 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
@@ -69,7 +69,7 @@ public class YamlResource {
     this.detectionConfigDAO = DAORegistry.getInstance().getDetectionConfigManager();
     this.detectionAlertConfigDAO = DAORegistry.getInstance().getDetectionAlertConfigManager();
     this.translatorLoader = new YamlDetectionTranslatorLoader();
-    this.alertConfigTranslator = new YamlDetectionAlertConfigTranslator();
+    this.alertConfigTranslator = YamlDetectionAlertConfigTranslator.getInstance();
     this.metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
     this.datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
     this.eventDAO = DAORegistry.getInstance().getEventDAO();
diff --git a/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslatorTest.java b/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslatorTest.java
index 29d3ead..eac835b 100644
--- a/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslatorTest.java
+++ b/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/yaml/YamlDetectionAlertConfigTranslatorTest.java
@@ -1,16 +1,23 @@
 package com.linkedin.thirdeye.detection.yaml;
 
 import com.linkedin.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+import com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean;
+import com.linkedin.thirdeye.detection.annotation.registry.DetectionAlertRegistry;
 import com.linkedin.thirdeye.detection.annotation.registry.DetectionRegistry;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import static com.linkedin.thirdeye.detection.yaml.YamlDetectionAlertConfigTranslator.*;
+
 
 public class YamlDetectionAlertConfigTranslatorTest {
   private Map<String, Object> alertYamlConfigs;
@@ -21,12 +28,12 @@ public class YamlDetectionAlertConfigTranslatorTest {
     List<Long> ids = Collections.singletonList(1234567L);
     DetectionAlertConfigDTO
         alertConfigDTO = this.translator.generateDetectionAlertConfig(this.alertYamlConfigs, ids, null);
-    Assert.assertEquals(alertConfigDTO.getName(), alertYamlConfigs.get("name"));
+    Assert.assertEquals(alertConfigDTO.getName(), alertYamlConfigs.get(PROP_SUBS_GROUP_NAME));
     Assert.assertEquals(alertConfigDTO.getApplication(), alertYamlConfigs.get("application"));
     Assert.assertEquals(alertConfigDTO.getVectorClocks().get(ids.get(0)), new Long(0L));
-    Assert.assertEquals(alertConfigDTO.getCronExpression(), "0 21 * * * ? *");
+    Assert.assertEquals(alertConfigDTO.getCronExpression(), CRON_SCHEDULE_DEFAULT);
     Map<String, Object> properties = alertConfigDTO.getProperties();
-    Assert.assertEquals(properties.get("detectionConfigIds"), ids);
+    Assert.assertEquals(properties.get(PROP_DETECTION_CONFIG_IDS), ids);
     Assert.assertEquals(properties.get("to"), alertYamlConfigs.get("to"));
   }
 
@@ -38,24 +45,100 @@ public class YamlDetectionAlertConfigTranslatorTest {
     vectorClocks.put(7654321L, 1536173395000L);
     DetectionAlertConfigDTO
         alertConfigDTO = this.translator.generateDetectionAlertConfig(this.alertYamlConfigs, ids, vectorClocks);
-    Assert.assertEquals(alertConfigDTO.getName(), alertYamlConfigs.get("name"));
+    Assert.assertEquals(alertConfigDTO.getName(), alertYamlConfigs.get(PROP_SUBS_GROUP_NAME));
     Assert.assertEquals(alertConfigDTO.getApplication(), alertYamlConfigs.get("application"));
     Assert.assertEquals(alertConfigDTO.getVectorClocks().get(ids.get(0)), vectorClocks.get(ids.get(0)));
     Assert.assertEquals(alertConfigDTO.getVectorClocks().get(7654321L), vectorClocks.get(7654321L));
-    Assert.assertEquals(alertConfigDTO.getCronExpression(), "0 21 * * * ? *");
+    Assert.assertEquals(alertConfigDTO.getCronExpression(), CRON_SCHEDULE_DEFAULT);
 
     Map<String, Object> properties = alertConfigDTO.getProperties();
     Assert.assertEquals(properties.get("detectionConfigIds"), ids);
     Assert.assertEquals(properties.get("to"), alertYamlConfigs.get("to"));
   }
 
+  @Test
+  public void testTranslateAlert() {
+    DetectionAlertRegistry.getInstance().registerAlertScheme("EMAIL", "EmailClass");
+    DetectionAlertRegistry.getInstance().registerAlertSuppressor("TIME_WINDOW", "TimeWindowClass");
+
+    Map<String, Object> alertYamlConfigs = new HashMap<>();
+    alertYamlConfigs.put(PROP_SUBS_GROUP_NAME, "test_group_name");
+    alertYamlConfigs.put(PROP_APPLICATION, "test_application");
+    alertYamlConfigs.put(PROP_FROM, "thirdeye@thirdeye");
+    alertYamlConfigs.put(PROP_CRON, CRON_SCHEDULE_DEFAULT);
+    alertYamlConfigs.put(PROP_ACTIVE, true);
+
+    Map<String, String> refLinks = new HashMap<>();
+    refLinks.put("Test Link", "test_url");
+    alertYamlConfigs.put(PROP_REFERENCE_LINKS, refLinks);
+
+    Set<Long> detectionIds = new HashSet<>(Arrays.asList(1234L, 6789L));
+    alertYamlConfigs.put(PROP_DETECTION_CONFIG_IDS, detectionIds);
+
+    Map<String, Object> alertSchemes = new HashMap<>();
+    alertSchemes.put(PROP_TYPE, "EMAIL");
+    List<Map<String, Object>> alertSchemesHolder = new ArrayList<>();
+    alertSchemesHolder.add(alertSchemes);
+    alertYamlConfigs.put(PROP_ALERT_SCHEMES, alertSchemesHolder);
+
+    Map<String, Object> alertSuppressors = new HashMap<>();
+    alertSuppressors.put(PROP_TYPE, "TIME_WINDOW");
+    Map<String, Object> suppressorParams = new HashMap<>();
+    suppressorParams.put("windowStartTime", 1542888000000L);
+    suppressorParams.put("windowEndTime", 1543215600000L);
+    alertSuppressors.put(PROP_PARAM, suppressorParams);
+    List<Map<String, Object>> alertSuppressorsHolder = new ArrayList<>();
+    alertSuppressorsHolder.add(alertSuppressors);
+    alertYamlConfigs.put(PROP_ALERT_SUPPRESSORS, alertSuppressorsHolder);
+
+    Map<String, List<String>> recipients = new HashMap<>();
+    recipients.put("to", new ArrayList<>(Collections.singleton("userTo@thirdeye.com")));
+    recipients.put("cc", new ArrayList<>(Collections.singleton("userCc@thirdeye.com")));
+    alertYamlConfigs.put(PROP_RECIPIENTS, recipients);
+
+    DetectionAlertConfigDTO alertConfig = YamlDetectionAlertConfigTranslator.getInstance().translate(alertYamlConfigs);
+
+    Assert.assertTrue(alertConfig.isActive());
+    Assert.assertFalse(alertConfig.isOnlyFetchLegacyAnomalies());
+    Assert.assertEquals(alertConfig.getName(), "test_group_name");
+    Assert.assertEquals(alertConfig.getApplication(), "test_application");
+    Assert.assertEquals(alertConfig.getFrom(), "thirdeye@thirdeye");
+    Assert.assertEquals(alertConfig.getCronExpression(), "0 0/5 * * * ? *");
+    Assert.assertEquals(alertConfig.getSubjectType(), AlertConfigBean.SubjectType.METRICS);
+    Assert.assertEquals(alertConfig.getReferenceLinks().size(), 3);
+    Assert.assertEquals(alertConfig.getReferenceLinks().get("Test Link"), "test_url");
+
+    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(alertConfig.getAlertSuppressors().size(), 1);
+    Map<String, Object> timeWindowSuppressor = 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);
+    Assert.assertEquals(timeWindow.get("windowEndTime"), 1543215600000L);
+
+    Assert.assertNotNull(alertConfig.getProperties());
+    Assert.assertEquals(((Set<Long>) alertConfig.getProperties().get(PROP_DETECTION_CONFIG_IDS)).size(), 2);
+
+    Map<String, Object> recipient = (Map<String, Object>) alertConfig.getProperties().get(PROP_RECIPIENTS);
+    Assert.assertEquals(recipient.size(), 2);
+    Assert.assertEquals(((List<String>) recipient.get("to")).get(0), "userTo@thirdeye.com");
+    Assert.assertEquals(((List<String>) recipient.get("cc")).get(0), "userCc@thirdeye.com");
+
+    Assert.assertEquals(((Set<Long>) alertConfig.getProperties().get(PROP_DETECTION_CONFIG_IDS)).size(), 2);
+  }
+
   @BeforeMethod
   public void setUp() {
     DetectionRegistry.registerComponent("testclassname", "TO_ALL_RECIPIENTS");
     this.alertYamlConfigs = new HashMap<>();
-    alertYamlConfigs.put("name", "test_alert");
+    alertYamlConfigs.put(PROP_SUBS_GROUP_NAME, "test_alert");
     alertYamlConfigs.put("type", "TO_ALL_RECIPIEnts");
-    alertYamlConfigs.put("to", Arrays.asList("test1", "test2"));
+    Map<String, Object> recipients = new HashMap<>();
+    recipients.put("to", Arrays.asList("test1", "test2"));
+    alertYamlConfigs.put("recipients", recipients);
     alertYamlConfigs.put("application", "TestApplication");
     this.translator = new YamlDetectionAlertConfigTranslator();
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org