@Override
  public Distribution distribute(D2CanaryDistributionStrategy strategy)
  {
    switch (strategy.getStrategy()) {
      case TARGET_HOSTS:
        return distributeByTargetHosts(strategy);
      case TARGET_APPLICATIONS:
        return distributeByTargetApplications(strategy);
      case PERCENTAGE:
        return distributeByPercentage(strategy);
      case DISABLED:
        return Distribution.STABLE;
      default:
        _log.warn("Invalid distribution strategy type: " + strategy.getStrategy().name());
        return Distribution.STABLE;
    }
  }
@Test
  public void testNormalCasesForApplicationsStrategy()
  {
    TargetApplicationsStrategyProperties appsProperties =
        new TargetApplicationsStrategyProperties().setTargetApplications(new StringArray(Arrays.asList("appA", "appB")))
            .setScope(0.4);
    D2CanaryDistributionStrategy targetAppsStrategy =
        new D2CanaryDistributionStrategy().setStrategy(StrategyType.TARGET_APPLICATIONS)
            .setTargetApplicationsStrategyProperties(appsProperties);

    CanaryDistributionProviderImplFixture fixture = new CanaryDistributionProviderImplFixture();

    // NOT in target list
    Assert.assertEquals(fixture.getSpiedImpl("appC", null).distribute(targetAppsStrategy),
        CanaryDistributionProvider.Distribution.STABLE, "App not in target list should return stable.");

    // in scope and target list
    Assert.assertEquals(fixture.getSpiedImpl("appA", null, 38).distribute(targetAppsStrategy),
        CanaryDistributionProvider.Distribution.CANARY,
        "App in target list and hash result in canary scope should return canary.");

    // not in scope and in target list
    Assert.assertEquals(fixture.getSpiedImpl("appA", null, 50).distribute(targetAppsStrategy),
        CanaryDistributionProvider.Distribution.STABLE,
        "App in target list but hash result not in canary scope should return stable.");
  }