From f2e96f4f71aab0583df45b899aa70d86a8ee6fc3 Mon Sep 17 00:00:00 2001 From: dsyer Date: Wed, 4 Nov 2009 12:21:04 +0000 Subject: [PATCH] RESOLVED - issue BATCH-1421: Add method to get all job names to JobExplorer --- .../batch/core/explore/JobExplorer.java | 8 ++++++++ .../batch/core/explore/support/SimpleJobExplorer.java | 7 +++++++ .../core/exlore/support/SimpleJobExplorerTests.java | 10 ++++++++++ .../core/launch/support/CommandLineJobRunnerTests.java | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java index d7c7f2e96..7e5ef85fd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java @@ -80,4 +80,12 @@ public interface JobExplorer { */ Set findRunningJobExecutions(String jobName); + /** + * Query the repository for all unique {@link JobInstance} names (sorted + * alphabetically). + * + * @return the set of job names that have been executed + */ + List getJobNames(); + } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java index 6862877b7..dc92ea4bc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java @@ -159,6 +159,13 @@ public class SimpleJobExplorer implements JobExplorer { int count) { return jobInstanceDao.getJobInstances(jobName, start, count); } + + /* (non-Javadoc) + * @see org.springframework.batch.core.explore.JobExplorer#getJobNames() + */ + public List getJobNames() { + return jobInstanceDao.getJobNames(); + } /* * Find all dependencies for a JobExecution, including JobInstance (which diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/SimpleJobExplorerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/SimpleJobExplorerTests.java index 539408021..266d6ad7a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/SimpleJobExplorerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/SimpleJobExplorerTests.java @@ -174,4 +174,14 @@ public class SimpleJobExplorerTests extends TestCase { verify(jobExecutionDao, jobInstanceDao, stepExecutionDao); } + @Test + public void testGetJobNames() throws Exception { + jobInstanceDao.getJobNames(); + EasyMock.expectLastCall().andReturn( + Collections.singletonList("foo")); + replay(jobExecutionDao, jobInstanceDao, stepExecutionDao); + jobExplorer.getJobNames(); + verify(jobExecutionDao, jobInstanceDao, stepExecutionDao); + } + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java index c0882b5ad..0a6b816de 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java @@ -298,6 +298,10 @@ public class CommandLineJobRunnerTests { public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) { throw new UnsupportedOperationException(); } + + public List getJobNames() { + throw new UnsupportedOperationException(); + } }