@Test public void testParseNumeratorDenominatorId() { SummaryResource.MatchedRatioMetricsResult matchedRatioMetricsResult = SummaryResource.parseNumeratorDenominatorId(""); Assert.assertFalse(matchedRatioMetricsResult.hasFound); matchedRatioMetricsResult = SummaryResource.parseNumeratorDenominatorId(null); Assert.assertFalse(matchedRatioMetricsResult.hasFound); matchedRatioMetricsResult = SummaryResource.parseNumeratorDenominatorId("id123/id456"); Assert.assertTrue(matchedRatioMetricsResult.hasFound); Assert.assertEquals(matchedRatioMetricsResult.numeratorId, 123); Assert.assertEquals(matchedRatioMetricsResult.denominatorId, 456); }
static MatchedRatioMetricsResult parseNumeratorDenominatorId(String derivedMetricExpression) { if (Strings.isNullOrEmpty(derivedMetricExpression)) { return new MatchedRatioMetricsResult(false, -1, -1); } Pattern pattern = Pattern.compile(SIMPLE_RATIO_METRIC_EXPRESSION_ID_PARSER); Matcher matcher = pattern.matcher(derivedMetricExpression); if (matcher.find()) { long numeratorId = Long.valueOf(matcher.group(NUMERATOR_GROUP_NAME)); long denominatorId = Long.valueOf(matcher.group(DENOMINATOR_GROUP_NAME)); return new MatchedRatioMetricsResult(true, numeratorId, denominatorId); } else { return new MatchedRatioMetricsResult(false, -1, -1); } }
SummaryResource { static MatchedRatioMetricsResult parseNumeratorDenominatorId(String derivedMetricExpression) { if (Strings.isNullOrEmpty(derivedMetricExpression)) { return new MatchedRatioMetricsResult(false, -1, -1); } Pattern pattern = Pattern.compile(SIMPLE_RATIO_METRIC_EXPRESSION_ID_PARSER); Matcher matcher = pattern.matcher(derivedMetricExpression); if (matcher.find()) { long numeratorId = Long.valueOf(matcher.group(NUMERATOR_GROUP_NAME)); long denominatorId = Long.valueOf(matcher.group(DENOMINATOR_GROUP_NAME)); return new MatchedRatioMetricsResult(true, numeratorId, denominatorId); } else { return new MatchedRatioMetricsResult(false, -1, -1); } } }
SummaryResource { static MatchedRatioMetricsResult parseNumeratorDenominatorId(String derivedMetricExpression) { if (Strings.isNullOrEmpty(derivedMetricExpression)) { return new MatchedRatioMetricsResult(false, -1, -1); } Pattern pattern = Pattern.compile(SIMPLE_RATIO_METRIC_EXPRESSION_ID_PARSER); Matcher matcher = pattern.matcher(derivedMetricExpression); if (matcher.find()) { long numeratorId = Long.valueOf(matcher.group(NUMERATOR_GROUP_NAME)); long denominatorId = Long.valueOf(matcher.group(DENOMINATOR_GROUP_NAME)); return new MatchedRatioMetricsResult(true, numeratorId, denominatorId); } else { return new MatchedRatioMetricsResult(false, -1, -1); } }  }
SummaryResource { static MatchedRatioMetricsResult parseNumeratorDenominatorId(String derivedMetricExpression) { if (Strings.isNullOrEmpty(derivedMetricExpression)) { return new MatchedRatioMetricsResult(false, -1, -1); } Pattern pattern = Pattern.compile(SIMPLE_RATIO_METRIC_EXPRESSION_ID_PARSER); Matcher matcher = pattern.matcher(derivedMetricExpression); if (matcher.find()) { long numeratorId = Long.valueOf(matcher.group(NUMERATOR_GROUP_NAME)); long denominatorId = Long.valueOf(matcher.group(DENOMINATOR_GROUP_NAME)); return new MatchedRatioMetricsResult(true, numeratorId, denominatorId); } else { return new MatchedRatioMetricsResult(false, -1, -1); } }  @GET @Path("autoDimensionOrder/v2") @Produces(MediaType.APPLICATION_JSON) Map<String, Object> getDataCubeSummary(
      @QueryParam(METRIC_URN) String metricUrn,
      @QueryParam("dataset") String dataset,
      @QueryParam("metric") String metric,
      @QueryParam(CURRENT_START) long currentStartInclusive,
      @QueryParam(CURRENT_END) long currentEndExclusive,
      @QueryParam(BASELINE_START) long baselineStartInclusive,
      @QueryParam(BASELINE_END) long baselineEndExclusive,
      @QueryParam("dimensions") String groupByDimensions,
      @QueryParam("filters") String filterJsonPayload,
      @QueryParam(CUBE_SUMMARY_SIZE) int summarySize,
      @QueryParam(CUBE_DEPTH) @DefaultValue(DEFAULT_DEPTH) int depth,
      @QueryParam(CUBE_DIM_HIERARCHIES) @DefaultValue(DEFAULT_HIERARCHIES) String hierarchiesPayload,
      @QueryParam(CUBE_ONE_SIDE_ERROR) @DefaultValue(DEFAULT_ONE_SIDE_ERROR) boolean doOneSideError,
      @QueryParam(CUBE_EXCLUDED_DIMENSIONS) @DefaultValue(DEFAULT_EXCLUDED_DIMENSIONS) String excludedDimensions,
      @QueryParam(TIME_ZONE) @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone); @GET @Path("autoDimensionOrder") @Produces(MediaType.APPLICATION_JSON) String buildSummary(
      @QueryParam(METRIC_URN) String metricUrn,
      @QueryParam("dataset") String dataset,
      @QueryParam("metric") String metric,
      @QueryParam(CURRENT_START) long currentStartInclusive,
      @QueryParam(CURRENT_END) long currentEndExclusive,
      @QueryParam(BASELINE_START) long baselineStartInclusive,
      @QueryParam(BASELINE_END) long baselineEndExclusive,
      @QueryParam("dimensions") String groupByDimensions,
      @QueryParam("filters") String filterJsonPayload,
      @QueryParam(CUBE_SUMMARY_SIZE) int summarySize,
      @QueryParam(CUBE_DEPTH) @DefaultValue(DEFAULT_DEPTH) int depth,
      @QueryParam(CUBE_DIM_HIERARCHIES) @DefaultValue(DEFAULT_HIERARCHIES) String hierarchiesPayload,
      @QueryParam(CUBE_ONE_SIDE_ERROR) @DefaultValue(DEFAULT_ONE_SIDE_ERROR) boolean doOneSideError,
      @QueryParam(CUBE_EXCLUDED_DIMENSIONS) @DefaultValue(DEFAULT_EXCLUDED_DIMENSIONS) String excludedDimensions,
      @QueryParam(TIME_ZONE) @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone); @GET @Path("manualDimensionOrder") @Produces(MediaType.APPLICATION_JSON) String buildSummaryManualDimensionOrder(
      @QueryParam(METRIC_URN) String metricUrn,
      @QueryParam("dataset") String dataset,
      @QueryParam("metric") String metric,
      @QueryParam(CURRENT_START) long currentStartInclusive,
      @QueryParam(CURRENT_END) long currentEndExclusive,
      @QueryParam(BASELINE_START) long baselineStartInclusive,
      @QueryParam(BASELINE_END) long baselineEndExclusive,
      @QueryParam("dimensions") String groupByDimensions,
      @QueryParam("filters") String filterJsonPayload,
      @QueryParam(CUBE_SUMMARY_SIZE) int summarySize,
      @QueryParam(CUBE_ONE_SIDE_ERROR) @DefaultValue(DEFAULT_ONE_SIDE_ERROR) boolean doOneSideError,
      @QueryParam(TIME_ZONE) @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone); }
