@Override
  public String buildQuery(
      String metricsAccountName,
      CanaryConfig canaryConfig,
      CanaryMetricConfig canaryMetricConfig,
      CanaryScope canaryScope) {
    WavefrontCanaryMetricSetQueryConfig queryConfig =
        (WavefrontCanaryMetricSetQueryConfig) canaryMetricConfig.getQuery();

    String query = queryConfig.getMetricName();
    if (canaryScope.getScope() != null && !canaryScope.getScope().equals("")) {
      query = query + ", " + canaryScope.getScope();
    }

    query = "ts(" + query + ")";
    if (queryConfig.getAggregate() != null && !queryConfig.getAggregate().equals("")) {
      query = queryConfig.getAggregate() + "(" + query + ")";
    }

    return query;
  }
@Test
  public void testBuildQuery_ScopeAndAggregateProvided() {
    CanaryScope canaryScope = createScope(SCOPE);
    CanaryMetricConfig canaryMetricSetQueryConfig = queryConfig("avg");
    String query =
        wavefrontMetricsService.buildQuery("", null, canaryMetricSetQueryConfig, canaryScope);
    assertThat(query).isEqualTo(AGGREGATE + "(ts(" + METRIC_NAME + ", " + SCOPE + "))");
  }