@Test
public void addingAClusterAutomaticallySetupSchedulingRepairsWhenEnabled() throws Exception {

  final MockObjects mocks = initMocks();
  when(mocks.jmxProxy.getLiveNodes()).thenReturn(Arrays.asList(SEED_HOST));
  when(mocks.jmxProxy.getKeyspaces()).thenReturn(Lists.newArrayList("keyspace1"));
  when(mocks.jmxProxy.getTablesForKeyspace("keyspace1"))
      .thenReturn(Sets.newHashSet(Table.builder().withName("table1").withCompactionStrategy(STCS).build()));
  mocks.context.config = TestRepairConfiguration.defaultConfigBuilder()
      .withAutoScheduling(
          TestRepairConfiguration.defaultAutoSchedulingConfigBuilder()
              .thatIsEnabled()
              .withTimeBeforeFirstSchedule(Duration.ofMinutes(1))
              .build())
      .build();
  ClusterResource clusterResource = new ClusterResource(
          mocks.context,
          mocks.cryptograph,
          Executors.newFixedThreadPool(2));
  Response response = clusterResource
      .addOrUpdateCluster(mocks.uriInfo, Optional.of(SEED_HOST), Optional.of(Cluster.DEFAULT_JMX_PORT),
              Optional.of(JMX_USERNAME), Optional.of(JMX_PASSWORD));
  assertEquals(HttpStatus.CREATED_201, response.getStatus());
  assertEquals(1, mocks.context.storage.getAllRepairSchedules().size());
  assertEquals(1, mocks.context.storage.getRepairSchedulesForClusterAndKeyspace(CLUSTER_NAME, "keyspace1").size());
}