### Question:
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);  }### Answer:
@Test public void null_path_not_valid() { assertNotValid(validatorToTest.createValidationErrorMessage(null)); }
@Test public void empty_path_not_valid() { assertNotValid(validatorToTest.createValidationErrorMessage("")); }
@Test public void path_existing_but_not_executable_not_valid() throws Exception { Path tempFile = Files.createTempFile("pds_executable", ".sh"); String message = validatorToTest.createValidationErrorMessage(tempFile.toRealPath().toString()); assertNotValid(message); assertTrue(message.contains("but not executable")); }
@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); }