@Test(expected = IOException.class)
  public void shouldThrowExceptionOnDistcpFailure() throws Exception {
    Path destination = mock(Path.class);
    Path source = mock(Path.class);
    FileSystem fs = mock(FileSystem.class);
    List<Path> srcPaths = Arrays.asList(source, source);
    HiveConf conf = mock(HiveConf.class);
    CopyUtils copyUtils = Mockito.spy(new CopyUtils(null, conf, fs));
    doReturn(false).when(copyUtils).regularCopy(same(fs), anyList());

    when(source.getFileSystem(same(conf))).thenReturn(fs);
    try (MockedStatic<FileUtils> fileUtilsMockedStatic = mockStatic(FileUtils.class);
         MockedStatic<Utils> utilsMockedStatic = mockStatic(Utils.class)) {
      fileUtilsMockedStatic.when(
              () -> FileUtils.distCp(same(fs), anyList(), same(destination), anyBoolean(), eq(null), same(conf),
                      same(ShimLoader.getHadoopShims()))).thenReturn(false);
      utilsMockedStatic.when(Utils::getUGI).thenReturn(mock(UserGroupInformation.class));

      copyUtils.doCopy(destination, srcPaths);
    }
  }
Unit Test class for CopyUtils class.
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java