### Question:
KeyValueHandler extends Handler { @VisibleForTesting public VolumeChoosingPolicy getVolumeChoosingPolicyForTesting() { return volumeChoosingPolicy; } KeyValueHandler(ConfigurationSource config, String datanodeId,
      ContainerSet contSet, VolumeSet volSet, ContainerMetrics metrics,
      Consumer<ContainerReplicaProto> icrSender); @VisibleForTesting VolumeChoosingPolicy getVolumeChoosingPolicyForTesting(); @Override void stop(); @Override ContainerCommandResponseProto handle(
      ContainerCommandRequestProto request, Container container,
      DispatcherContext dispatcherContext); @VisibleForTesting ChunkManager getChunkManager(); @VisibleForTesting BlockManager getBlockManager(); @Override Container importContainer(ContainerData originalContainerData,
      final InputStream rawContainerStream,
      final TarContainerPacker packer); @Override void exportContainer(final Container container,
      final OutputStream outputStream,
      final TarContainerPacker packer); @Override void markContainerForClose(Container container); @Override void markContainerUnhealthy(Container container); @Override void quasiCloseContainer(Container container); @Override void closeContainer(Container container); @Override void deleteContainer(Container container, boolean force); @Override void deleteBlock(Container container, BlockData blockData);  }### Answer:
@Test public void testVolumeSetInKeyValueHandler() throws Exception{ File path = GenericTestUtils.getRandomizedTestDir(); OzoneConfiguration conf = new OzoneConfiguration(); conf.set(HDDS_DATANODE_DIR_KEY, path.getAbsolutePath()); MutableVolumeSet volumeSet = new MutableVolumeSet(UUID.randomUUID().toString(), conf); try { ContainerSet cset = new ContainerSet(); int[] interval = new int[1]; interval[0] = 2; ContainerMetrics metrics = new ContainerMetrics(interval); DatanodeDetails datanodeDetails = Mockito.mock(DatanodeDetails.class); DatanodeStateMachine stateMachine = Mockito.mock( DatanodeStateMachine.class); StateContext context = Mockito.mock(StateContext.class); Mockito.when(stateMachine.getDatanodeDetails()) .thenReturn(datanodeDetails); Mockito.when(context.getParent()).thenReturn(stateMachine); KeyValueHandler keyValueHandler = new KeyValueHandler(conf, context.getParent().getDatanodeDetails().getUuidString(), cset, volumeSet, metrics, c -> { }); assertEquals("org.apache.hadoop.ozone.container.common" + ".volume.RoundRobinVolumeChoosingPolicy", keyValueHandler.getVolumeChoosingPolicyForTesting() .getClass().getName()); conf.set(HDDS_DATANODE_VOLUME_CHOOSING_POLICY, "org.apache.hadoop.ozone.container.common.impl.HddsDispatcher"); try { new KeyValueHandler(conf, context.getParent().getDatanodeDetails().getUuidString(), cset, volumeSet, metrics, c->{}); } catch (RuntimeException ex) { GenericTestUtils.assertExceptionContains("class org.apache.hadoop" + ".ozone.container.common.impl.HddsDispatcher not org.apache" + ".hadoop.ozone.container.common.interfaces.VolumeChoosingPolicy", ex); } } finally { volumeSet.shutdown(); FileUtil.fullyDelete(path); } }