@Test public void testCheck_withInvalidDataName() { when(directory.listFiles()).thenReturn( new File[]{dataInput1, dataOutput1, spjFile, otherFile}); try { checker.check(directory); Assert.fail(); } catch (AppException e) { Assert.assertEquals(new AppException("Problem information directory contains unknown file type."), e); } }
@Override public void check(File file) throws AppException { AppExceptionUtil.assertNotNull(file); File[] files = file.listFiles(); if (files == null) { throw new AppException("Data file is invalid."); } Set<String> fileSet = new HashSet<>(); List<String> outputFileList = new LinkedList<>(); for (File current : files) { if (current.isDirectory()) { throw new AppException("Problem information contains sub-directory."); } if (current.getName().endsWith(".in")) { fileSet.add(FileUtil.getFileName(current)); } else if (current.getName().endsWith(".out")) { outputFileList.add(FileUtil.getFileName(current)); } else if (current.getName().equals("spj.cc")) { } else if (current.getName().equals("problemInfo.xml")) { } else { throw new AppException("Problem information directory contains unknown file type."); } } if (outputFileList.size() != fileSet.size()) { throw new AppException("Some data files has not input file or output file."); } if (fileSet.size() == 0) { throw new AppException("No test data."); } for (String outputFile : outputFileList) { if (!fileSet.contains(outputFile)) { throw new AppException("Some data files has not input file or output file."); } } }
ZipDataChecker implements Checker<File> { @Override public void check(File file) throws AppException { AppExceptionUtil.assertNotNull(file); File[] files = file.listFiles(); if (files == null) { throw new AppException("Data file is invalid."); } Set<String> fileSet = new HashSet<>(); List<String> outputFileList = new LinkedList<>(); for (File current : files) { if (current.isDirectory()) { throw new AppException("Problem information contains sub-directory."); } if (current.getName().endsWith(".in")) { fileSet.add(FileUtil.getFileName(current)); } else if (current.getName().endsWith(".out")) { outputFileList.add(FileUtil.getFileName(current)); } else if (current.getName().equals("spj.cc")) { } else if (current.getName().equals("problemInfo.xml")) { } else { throw new AppException("Problem information directory contains unknown file type."); } } if (outputFileList.size() != fileSet.size()) { throw new AppException("Some data files has not input file or output file."); } if (fileSet.size() == 0) { throw new AppException("No test data."); } for (String outputFile : outputFileList) { if (!fileSet.contains(outputFile)) { throw new AppException("Some data files has not input file or output file."); } } } }
ZipDataChecker implements Checker<File> { @Override public void check(File file) throws AppException { AppExceptionUtil.assertNotNull(file); File[] files = file.listFiles(); if (files == null) { throw new AppException("Data file is invalid."); } Set<String> fileSet = new HashSet<>(); List<String> outputFileList = new LinkedList<>(); for (File current : files) { if (current.isDirectory()) { throw new AppException("Problem information contains sub-directory."); } if (current.getName().endsWith(".in")) { fileSet.add(FileUtil.getFileName(current)); } else if (current.getName().endsWith(".out")) { outputFileList.add(FileUtil.getFileName(current)); } else if (current.getName().equals("spj.cc")) { } else if (current.getName().equals("problemInfo.xml")) { } else { throw new AppException("Problem information directory contains unknown file type."); } } if (outputFileList.size() != fileSet.size()) { throw new AppException("Some data files has not input file or output file."); } if (fileSet.size() == 0) { throw new AppException("No test data."); } for (String outputFile : outputFileList) { if (!fileSet.contains(outputFile)) { throw new AppException("Some data files has not input file or output file."); } } }  }
ZipDataChecker implements Checker<File> { @Override public void check(File file) throws AppException { AppExceptionUtil.assertNotNull(file); File[] files = file.listFiles(); if (files == null) { throw new AppException("Data file is invalid."); } Set<String> fileSet = new HashSet<>(); List<String> outputFileList = new LinkedList<>(); for (File current : files) { if (current.isDirectory()) { throw new AppException("Problem information contains sub-directory."); } if (current.getName().endsWith(".in")) { fileSet.add(FileUtil.getFileName(current)); } else if (current.getName().endsWith(".out")) { outputFileList.add(FileUtil.getFileName(current)); } else if (current.getName().equals("spj.cc")) { } else if (current.getName().equals("problemInfo.xml")) { } else { throw new AppException("Problem information directory contains unknown file type."); } } if (outputFileList.size() != fileSet.size()) { throw new AppException("Some data files has not input file or output file."); } if (fileSet.size() == 0) { throw new AppException("No test data."); } for (String outputFile : outputFileList) { if (!fileSet.contains(outputFile)) { throw new AppException("Some data files has not input file or output file."); } } }  @Override void check(File file); }
ZipDataChecker implements Checker<File> { @Override public void check(File file) throws AppException { AppExceptionUtil.assertNotNull(file); File[] files = file.listFiles(); if (files == null) { throw new AppException("Data file is invalid."); } Set<String> fileSet = new HashSet<>(); List<String> outputFileList = new LinkedList<>(); for (File current : files) { if (current.isDirectory()) { throw new AppException("Problem information contains sub-directory."); } if (current.getName().endsWith(".in")) { fileSet.add(FileUtil.getFileName(current)); } else if (current.getName().endsWith(".out")) { outputFileList.add(FileUtil.getFileName(current)); } else if (current.getName().equals("spj.cc")) { } else if (current.getName().equals("problemInfo.xml")) { } else { throw new AppException("Problem information directory contains unknown file type."); } } if (outputFileList.size() != fileSet.size()) { throw new AppException("Some data files has not input file or output file."); } if (fileSet.size() == 0) { throw new AppException("No test data."); } for (String outputFile : outputFileList) { if (!fileSet.contains(outputFile)) { throw new AppException("Some data files has not input file or output file."); } } }  @Override void check(File file);  }