protected Map<String, CanaryScopePair> buildRequestScopes(
      CanaryAnalysisExecutionRequest config, long interval, Duration intervalDuration) {

    Map<String, CanaryScopePair> scopes = new HashMap<>();

    config
        .getScopes()
        .forEach(
            scope -> {
              ScopeTimeConfig scopeTimeConfig =
                  calculateStartAndEndForJudgement(config, interval, intervalDuration);

              CanaryScope controlScope =
                  new CanaryScope(
                      scope.getControlScope(),
                      scope.getControlLocation(),
                      scopeTimeConfig.start.minus(
                          Duration.ofMinutes(scope.getControlOffsetInMinutes())),
                      scopeTimeConfig.end.minus(
                          Duration.ofMinutes(scope.getControlOffsetInMinutes())),
                      config.getStep().getSeconds(),
                      scope.getExtendedScopeParams());

              CanaryScope experimentScope =
                  new CanaryScope(
                      scope.getExperimentScope(),
                      scope.getExperimentLocation(),
                      scopeTimeConfig.start,
                      scopeTimeConfig.end,
                      config.getStep().getSeconds(),
                      scope.getExtendedScopeParams());

              CanaryScopePair canaryScopePair =
                  CanaryScopePair.builder()
                      .controlScope(controlScope)
                      .experimentScope(experimentScope)
                      .build();

              scopes.put(scope.getScopeName(), canaryScopePair);
            });

    return scopes;
  }
@Test
  public void
      test_that_buildRequestScopes_has_expected_start_and_end_when_control_offset_is_supplied() {
    int interval = 1;
    String startIso = "2018-12-17T20:56:39.689Z";
    Duration lifetimeDuration = Duration.ofMinutes(3L);
    CanaryAnalysisExecutionRequest request =
        CanaryAnalysisExecutionRequest.builder()
            .scopes(
                ImmutableList.of(
                    CanaryAnalysisExecutionRequestScope.builder()
                        .controlOffsetInMinutes(5L)
                        .startTimeIso(startIso)
                        .build()))
            .build();

    var requestScopes = stage.buildRequestScopes(request, interval, lifetimeDuration);
    var defaultScope = requestScopes.get("default");
    var expectedControlStartIso = "2018-12-17T20:51:39.689Z";
    assertEquals(Instant.parse(startIso), defaultScope.getExperimentScope().getStart());
    assertEquals(Instant.parse(expectedControlStartIso), defaultScope.getControlScope().getStart());
  }