### Question:
TableMetricHolder implements Closeable { public void repairState(int repairedRanges, int notRepairedRanges) { myRepairState.set(new RangeRepairState(repairedRanges, notRepairedRanges)); double ratio; if (notRepairedRanges == 0) { ratio = 1; } else if (repairedRanges == 0) { ratio = 0; } else { ratio = (double)repairedRanges / (repairedRanges + notRepairedRanges); } myNodeMetricHolder.repairState(myTableReference, ratio); } TableMetricHolder(TableReference tableReference, MetricRegistry metricRegistry, NodeMetricHolder nodeMetricHolder); void init(); void repairState(int repairedRanges, int notRepairedRanges); void lastRepairedAt(long lastRepairedAt); void repairTiming(long timeTaken, TimeUnit timeUnit, boolean successful); @Override void close();  }### Answer:
@Test public void testUpdateRepairStateIsPropagatedToNodeMetrics() { int expectedRepaired = 1; int expectedNotRepaired = 2; double expectedRatio = (double)expectedRepaired / (expectedNotRepaired + expectedRepaired); myTableMetricHolder.repairState(expectedRepaired, expectedNotRepaired); assertThat(getGague(TableMetricHolder.REPAIR_STATE).getValue()).isEqualTo(expectedRatio); verify(myNodeMetricHolder).repairState(eq(myTableReference), eq(expectedRatio)); }
@Test public void testUpdateRepairStateAllRepaired() { int expectedRepaired = 1; int expectedNotRepaired = 0; double expectedRatio = 1; myTableMetricHolder.repairState(expectedRepaired, expectedNotRepaired); assertThat(getGague(TableMetricHolder.REPAIR_STATE).getValue()).isEqualTo(expectedRatio); verify(myNodeMetricHolder).repairState(eq(myTableReference), eq(expectedRatio)); }
@Test public void testUpdateRepairStateNothingRepaired() { int expectedRepaired = 0; int expectedNotRepaired = 1; double expectedRatio = 0; myTableMetricHolder.repairState(expectedRepaired, expectedNotRepaired); assertThat(getGague(TableMetricHolder.REPAIR_STATE).getValue()).isEqualTo(expectedRatio); verify(myNodeMetricHolder).repairState(eq(myTableReference), eq(expectedRatio)); }