@Test
public void testAddRepairRun() throws Exception {

  DateTimeUtils.setCurrentMillisFixed(TIME_CREATE);
  RepairRunResource resource = new RepairRunResource(context);
  Response response = addDefaultRepairRun(resource);
  assertEquals(201, response.getStatus());
  assertTrue(response.getEntity() instanceof RepairRunStatus);
  assertEquals(1, context.storage.getClusters().size());
  assertEquals(1, context.storage.getRepairRunsForCluster(clustername, Optional.of(2)).size());
  assertEquals(1, context.storage.getRepairRunIdsForCluster(clustername, Optional.empty()).size());
  UUID runId = context.storage.getRepairRunIdsForCluster(clustername, Optional.empty()).iterator().next();
  RepairRun run = context.storage.getRepairRun(runId).get();
  final RepairUnit unit = context.storage.getRepairUnit(run.getRepairUnitId());
  assertEquals(RepairRun.RunState.NOT_STARTED, run.getRunState());
  assertEquals(TIME_CREATE, run.getCreationTime().getMillis());
  assertEquals(REPAIR_INTENSITY, run.getIntensity(), 0.0f);
  assertNull(run.getStartTime());
  assertNull(run.getEndTime());
  assertEquals(2, unit.getRepairThreadCount());
  // tokens [0, 100, 200], 6 requested segments per node and 3 nodes causes generating 20 RepairSegments
  assertEquals(
      20,
      context.storage.getSegmentAmountForRepairRunWithState(
          run.getId(), RepairSegment.State.NOT_STARTED));
  // adding another repair run should work as well
  response = addDefaultRepairRun(resource);
  assertEquals(201, response.getStatus());
  assertTrue(response.getEntity() instanceof RepairRunStatus);
  assertEquals(1, context.storage.getClusters().size());
  assertEquals(1, context.storage.getRepairRunsForCluster(clustername, Optional.of(1)).size());
  assertEquals(2, context.storage.getRepairRunsForCluster(clustername, Optional.of(2)).size());
  assertEquals(2, context.storage.getRepairRunsForCluster(clustername, Optional.of(3)).size());
  assertEquals(
      context.storage.getRepairRunsForCluster(clustername, Optional.of(3)).iterator().next().getId(),
      context.storage.getRepairRunsForCluster(clustername, Optional.of(1)).iterator().next().getId());
  assertEquals(
      context.storage.getRepairRunsForCluster(clustername, Optional.of(2)).iterator().next().getId(),
      context.storage.getRepairRunsForCluster(clustername, Optional.of(1)).iterator().next().getId());
}