@Test public void testGenerateOutputPathWithEmptyBasePath() { String basePath = ""; String output = underTest.generateOutputPath(basePath, CLUSTER_NAME, HOSTNAME, new File("/my/path")); Assert.assertEquals("cl/hostname/my/path", output); }
@VisibleForTesting String generateOutputPath(String basePath, String clusterName, String hostName, File localFile) { final String outputWithoutBasePath = Paths.get(clusterName, hostName, localFile.getParentFile().getName(), localFile.getName()).toString(); final String outputPath; if (StringUtils.isNotEmpty(basePath)) { if (!basePath.endsWith("/")){ outputPath = basePath + "/" + outputWithoutBasePath; } else { outputPath = basePath + outputWithoutBasePath; } } else { outputPath = outputWithoutBasePath; } return outputPath; }
CloudStorageUploader extends Thread { @VisibleForTesting String generateOutputPath(String basePath, String clusterName, String hostName, File localFile) { final String outputWithoutBasePath = Paths.get(clusterName, hostName, localFile.getParentFile().getName(), localFile.getName()).toString(); final String outputPath; if (StringUtils.isNotEmpty(basePath)) { if (!basePath.endsWith("/")){ outputPath = basePath + "/" + outputWithoutBasePath; } else { outputPath = basePath + outputWithoutBasePath; } } else { outputPath = outputWithoutBasePath; } return outputPath; } }
CloudStorageUploader extends Thread { @VisibleForTesting String generateOutputPath(String basePath, String clusterName, String hostName, File localFile) { final String outputWithoutBasePath = Paths.get(clusterName, hostName, localFile.getParentFile().getName(), localFile.getName()).toString(); final String outputPath; if (StringUtils.isNotEmpty(basePath)) { if (!basePath.endsWith("/")){ outputPath = basePath + "/" + outputWithoutBasePath; } else { outputPath = basePath + outputWithoutBasePath; } } else { outputPath = outputWithoutBasePath; } return outputPath; } CloudStorageUploader(String name, UploadClient uploadClient, LogFeederProps logFeederProps); }
CloudStorageUploader extends Thread { @VisibleForTesting String generateOutputPath(String basePath, String clusterName, String hostName, File localFile) { final String outputWithoutBasePath = Paths.get(clusterName, hostName, localFile.getParentFile().getName(), localFile.getName()).toString(); final String outputPath; if (StringUtils.isNotEmpty(basePath)) { if (!basePath.endsWith("/")){ outputPath = basePath + "/" + outputWithoutBasePath; } else { outputPath = basePath + outputWithoutBasePath; } } else { outputPath = outputWithoutBasePath; } return outputPath; } CloudStorageUploader(String name, UploadClient uploadClient, LogFeederProps logFeederProps); @Override void run(); }
CloudStorageUploader extends Thread { @VisibleForTesting String generateOutputPath(String basePath, String clusterName, String hostName, File localFile) { final String outputWithoutBasePath = Paths.get(clusterName, hostName, localFile.getParentFile().getName(), localFile.getName()).toString(); final String outputPath; if (StringUtils.isNotEmpty(basePath)) { if (!basePath.endsWith("/")){ outputPath = basePath + "/" + outputWithoutBasePath; } else { outputPath = basePath + outputWithoutBasePath; } } else { outputPath = outputWithoutBasePath; } return outputPath; } CloudStorageUploader(String name, UploadClient uploadClient, LogFeederProps logFeederProps); @Override void run();  }