Class MetaDataInstanceFactory

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

public class MetaDataInstanceFactory extends Object
Convenience methods for creating test instances of JobExecution, JobInstance and StepExecution.
Author:
Dave Syer, Mahmoud Ben Hassine
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The default id for a job execution (123L)
    static final long
    The default id for a job instance (12L)
    static final String
    The default name for a job ("job")
    static final long
    The default id for a step execution (1234L)
    static final String
    The default name for a step ("step")
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.batch.core.job.JobExecution
    Create a JobExecution with default parameters.
    static org.springframework.batch.core.job.JobExecution
    createJobExecution(Long executionId)
    Create a JobExecution with the parameters provided.
    static org.springframework.batch.core.job.JobExecution
    createJobExecution(String jobName, Long instanceId, Long executionId)
    Create a JobExecution with the parameters provided.
    static org.springframework.batch.core.job.JobExecution
    createJobExecution(String jobName, Long instanceId, Long executionId, org.springframework.batch.core.job.parameters.JobParameters jobParameters)
    Create a JobExecution with the parameters provided.
    static org.springframework.batch.core.job.JobExecution
    Create a JobExecution with the parameters provided with attached step executions.
    static org.springframework.batch.core.job.JobInstance
    Create a JobInstance with default parameters.
    static org.springframework.batch.core.job.JobInstance
    createJobInstance(String jobName, Long instanceId)
    Create a JobInstance with the parameters provided.
    static org.springframework.batch.core.step.StepExecution
    Create a StepExecution with default parameters.
    static org.springframework.batch.core.step.StepExecution
    createStepExecution(String stepName, Long executionId)
    Create a StepExecution with the parameters provided.
    static org.springframework.batch.core.step.StepExecution
    createStepExecution(org.springframework.batch.core.job.JobExecution jobExecution, String stepName, Long executionId)
    Create a StepExecution with the parameters provided.
    static org.springframework.batch.core.step.StepExecution
    createStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters)
    Create a StepExecution and all its parent entities with default values, but using the JobParameters provided.
    static org.springframework.batch.core.step.StepExecution
    createStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters, org.springframework.batch.infrastructure.item.ExecutionContext executionContext)
    Create a StepExecution and all its parent entities with default values, but using the ExecutionContext and JobParameters provided.
    static org.springframework.batch.core.step.StepExecution
    createStepExecution(org.springframework.batch.infrastructure.item.ExecutionContext executionContext)
    Create a StepExecution and all its parent entities with default values, but using the ExecutionContext provided.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_JOB_NAME

      public static final String DEFAULT_JOB_NAME
      The default name for a job ("job")
      See Also:
    • DEFAULT_JOB_INSTANCE_ID

      public static final long DEFAULT_JOB_INSTANCE_ID
      The default id for a job instance (12L)
      See Also:
    • DEFAULT_JOB_EXECUTION_ID

      public static final long DEFAULT_JOB_EXECUTION_ID
      The default id for a job execution (123L)
      See Also:
    • DEFAULT_STEP_NAME

      public static final String DEFAULT_STEP_NAME
      The default name for a step ("step")
      See Also:
    • DEFAULT_STEP_EXECUTION_ID

      public static final long DEFAULT_STEP_EXECUTION_ID
      The default id for a step execution (1234L)
      See Also:
  • Constructor Details

    • MetaDataInstanceFactory

      public MetaDataInstanceFactory()
  • Method Details

    • createJobInstance

      public static org.springframework.batch.core.job.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 org.springframework.batch.core.job.JobInstance createJobInstance()
      Create a JobInstance with default parameters.
      Returns:
      a JobInstance with name=DEFAULT_JOB_NAME, id=DEFAULT_JOB_INSTANCE_ID and empty parameters
    • createJobExecution

      public static org.springframework.batch.core.job.JobExecution createJobExecution()
      Create a JobExecution with default parameters.
      Returns:
      a JobExecution with id=DEFAULT_JOB_EXECUTION_ID
    • createJobExecution

      public static org.springframework.batch.core.job.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 org.springframework.batch.core.job.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 org.springframework.batch.core.job.JobExecution createJobExecution(String jobName, Long instanceId, Long executionId, org.springframework.batch.core.job.parameters.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 org.springframework.batch.core.step.StepExecution createStepExecution()
      Create a StepExecution with default parameters.
      Returns:
      a StepExecution with stepName="step" and id=DEFAULT_STEP_EXECUTION_ID
    • createStepExecution

      public static org.springframework.batch.core.step.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 org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.core.job.JobExecution jobExecution, String stepName, Long executionId)
      Create a StepExecution with the parameters provided.
      Parameters:
      jobExecution - instance of JobExecution.
      stepName - the name for the StepExecution.
      executionId - the id for the StepExecution.
      Returns:
      a StepExecution with the given JobExecution.
    • createJobExecutionWithStepExecutions

      public static org.springframework.batch.core.job.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
    • 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 a StepExecution and all its parent entities with default values, but using the ExecutionContext and JobParameters provided.
      Parameters:
      jobParameters - come JobParameters
      executionContext - some ExecutionContext
      Returns:
      a StepExecution with the execution context provided
    • createStepExecution

      public static org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.core.job.parameters.JobParameters jobParameters)
      Create a StepExecution and all its parent entities with default values, but using the JobParameters provided.
      Parameters:
      jobParameters - some JobParameters
      Returns:
      a StepExecution with the job parameters provided
    • createStepExecution

      public static org.springframework.batch.core.step.StepExecution createStepExecution(org.springframework.batch.infrastructure.item.ExecutionContext executionContext)
      Create a StepExecution and all its parent entities with default values, but using the ExecutionContext provided.
      Parameters:
      executionContext - some ExecutionContext
      Returns:
      a StepExecution with the execution context provided