@Test public void path_existing_and_executable_is_valid() throws Exception { Path tempFile = Files.createTempFile("pds_executable", ".sh",PosixFilePermissions.asFileAttribute(Collections.singleton(PosixFilePermission.OWNER_EXECUTE))); String message = validatorToTest.createValidationErrorMessage(tempFile.toRealPath().toString()); assertValid(message); }
public String createValidationErrorMessage(String path) { if (path == null || path.trim().isEmpty()) { return "no path set!"; } Path p = Paths.get(path); if (Files.notExists(p)) { return "file does not exist:"+path; } if (! Files.isExecutable(p)) { return "file exists, but not executable:"+path; } return null; }
PDSPathExecutableValidator { public String createValidationErrorMessage(String path) { if (path == null || path.trim().isEmpty()) { return "no path set!"; } Path p = Paths.get(path); if (Files.notExists(p)) { return "file does not exist:"+path; } if (! Files.isExecutable(p)) { return "file exists, but not executable:"+path; } return null; } }
PDSPathExecutableValidator { public String createValidationErrorMessage(String path) { if (path == null || path.trim().isEmpty()) { return "no path set!"; } Path p = Paths.get(path); if (Files.notExists(p)) { return "file does not exist:"+path; } if (! Files.isExecutable(p)) { return "file exists, but not executable:"+path; } return null; }  }
PDSPathExecutableValidator { public String createValidationErrorMessage(String path) { if (path == null || path.trim().isEmpty()) { return "no path set!"; } Path p = Paths.get(path); if (Files.notExists(p)) { return "file does not exist:"+path; } if (! Files.isExecutable(p)) { return "file exists, but not executable:"+path; } return null; }  String createValidationErrorMessage(String path); }
PDSPathExecutableValidator { public String createValidationErrorMessage(String path) { if (path == null || path.trim().isEmpty()) { return "no path set!"; } Path p = Paths.get(path); if (Files.notExists(p)) { return "file does not exist:"+path; } if (! Files.isExecutable(p)) { return "file exists, but not executable:"+path; } return null; }  String createValidationErrorMessage(String path);  }