### Question:
RepairGroup extends ScheduledTask { @Override public LockFactory.DistributedLock getLock(LockFactory lockFactory) throws LockException { Map<String, String> metadata = new HashMap<>(); metadata.put(LOCK_METADATA_KEYSPACE, myTableReference.getKeyspace()); metadata.put(LOCK_METADATA_TABLE, myTableReference.getTable()); Set<RepairResource> repairResources = myRepairResourceFactory.getRepairResources(myReplicaRepairGroup); return myRepairLockFactory.getLock(lockFactory, repairResources, metadata, myPriority); } RepairGroup(int priority,
                       TableReference tableReference,
                       RepairConfiguration repairConfiguration,
                       ReplicaRepairGroup replicaRepairGroup,
                       JmxProxyFactory jmxProxyFactory,
                       TableRepairMetrics tableRepairMetrics,
                       RepairResourceFactory repairResourceFactory,
                       RepairLockFactory repairLockFactory);  RepairGroup(int priority,
            TableReference tableReference,
            RepairConfiguration repairConfiguration,
            ReplicaRepairGroup replicaRepairGroup,
            JmxProxyFactory jmxProxyFactory,
            TableRepairMetrics tableRepairMetrics,
            RepairResourceFactory repairResourceFactory,
            RepairLockFactory repairLockFactory,
            List<TableRepairPolicy> tableRepairPolicies); @Override boolean execute(); @Override LockFactory.DistributedLock getLock(LockFactory lockFactory); @Override String toString();  }### Answer:
@Test public void testGetLock() throws LockException { Map<String, String> metadata = new HashMap<>(); metadata.put("keyspace", keyspaceName); metadata.put("table", tableName); ReplicaRepairGroup replicaRepairGroup = new ReplicaRepairGroup(ImmutableSet.of(), ImmutableList.of()); Set<RepairResource> repairResources = Sets.newHashSet(new RepairResource("DC1", "my-resource")); doReturn(repairResources).when(myRepairResourceFactory).getRepairResources(eq(replicaRepairGroup)); doReturn(new DummyLock()).when(myRepairLockFactory).getLock(eq(myLockFactory), eq(repairResources), eq(metadata), eq(priority)); RepairGroup repairGroup = new RepairGroup(priority, tableReference, repairConfiguration, replicaRepairGroup, myJmxProxyFactory, myTableRepairMetrics, myRepairResourceFactory, myRepairLockFactory); repairGroup.getLock(myLockFactory); verify(myRepairResourceFactory).getRepairResources(eq(replicaRepairGroup)); verify(myRepairLockFactory).getLock(eq(myLockFactory), eq(repairResources), eq(metadata), eq(priority)); }
@Test public void testGetLockWithThrowingLockingStrategy() throws LockException { Map<String, String> metadata = new HashMap<>(); metadata.put("keyspace", keyspaceName); metadata.put("table", tableName); ReplicaRepairGroup replicaRepairGroup = new ReplicaRepairGroup(ImmutableSet.of(), ImmutableList.of()); Set<RepairResource> repairResources = Sets.newHashSet(new RepairResource("DC1", "my-resource")); doReturn(repairResources).when(myRepairResourceFactory).getRepairResources(eq(replicaRepairGroup)); doThrow(LockException.class).when(myRepairLockFactory).getLock(eq(myLockFactory), eq(repairResources), eq(metadata), eq(priority)); RepairGroup repairGroup = new RepairGroup(priority, tableReference, repairConfiguration, replicaRepairGroup, myJmxProxyFactory, myTableRepairMetrics, myRepairResourceFactory, myRepairLockFactory); assertThatExceptionOfType(LockException.class).isThrownBy(() -> repairGroup.getLock(myLockFactory)); verify(myRepairResourceFactory).getRepairResources(eq(replicaRepairGroup)); verify(myRepairLockFactory).getLock(eq(myLockFactory), eq(repairResources), eq(metadata), eq(priority)); }