### Question:
KubernetesUtils { public static void copyFileOrDirectory(String source, String destination) throws KubernetesPluginException { File src = new File(source); File dst = new File(destination); try { if (Files.isRegularFile(Paths.get(source))) { if (Files.isDirectory(dst.toPath())) { FileUtils.copyFileToDirectory(src, dst); } else { FileUtils.copyFile(src, dst); } } else if (Files.isDirectory(Paths.get(source))) { FileUtils.copyDirectory(src, dst); } } catch (IOException e) { throw new KubernetesPluginException("error while copying file", e); } }  static void writeToFile(String context, String outputFileName); static void writeToFile(Path outputDir, String context, String fileSuffix); static byte[] readFileContent(Path targetFilePath); static void copyFileOrDirectory(String source, String destination); static void printInfo(String msg); static void printError(String msg); static void printDebug(String msg); static void printWarning(String message); static void printInstruction(String msg); static void deleteDirectory(Path path); static boolean isBlank(String str); static String resolveValue(String value); static List<String> getList(BLangExpression expr); static Map<String, String> getMap(BLangExpression expr); static boolean getBooleanValue(BLangExpression expr); static long getLongValue(BLangExpression expr); static int getIntValue(BLangExpression expr); static String getStringValue(BLangExpression expr); static String getValidName(String name); static DeploymentBuildExtension parseBuildExtension(BLangExpression buildExtensionValue); static Map<String, EnvVarValueModel> getEnvVarMap(BLangExpression envVarValues); static Set<String> getImagePullSecrets(BLangRecordLiteral.BLangRecordKeyValueField keyValue); static Set<CopyFileModel> getExternalFileMap(BLangRecordLiteral.BLangRecordKeyValueField keyValue); static List<EnvVar> populateEnvVar(Map<String, EnvVarValueModel> envMap); static List<BLangRecordLiteral.BLangRecordKeyValueField> convertRecordFields(
            List<BLangRecordLiteral.RecordField> fields); static AnnotationAttachmentNode createAnnotation(String annotationName);  }### Answer:
@Test public void copyFileTest() throws IOException, KubernetesPluginException { File testFile = tempDirectory.resolve("copy.txt").toFile(); Assert.assertTrue(testFile.createNewFile()); Path tempDirectory = Files.createTempDirectory("copy-test-"); Path destinationFile = tempDirectory.resolve("copy.txt"); KubernetesUtils.copyFileOrDirectory(testFile.getAbsolutePath(), destinationFile.toString()); Assert.assertTrue(Files.exists(destinationFile)); FileUtils.deleteQuietly(testFile); FileUtils.deleteQuietly(tempDirectory.toFile()); }
@Test public void copyDirectoryTest() throws IOException, KubernetesPluginException { File testFolder = tempDirectory.resolve("copyDir").toFile(); Assert.assertTrue(testFolder.mkdirs()); Path copy1File = testFolder.toPath().resolve("copy1.txt"); Path copy2File = testFolder.toPath().resolve("copy2.txt"); Files.createFile(copy1File); Files.createFile(copy2File); Path destinationDir = Files.createTempDirectory("copy-test-"); KubernetesUtils.copyFileOrDirectory(testFolder.getAbsolutePath(), destinationDir.toString()); Assert.assertTrue(Files.exists(destinationDir)); Assert.assertTrue(Files.exists(destinationDir.resolve("copy1.txt"))); Assert.assertTrue(Files.exists(destinationDir.resolve("copy2.txt"))); FileUtils.deleteQuietly(testFolder); FileUtils.deleteQuietly(destinationDir.toFile()); }
@Test public void copyFileToDirectoryTest() throws IOException, KubernetesPluginException { File testFile = tempDirectory.resolve("copy.txt").toFile(); Assert.assertTrue(testFile.createNewFile()); Path destinationDir = Files.createTempDirectory("copy-test-"); KubernetesUtils.copyFileOrDirectory(testFile.getAbsolutePath(), destinationDir.toString()); Assert.assertTrue(Files.exists(destinationDir.resolve("copy.txt"))); FileUtils.deleteQuietly(testFile); FileUtils.deleteQuietly(destinationDir.toFile()); }