@Test public void testJobSpecConfigurationDependencyPathsAreResolvedRelativeToTheJobSpecFolderAsAbsolutePaths() throws IOException { final Path jobSpecsDir = Files.createTempDirectory(FilesystemJobSpecDAOTest.class.getSimpleName()); final JobSpecId jobSpecId = new JobSpecId("test"); final Path jobSpecPath = jobSpecsDir.resolve(jobSpecId.toString()); createDirectory(jobSpecPath); final Path jobSpecConfigurationPath = jobSpecPath.resolve(SPEC_DIR_SPEC_FILENAME); final String jobSpecConfigurationText = fixture("fixtures/dao/specs/FilesystemBasedJobSpecDAO/valid-job-spec-configuration.yml"); Files.write(jobSpecConfigurationPath, jobSpecConfigurationText.getBytes()); final FilesystemJobSpecDAO filesystemJobSpecDAO = new FilesystemJobSpecDAO(jobSpecsDir); final Optional<JobSpec> maybeJobSpecConfiguration = filesystemJobSpecDAO.getJobSpecById(jobSpecId); assertThat(maybeJobSpecConfiguration.isPresent()).isTrue(); final JobSpec jobSpec = maybeJobSpecConfiguration.get(); final String source = jobSpec.getExecution().getDependencies().get().get(0).getSource().getValue(); assertThat(source).isNotEqualTo("libyaml.so"); assertThat(source).isEqualTo(jobSpecPath.resolve("libyaml.so").toString()); }
@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);  }