@Test public void testGetJobSpecConfigurationByIdReturnsEmptyOptionalIfJobSpecDoesNotExist() throws IOException { final Path jobSpecsDir = Files.createTempDirectory(FilesystemJobSpecDAOTest.class.getSimpleName()); final FilesystemJobSpecDAO filesystemJobSpecDAO = new FilesystemJobSpecDAO(jobSpecsDir); final JobSpecId jobSpecId = new JobSpecId(generateRandomBase36String(10)); final Optional<JobSpec> jobSpecDetailsResponse = filesystemJobSpecDAO.getJobSpecById(jobSpecId); assertThat(jobSpecDetailsResponse.isPresent()).isFalse(); }
@Override public Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId) { final Path jobSpecDir = jobSpecsDir.resolve(jobSpecId.toString()); if (!jobSpecDir.toFile().exists()) { return Optional.empty(); } else if (!jobSpecDir.toFile().isDirectory()) { log.error(jobSpecDir.toString() + ": is not a directory"); return Optional.empty(); } else { return loadJobSpec(jobSpecDir); } }
FilesystemJobSpecDAO implements JobSpecDAO { @Override public Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId) { final Path jobSpecDir = jobSpecsDir.resolve(jobSpecId.toString()); if (!jobSpecDir.toFile().exists()) { return Optional.empty(); } else if (!jobSpecDir.toFile().isDirectory()) { log.error(jobSpecDir.toString() + ": is not a directory"); return Optional.empty(); } else { return loadJobSpec(jobSpecDir); } } }
FilesystemJobSpecDAO implements JobSpecDAO { @Override public Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId) { final Path jobSpecDir = jobSpecsDir.resolve(jobSpecId.toString()); if (!jobSpecDir.toFile().exists()) { return Optional.empty(); } else if (!jobSpecDir.toFile().isDirectory()) { log.error(jobSpecDir.toString() + ": is not a directory"); return Optional.empty(); } else { return loadJobSpec(jobSpecDir); } } FilesystemJobSpecDAO(Path jobSpecsDir); }
FilesystemJobSpecDAO implements JobSpecDAO { @Override public Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId) { final Path jobSpecDir = jobSpecsDir.resolve(jobSpecId.toString()); if (!jobSpecDir.toFile().exists()) { return Optional.empty(); } else if (!jobSpecDir.toFile().isDirectory()) { log.error(jobSpecDir.toString() + ": is not a directory"); return Optional.empty(); } else { return loadJobSpec(jobSpecDir); } } FilesystemJobSpecDAO(Path jobSpecsDir); @Override Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId); @Override Map<String, HealthCheck> getHealthChecks(); @Override Optional<JobSpecSummary> getJobSpecSummaryById(JobSpecId jobSpecId); @Override List<JobSpecSummary> getJobSpecSummaries(int pageSize, int page); @Override List<JobSpecSummary> getJobSpecSummaries(int pageSize, int page, String query); }
FilesystemJobSpecDAO implements JobSpecDAO { @Override public Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId) { final Path jobSpecDir = jobSpecsDir.resolve(jobSpecId.toString()); if (!jobSpecDir.toFile().exists()) { return Optional.empty(); } else if (!jobSpecDir.toFile().isDirectory()) { log.error(jobSpecDir.toString() + ": is not a directory"); return Optional.empty(); } else { return loadJobSpec(jobSpecDir); } } FilesystemJobSpecDAO(Path jobSpecsDir); @Override Optional<JobSpec> getJobSpecById(JobSpecId jobSpecId); @Override Map<String, HealthCheck> getHealthChecks(); @Override Optional<JobSpecSummary> getJobSpecSummaryById(JobSpecId jobSpecId); @Override List<JobSpecSummary> getJobSpecSummaries(int pageSize, int page); @Override List<JobSpecSummary> getJobSpecSummaries(int pageSize, int page, String query);  }