@Test
public void queryAlertsBySeverity() throws Exception {

    int numTenants = 1;
    int numTriggers = 5;
    int numAlerts = 5;
    createTestAlerts(numTenants, numTriggers, numAlerts);
    Set<String> tenantIds = new HashSet<>();
    tenantIds.add("tenant0");
    AlertsCriteria criteria = new AlertsCriteria();
    criteria.setSeverities(Arrays.asList(Severity.LOW));
    // Alerts on stime 2 and 5 are severity LOW
    List<Alert> lowAlerts = alerts.getAlerts(tenantIds, criteria, null);
    assertEquals(5 * 2, lowAlerts.size());
    // Alerts on stime 3 are severity CRITICAL
    criteria.setSeverities(Arrays.asList(Severity.CRITICAL));
    List<Alert> criticalAlerts = alerts.getAlerts(tenantIds, criteria, null);
    assertEquals(5, criticalAlerts.size());
    // Alerts on stime 1 and 4 are severity MEDIUM
    criteria.setSeverities(Arrays.asList(Severity.MEDIUM));
    List<Alert> mediumAlerts = alerts.getAlerts(tenantIds, criteria, null);
    assertEquals(5 * 2, mediumAlerts.size());
    criteria.setSeverities(Arrays.asList(Severity.MEDIUM, Severity.CRITICAL));
    List<Alert> mediumCriticalAlerts = alerts.getAlerts(tenantIds, criteria, null);
    assertEquals(5 * 3, mediumCriticalAlerts.size());
    deleteTestAlerts(numTenants);
}