Class MetaDataInstanceFactory
java.lang.Object
org.springframework.batch.test.MetaDataInstanceFactory
Convenience methods for creating test instances of
JobExecution,
JobInstance and StepExecution.- Author:
- Dave Syer, Mahmoud Ben Hassine
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default id for a job execution (123L)static final longThe default id for a job instance (12L)static final StringThe default name for a job ("job")static final longThe default id for a step execution (1234L)static final StringThe default name for a step ("step") -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.batch.core.job.JobExecutionCreate aJobExecutionwith default parameters.static org.springframework.batch.core.job.JobExecutioncreateJobExecution(Long executionId) Create aJobExecutionwith the parameters provided.static org.springframework.batch.core.job.JobExecutioncreateJobExecution(String jobName, Long instanceId, Long executionId) Create aJobExecutionwith the parameters provided.static org.springframework.batch.core.job.JobExecutioncreateJobExecution(String jobName, Long instanceId, Long executionId, org.springframework.batch.core.job.parameters.JobParameters jobParameters) Create aJobExecutionwith the parameters provided.static org.springframework.batch.core.job.JobExecutioncreateJobExecutionWithStepExecutions(Long executionId, Collection<String> stepNames) Create aJobExecutionwith the parameters provided with attached step executions.static org.springframework.batch.core.job.JobInstanceCreate aJobInstancewith default parameters.static org.springframework.batch.core.job.JobInstancecreateJobInstance(String jobName, Long instanceId) Create aJobInstancewith the parameters provided.static org.springframework.batch.core.step.StepExecutionCreate aStepExecutionwith default parameters.static org.springframework.batch.core.step.StepExecutioncreateStepExecution(String stepName, Long executionId) Create aStepExecutionwith the parameters provided.static org.springframework.batch.core.step.StepExecutioncreateStepExecution(org.springframework.batch.core.job.JobExecution jobExecution, String stepName, Long executionId) Create aStepExecutionwith the parameters provided.static org.springframework.batch.core.step.StepExecutioncreateStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters) Create aStepExecutionand all its parent entities with default values, but using theJobParametersprovided.static org.springframework.batch.core.step.StepExecutioncreateStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters, org.springframework.batch.infrastructure.item.ExecutionContext executionContext) Create aStepExecutionand all its parent entities with default values, but using theExecutionContextandJobParametersprovided.static org.springframework.batch.core.step.StepExecutioncreateStepExecution(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) Create aStepExecutionand all its parent entities with default values, but using theExecutionContextprovided.
-
Field Details
-
DEFAULT_JOB_NAME
-
DEFAULT_JOB_INSTANCE_ID
public static final long DEFAULT_JOB_INSTANCE_IDThe default id for a job instance (12L)- See Also:
-
DEFAULT_JOB_EXECUTION_ID
public static final long DEFAULT_JOB_EXECUTION_IDThe default id for a job execution (123L)- See Also:
-
DEFAULT_STEP_NAME
-
DEFAULT_STEP_EXECUTION_ID
public static final long DEFAULT_STEP_EXECUTION_IDThe default id for a step execution (1234L)- See Also:
-
-
Constructor Details
-
MetaDataInstanceFactory
public MetaDataInstanceFactory()
-
-
Method Details
-
createJobInstance
-
createJobInstance
public static org.springframework.batch.core.job.JobInstance createJobInstance()Create aJobInstancewith default parameters.- Returns:
- a
JobInstancewith name=DEFAULT_JOB_NAME, id=DEFAULT_JOB_INSTANCE_ID and empty parameters
-
createJobExecution
public static org.springframework.batch.core.job.JobExecution createJobExecution()Create aJobExecutionwith default parameters.- Returns:
- a
JobExecutionwith id=DEFAULT_JOB_EXECUTION_ID
-
createJobExecution
Create aJobExecutionwith the parameters provided.- Parameters:
executionId- the id for theJobExecution- Returns:
- a
JobExecutionwith validJobInstance
-
createJobExecution
public static org.springframework.batch.core.job.JobExecution createJobExecution(String jobName, Long instanceId, Long executionId) Create aJobExecutionwith the parameters provided.- Parameters:
jobName- the name of the jobinstanceId- the id for theJobInstanceexecutionId- the id for theJobExecution- Returns:
- a
JobExecutionwith emptyJobParameters
-
createJobExecution
public static org.springframework.batch.core.job.JobExecution createJobExecution(String jobName, Long instanceId, Long executionId, org.springframework.batch.core.job.parameters.JobParameters jobParameters) Create aJobExecutionwith the parameters provided.- Parameters:
jobName- the name of the jobinstanceId- the Id of theJobInstanceexecutionId- the id for theJobExecutionjobParameters- an instance ofJobParameters- Returns:
- a
JobExecution
-
createStepExecution
public static org.springframework.batch.core.step.StepExecution createStepExecution()Create aStepExecutionwith default parameters.- Returns:
- a
StepExecutionwith stepName="step" and id=DEFAULT_STEP_EXECUTION_ID
-
createStepExecution
public static org.springframework.batch.core.step.StepExecution createStepExecution(String stepName, Long executionId) Create aStepExecutionwith the parameters provided.- Parameters:
stepName- the stepName for theStepExecutionexecutionId- the id for theStepExecution- Returns:
- a
StepExecutionwith aJobExecutionhaving default properties
-
createStepExecution
public static org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.core.job.JobExecution jobExecution, String stepName, Long executionId) Create aStepExecutionwith the parameters provided.- Parameters:
jobExecution- instance ofJobExecution.stepName- the name for theStepExecution.executionId- the id for theStepExecution.- Returns:
- a
StepExecutionwith the givenJobExecution.
-
createJobExecutionWithStepExecutions
public static org.springframework.batch.core.job.JobExecution createJobExecutionWithStepExecutions(Long executionId, Collection<String> stepNames) Create aJobExecutionwith the parameters provided with attached step executions.- Parameters:
executionId- theJobExecutionidstepNames- the names of the step executions- Returns:
- a
JobExecutionwith step executions as specified, each with a unique id
-
createStepExecution
public static org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters, org.springframework.batch.infrastructure.item.ExecutionContext executionContext) Create aStepExecutionand all its parent entities with default values, but using theExecutionContextandJobParametersprovided.- Parameters:
jobParameters- comeJobParametersexecutionContext- someExecutionContext- Returns:
- a
StepExecutionwith the execution context provided
-
createStepExecution
public static org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters) Create aStepExecutionand all its parent entities with default values, but using theJobParametersprovided.- Parameters:
jobParameters- someJobParameters- Returns:
- a
StepExecutionwith the job parameters provided
-
createStepExecution
public static org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) Create aStepExecutionand all its parent entities with default values, but using theExecutionContextprovided.- Parameters:
executionContext- someExecutionContext- Returns:
- a
StepExecutionwith the execution context provided
-