AlertUtils { public static boolean isPatternPresentInWhiteList(String expression, List<Pattern> scopeRegexPatterns) { for(Pattern regexPattern : scopeRegexPatterns) { if(regexPattern.matcher(expression.toLowerCase()).find()) { return true; } } return false; }  static boolean isPatternPresentInWhiteList(String expression, List<Pattern> scopeRegexPatterns); static Long getMaximumIntervalLength(String queryExpression); static Long[] getStartAndEndTimes(String originalExpression, Long relativeTo); static String getExpressionWithAbsoluteStartAndEndTimeStamps(DefaultAlertService.NotificationContext context);  }
@Test public void isScopePresentInWhiteListTest() { List<Pattern> scopesSet = new ArrayList<Pattern>(Arrays.asList(new Pattern[] {Pattern.compile("argus.core"), Pattern.compile("kafka.broker.*.ajna_local")})); assertTrue(AlertUtils.isPatternPresentInWhiteList("-1d:argus.core:alerts.scheduled:zimsum:15m-sum",scopesSet)); assertTrue(AlertUtils.isPatternPresentInWhiteList("COUNT(-75m:-15m:kafka.broker.CHI.NONE.ajna_local:kafka.server.BrokerTopicMetrics.BytesInPerSec.BytesCount{device=*}:avg:1m-avg)", scopesSet)); assertFalse(AlertUtils.isPatternPresentInWhiteList("COUNT(-75m:-15m:kafka1.broker.CHI.NONE.ajna_local:kafka.server.BrokerTopicMetrics.BytesInPerSec.BytesCount{device=*}:avg:1m-avg)", scopesSet)); }