SummaryResource { static MatchedRatioMetricsResult parseNumeratorDenominatorId(String derivedMetricExpression) { if (Strings.isNullOrEmpty(derivedMetricExpression)) { return new MatchedRatioMetricsResult(false, -1, -1); } Pattern pattern = Pattern.compile(SIMPLE_RATIO_METRIC_EXPRESSION_ID_PARSER); Matcher matcher = pattern.matcher(derivedMetricExpression); if (matcher.find()) { long numeratorId = Long.valueOf(matcher.group(NUMERATOR_GROUP_NAME)); long denominatorId = Long.valueOf(matcher.group(DENOMINATOR_GROUP_NAME)); return new MatchedRatioMetricsResult(true, numeratorId, denominatorId); } else { return new MatchedRatioMetricsResult(false, -1, -1); } }  @GET @Path("autoDimensionOrder/v2") @Produces(MediaType.APPLICATION_JSON) Map<String, Object> getDataCubeSummary(
      @QueryParam(METRIC_URN) String metricUrn,
      @QueryParam("dataset") String dataset,
      @QueryParam("metric") String metric,
      @QueryParam(CURRENT_START) long currentStartInclusive,
      @QueryParam(CURRENT_END) long currentEndExclusive,
      @QueryParam(BASELINE_START) long baselineStartInclusive,
      @QueryParam(BASELINE_END) long baselineEndExclusive,
      @QueryParam("dimensions") String groupByDimensions,
      @QueryParam("filters") String filterJsonPayload,
      @QueryParam(CUBE_SUMMARY_SIZE) int summarySize,
      @QueryParam(CUBE_DEPTH) @DefaultValue(DEFAULT_DEPTH) int depth,
      @QueryParam(CUBE_DIM_HIERARCHIES) @DefaultValue(DEFAULT_HIERARCHIES) String hierarchiesPayload,
      @QueryParam(CUBE_ONE_SIDE_ERROR) @DefaultValue(DEFAULT_ONE_SIDE_ERROR) boolean doOneSideError,
      @QueryParam(CUBE_EXCLUDED_DIMENSIONS) @DefaultValue(DEFAULT_EXCLUDED_DIMENSIONS) String excludedDimensions,
      @QueryParam(TIME_ZONE) @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone); @GET @Path("autoDimensionOrder") @Produces(MediaType.APPLICATION_JSON) String buildSummary(
      @QueryParam(METRIC_URN) String metricUrn,
      @QueryParam("dataset") String dataset,
      @QueryParam("metric") String metric,
      @QueryParam(CURRENT_START) long currentStartInclusive,
      @QueryParam(CURRENT_END) long currentEndExclusive,
      @QueryParam(BASELINE_START) long baselineStartInclusive,
      @QueryParam(BASELINE_END) long baselineEndExclusive,
      @QueryParam("dimensions") String groupByDimensions,
      @QueryParam("filters") String filterJsonPayload,
      @QueryParam(CUBE_SUMMARY_SIZE) int summarySize,
      @QueryParam(CUBE_DEPTH) @DefaultValue(DEFAULT_DEPTH) int depth,
      @QueryParam(CUBE_DIM_HIERARCHIES) @DefaultValue(DEFAULT_HIERARCHIES) String hierarchiesPayload,
      @QueryParam(CUBE_ONE_SIDE_ERROR) @DefaultValue(DEFAULT_ONE_SIDE_ERROR) boolean doOneSideError,
      @QueryParam(CUBE_EXCLUDED_DIMENSIONS) @DefaultValue(DEFAULT_EXCLUDED_DIMENSIONS) String excludedDimensions,
      @QueryParam(TIME_ZONE) @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone); @GET @Path("manualDimensionOrder") @Produces(MediaType.APPLICATION_JSON) String buildSummaryManualDimensionOrder(
      @QueryParam(METRIC_URN) String metricUrn,
      @QueryParam("dataset") String dataset,
      @QueryParam("metric") String metric,
      @QueryParam(CURRENT_START) long currentStartInclusive,
      @QueryParam(CURRENT_END) long currentEndExclusive,
      @QueryParam(BASELINE_START) long baselineStartInclusive,
      @QueryParam(BASELINE_END) long baselineEndExclusive,
      @QueryParam("dimensions") String groupByDimensions,
      @QueryParam("filters") String filterJsonPayload,
      @QueryParam(CUBE_SUMMARY_SIZE) int summarySize,
      @QueryParam(CUBE_ONE_SIDE_ERROR) @DefaultValue(DEFAULT_ONE_SIDE_ERROR) boolean doOneSideError,
      @QueryParam(TIME_ZONE) @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone); static final String DEFAULT_TIMEZONE_ID; static final String DEFAULT_DEPTH; static final String DEFAULT_HIERARCHIES; static final String DEFAULT_ONE_SIDE_ERROR; static final String DEFAULT_EXCLUDED_DIMENSIONS; }