QueryUtils { public static List<String> getScopesFromExpression(String expression) { return getScopesFromExpression(expression, System.currentTimeMillis()); }  static Long[] getStartAndEndTimesWithMaxInterval(String expression, Long relativeTo); static Long[] getStartAndEndTimesWithMaxInterval(QueryContext context); static QueryContext getQueryContext(String expression, Long relativeTo); static List<String> getScopesFromExpression(String expression); static List<String> getScopesFromExpression(String expression, long relativeTo);  }
@Test public void testGetScopesFromExpression() { List<String> scopes = QueryUtils.getScopesFromExpression("SUM(DOWNSAMPLE(UNION(-1h:argus.core:alerts.scheduled:zimsum:1m-sum,-1h:argus.core:alerts.evaluated:zimsum:1m-sum),#1m-avg#),#union#)"); assertEquals(scopes.size(),1); assertEquals(scopes.get(0),"argus.core"); scopes = QueryUtils.getScopesFromExpression("FILL(#-1d#,#-0d#,#4h#,#0m#,#100#)"); assertEquals(scopes.size(),0); scopes = QueryUtils.getScopesFromExpression("DIVIDE(SUM(-1h:argus.core1:alerts.scheduled:zimsum:1m-sum, -1h:argus.core2:alerts.evaluated:zimsum:1m-sum), -1h:argus.core3:alerts.scheduled:zimsum:1m-sum)"); assertEquals(scopes.size(),3); assertTrue(scopes.contains(new String("argus.core1"))); assertTrue(scopes.contains(new String("argus.core2"))); assertTrue(scopes.contains(new String("argus.core3"))); scopes = QueryUtils.getScopesFromExpression("DIVIDE(SUM(-1h:system.*.NONE:alerts.scheduled:zimsum:1m-sum, -1h:argus.core2:alerts.evaluated:zimsum:1m-sum), -1h:argus.core3:alerts.scheduled:zimsum:1m-sum)"); assertEquals(scopes.size(),3); }