org.springframework.batch.test
Class MetaDataInstanceFactory

java.lang.Object
  extended by org.springframework.batch.test.MetaDataInstanceFactory

public class MetaDataInstanceFactory
extends Object

Convenience methods for creating test instances of JobExecution, JobInstance and StepExecution.

Author:
Dave Syer

Constructor Summary
MetaDataInstanceFactory()
           
 
Method Summary
static JobExecution createJobExecution()
          Create a JobExecution with default parameters.
static JobExecution createJobExecution(Long executionId)
          Create a JobExecution with the parameters provided.
static JobExecution createJobExecution(String jobName, Long instanceId, Long executionId)
          Create a JobExecution with the parameters provided.
static JobExecution createJobExecution(String jobName, Long instanceId, Long executionId, JobParameters jobParameters)
          Create a JobExecution with the parameters provided.
static JobExecution createJobExecution(String jobName, Long instanceId, Long executionId, String jobParameters)
          Create a JobExecution with the parameters provided.
static JobExecution createJobExecutionWithStepExecutions(Long executionId, Collection<String> stepNames)
          Create a JobExecution with the parameters provided with attached step executions.
static JobInstance createJobInstance()
          Create a JobInstance with default parameters.
static JobInstance createJobInstance(String jobName, Long instanceId)
          Create a JobInstance with the parameters provided.
static JobInstance createJobInstance(String jobName, Long instanceId, JobParameters jobParameters)
          Create a JobInstance with the parameters provided.
static JobInstance createJobInstance(String jobName, Long instanceId, String jobParameters)
          Create a JobInstance with the parameters provided.
static StepExecution createStepExecution()
          Create a StepExecution with default parameters.
static StepExecution createStepExecution(JobExecution jobExecution, String stepName, Long executionId)
          Create a StepExecution with the parameters provided.
static StepExecution createStepExecution(String stepName, Long executionId)
          Create a StepExecution with the parameters provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaDataInstanceFactory

public MetaDataInstanceFactory()
Method Detail

createJobInstance

public static JobInstance createJobInstance(String jobName,
                                            Long instanceId,
                                            String jobParameters)
Create a JobInstance with the parameters provided.

Parameters:
jobName - the name of the job
instanceId - the Id of the JobInstance
jobParameters - comma or new line separated name=value pairs
Returns:
a JobInstance

createJobInstance

public static JobInstance createJobInstance(String jobName,
                                            Long instanceId,
                                            JobParameters jobParameters)
Create a JobInstance with the parameters provided.

Parameters:
jobName - the name of the job
instanceId - the Id of the JobInstance
jobParameters - an instance of JobParameters
Returns:
a JobInstance

createJobInstance

public static JobInstance createJobInstance(String jobName,
                                            Long instanceId)
Create a JobInstance with the parameters provided.

Parameters:
jobName - the name of the job
instanceId - the Id of the JobInstance
Returns:
a JobInstance with empty JobParameters

createJobInstance

public static JobInstance createJobInstance()
Create a JobInstance with default parameters.

Returns:
a JobInstance with name="job", id=12L and empty parameters

createJobExecution

public static JobExecution createJobExecution()
Create a JobExecution with default parameters.

Returns:
a JobExecution with id=123L

createJobExecution

public static JobExecution createJobExecution(Long executionId)
Create a JobExecution with the parameters provided.

Parameters:
executionId - the id for the JobExecution
Returns:
a JobExecution with valid JobInstance

createJobExecution

public static JobExecution createJobExecution(String jobName,
                                              Long instanceId,
                                              Long executionId)
Create a JobExecution with the parameters provided.

Parameters:
jobName - the name of the job
instanceId - the id for the JobInstance
executionId - the id for the JobExecution
Returns:
a JobExecution with empty JobParameters

createJobExecution

public static JobExecution createJobExecution(String jobName,
                                              Long instanceId,
                                              Long executionId,
                                              String jobParameters)
Create a JobExecution with the parameters provided.

Parameters:
jobName - the name of the job
instanceId - the Id of the JobInstance
executionId - the id for the JobExecution
jobParameters - comma or new line separated name=value pairs
Returns:
a JobExecution

createJobExecution

public static JobExecution createJobExecution(String jobName,
                                              Long instanceId,
                                              Long executionId,
                                              JobParameters jobParameters)
Create a JobExecution with the parameters provided.

Parameters:
jobName - the name of the job
instanceId - the Id of the JobInstance
executionId - the id for the JobExecution
jobParameters - an instance of JobParameters
Returns:
a JobExecution

createStepExecution

public static StepExecution createStepExecution()
Create a StepExecution with default parameters.

Returns:
a StepExecution with stepName="step" and id=1234L

createStepExecution

public static StepExecution createStepExecution(String stepName,
                                                Long executionId)
Create a StepExecution with the parameters provided.

Parameters:
stepName - the stepName for the StepExecution
executionId - the id for the StepExecution
Returns:
a StepExecution with a JobExecution having default properties

createStepExecution

public static StepExecution createStepExecution(JobExecution jobExecution,
                                                String stepName,
                                                Long executionId)
Create a StepExecution with the parameters provided.

Parameters:
stepName - the stepName for the StepExecution
executionId - the id for the StepExecution
Returns:
a StepExecution with the given JobExecution

createJobExecutionWithStepExecutions

public static JobExecution createJobExecutionWithStepExecutions(Long executionId,
                                                                Collection<String> stepNames)
Create a JobExecution with the parameters provided with attached step executions.

Parameters:
executionId - the JobExecution id
stepNames - the names of the step executions
Returns:
a JobExecution with step executions as specified, each with a unique id


Copyright © 2009 SpringSource. All Rights Reserved.