@Test public void testInitialEmptyState() { long expectedAtLeastRepairedAt = System.currentTimeMillis(); long repairIntervalInMs = TimeUnit.HOURS.toMillis(1); RepairConfiguration repairConfiguration = repairConfiguration(repairIntervalInMs); Host host = mockHost("DC1"); when(mockHostStates.isUp(eq(host))).thenReturn(true); VnodeRepairState vnodeRepairState = new VnodeRepairState(new LongTokenRange(1, 2), ImmutableSet.of(host), VnodeRepairState.UNREPAIRED); VnodeRepairStates vnodeRepairStates = VnodeRepairStates.newBuilder(Collections.singletonList(vnodeRepairState)) .build(); when(mockVnodeRepairStateFactory.calculateNewState(eq(tableReference), isNull(RepairStateSnapshot.class))).thenReturn(vnodeRepairStates); when(mockReplicaRepairGroupFactory.generateReplicaRepairGroups(repairGroupCaptor.capture())).thenReturn(Lists.emptyList()); RepairState repairState = new RepairStateImpl(tableReference, repairConfiguration, mockVnodeRepairStateFactory, mockHostStates, mockTableRepairMetrics, mockReplicaRepairGroupFactory); RepairStateSnapshot repairStateSnapshot = repairState.getSnapshot(); assertThat(repairGroupCaptor.getValue()).isEmpty(); assertRepairStateSnapshot(repairStateSnapshot, expectedAtLeastRepairedAt, Lists.emptyList(), vnodeRepairStates); verify(mockTableRepairMetrics).repairState(eq(tableReference), eq(1), eq(0)); verify(mockTableRepairMetrics).lastRepairedAt(eq(tableReference), eq(repairStateSnapshot.lastRepairedAt())); }
@Override public RepairStateSnapshot getSnapshot() { return myRepairStateSnapshot.get(); }
RepairStateImpl implements RepairState { @Override public RepairStateSnapshot getSnapshot() { return myRepairStateSnapshot.get(); } }
RepairStateImpl implements RepairState { @Override public RepairStateSnapshot getSnapshot() { return myRepairStateSnapshot.get(); } RepairStateImpl(TableReference tableReference, RepairConfiguration repairConfiguration,
                           VnodeRepairStateFactory vnodeRepairStateFactory, HostStates hostStates,
                           TableRepairMetrics tableRepairMetrics, ReplicaRepairGroupFactory replicaRepairGroupFactory); }
RepairStateImpl implements RepairState { @Override public RepairStateSnapshot getSnapshot() { return myRepairStateSnapshot.get(); } RepairStateImpl(TableReference tableReference, RepairConfiguration repairConfiguration,
                           VnodeRepairStateFactory vnodeRepairStateFactory, HostStates hostStates,
                           TableRepairMetrics tableRepairMetrics, ReplicaRepairGroupFactory replicaRepairGroupFactory); @Override final void update(); @Override RepairStateSnapshot getSnapshot(); }
RepairStateImpl implements RepairState { @Override public RepairStateSnapshot getSnapshot() { return myRepairStateSnapshot.get(); } RepairStateImpl(TableReference tableReference, RepairConfiguration repairConfiguration,
                           VnodeRepairStateFactory vnodeRepairStateFactory, HostStates hostStates,
                           TableRepairMetrics tableRepairMetrics, ReplicaRepairGroupFactory replicaRepairGroupFactory); @Override final void update(); @Override RepairStateSnapshot getSnapshot();  }