@Test
  public void testParallelCopySuccess() throws Exception {
    try (MockedStatic<UserGroupInformation> userGroupInformationMockedStatic =  mockStatic(UserGroupInformation.class)) {
      userGroupInformationMockedStatic.when(UserGroupInformation::getCurrentUser).thenReturn(mock(UserGroupInformation.class));
      HiveConf conf = Mockito.spy(new HiveConf());
      when(conf.getIntVar(HiveConf.ConfVars.REPL_PARALLEL_COPY_TASKS)).thenReturn(2);
      when(conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST_REPL)).thenReturn(true);
      FileSystem destFs = mock(FileSystem.class);
      CopyUtils copyUtils = new CopyUtils(UserGroupInformation.getCurrentUser().getUserName(), conf, destFs);
      CopyUtils copyUtilsSpy = Mockito.spy(copyUtils);
      ExecutorService executorService = Executors.newFixedThreadPool(2);
      ExecutorService mockExecutorService = Mockito.spy(executorService);
      when(copyUtilsSpy.getExecutorService()).thenReturn(mockExecutorService);
      Path destination = new Path("dest");
      Path source = mock(Path.class);
      FileSystem fs = mock(FileSystem.class);
      ReplChangeManager.FileInfo srcFileInfo = new ReplChangeManager.FileInfo(fs, source, "path1");
      List<ReplChangeManager.FileInfo> srcFiles = Arrays.asList(srcFileInfo);
      doNothing().when(copyUtilsSpy).doCopy(Mockito.any(), Mockito.any(),
        anyBoolean(), anyBoolean(), Mockito.any());
      copyUtilsSpy.copyAndVerify(destination, srcFiles, source, true, true);
      Class<Collection<? extends Callable<Void>>> listClass =
        (Class<Collection<? extends Callable<Void>>>)(Class)List.class;
      //Thread pool Not invoked as only one target path
      ArgumentCaptor<Collection<? extends Callable<Void>>> callableCapture = ArgumentCaptor.forClass(listClass);
      Mockito.verify(mockExecutorService, Mockito.times(0)).invokeAll(callableCapture.capture());
      ReplChangeManager.FileInfo srcFileInfo1 = new ReplChangeManager.FileInfo(fs, source, "path2");
      ReplChangeManager.FileInfo srcFileInfo2 = new ReplChangeManager.FileInfo(fs, source, "path3");
      srcFiles = Arrays.asList(srcFileInfo1, srcFileInfo2);
      executorService = Executors.newFixedThreadPool(2);
      mockExecutorService = Mockito.spy(executorService);
      when(copyUtilsSpy.getExecutorService()).thenReturn(mockExecutorService);
      copyUtilsSpy.copyAndVerify(destination, srcFiles, source, true, true);
      //File count is greater than 1 do thread pool invoked
      Mockito.verify(mockExecutorService,
        Mockito.times(1)).invokeAll(callableCapture.capture());
    }
  }
Unit Test class for CopyUtils class.
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java