EEToNetCDFExportDialog extends ProductChangeAwareDialog { static List<File> getTargetFiles(String filePath, File targetDir) throws IOException { final ArrayList<File> targetFiles = new ArrayList<>(); final File file = new File(filePath); if (file.isFile()) { final File outputFile = EEToNetCDFExporterOp.getOutputFile(file, targetDir); targetFiles.add(outputFile); } else { final TreeSet<File> sourceFileSet = new TreeSet<>(); WildcardMatcher.glob(filePath, sourceFileSet); for (File aSourceFile : sourceFileSet) { final File outputFile = EEToNetCDFExporterOp.getOutputFile(aSourceFile, targetDir); targetFiles.add(outputFile); } } return targetFiles; } EEToNetCDFExportDialog(AppContext appContext, String helpId);   }
@Test public void testGetTargetFiles_singleProduct() throws IOException { final File resourceFile = TestHelper.getResourceFile("SM_OPER_MIR_BWLF1C_20111026T143206_20111026T152520_503_001_1.zip"); final String filePath = resourceFile.getAbsolutePath(); final File targetDir = new File("/home/tom/target"); final List<File> targetFiles = EEToNetCDFExportDialog.getTargetFiles(filePath, targetDir); assertNotNull(targetFiles); assertEquals(1, targetFiles.size()); assertEquals(new File(targetDir, "SM_OPER_MIR_BWLF1C_20111026T143206_20111026T152520_503_001_1.nc").getAbsolutePath(), targetFiles.get(0).getAbsolutePath()); }
@Test public void testGetTargetFiles_directory() throws IOException { final File resourceDirectory = TestHelper.getResourceDirectory(); final File targetDir = new File("/home/tom/target"); final String wildCardpath = resourceDirectory.getAbsolutePath() + File.separator + "*"; final List<File> targetFiles = EEToNetCDFExportDialog.getTargetFiles(wildCardpath, targetDir); assertNotNull(targetFiles); assertEquals(4, targetFiles.size()); assertEquals(new File(targetDir, "SM_OPER_MIR_BWLF1C_20111026T143206_20111026T152520_503_001_1.nc").getAbsolutePath(), targetFiles.get(0).getAbsolutePath()); assertEquals(new File(targetDir, "SM_OPER_MIR_OSUDP2_20091204T001853_20091204T011255_310_001_1.nc").getAbsolutePath(), targetFiles.get(1).getAbsolutePath()); assertEquals(new File(targetDir, "SM_OPER_MIR_SMUDP2_20120514T163815_20120514T173133_551_001_1.nc").getAbsolutePath(), targetFiles.get(2).getAbsolutePath()); assertEquals(new File(targetDir, "SM_REPB_MIR_SCLF1C_20110201T151254_20110201T151308_505_152_1.nc").getAbsolutePath(), targetFiles.get(3).getAbsolutePath()); }