IOUtils { public static Path checkFile(Path filePath) { requireNonNull(filePath, "File is null!"); checkArgument(Files.exists(filePath), "File not exists!"); checkArgument(Files.isRegularFile(filePath), "Not a file!"); return filePath; } private  IOUtils(); static Path checkFile(Path filePath); static String readFile(Path filePath, Charset charset); static String getFileHashCode(Path filePath);  }
@Test public void checkOnExistingFile() { assertEquals(temporaryFile, checkFile(temporaryFile)); }
@Test(expected = NullPointerException.class) public void checkOnNullFile() throws Exception { checkFile(null); }
@Test public void checkOnNotExistingFile() throws Exception { Path notExistingPath = Paths.get("notExistingPath"); expected.expect(IllegalArgumentException.class); expected.expectMessage("File not exists!"); checkFile(notExistingPath); }
@Test public void checkOnNotAFile() throws Exception { expected.expect(IllegalArgumentException.class); expected.expectMessage("Not a file!"); checkFile(temporaryDirectory); }