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

Field Summary
static long DEFAULT_JOB_EXECUTION_ID
          The default id for a job execution (123L)
static long DEFAULT_JOB_INSTANCE_ID
          The default id for a job instance (12L)
static String DEFAULT_JOB_NAME
          The default name for a job ("job")
static long DEFAULT_STEP_EXECUTION_ID
          The default id for a step execution (1234L)
static String DEFAULT_STEP_NAME
          The default name for a step ("step")
 
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(ExecutionContext executionContext)
          Create a StepExecution and all its parent entities with default values, but using the ExecutionContext provided.
static StepExecution createStepExecution(JobExecution jobExecution, String stepName, Long executionId)
          Create a StepExecution with the parameters provided.
static StepExecution createStepExecution(JobParameters jobParameters)
          Create a StepExecution and all its parent entities with default values, but using the JobParameters provided.
static StepExecution createStepExecution(JobParameters jobParameters, ExecutionContext executionContext)
          Create a StepExecution and all its parent entities with default values, but using the ExecutionContext and JobParameters 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
 

Field Detail

DEFAULT_JOB_NAME

public static final String DEFAULT_JOB_NAME
The default name for a job ("job")

See Also:
Constant Field Values

DEFAULT_JOB_INSTANCE_ID

public static final long DEFAULT_JOB_INSTANCE_ID
The default id for a job instance (12L)

See Also:
Constant Field Values

DEFAULT_JOB_EXECUTION_ID

public static final long DEFAULT_JOB_EXECUTION_ID
The default id for a job execution (123L)

See Also:
Constant Field Values

DEFAULT_STEP_NAME

public static final String DEFAULT_STEP_NAME
The default name for a step ("step")

See Also:
Constant Field Values

DEFAULT_STEP_EXECUTION_ID

public static final long DEFAULT_STEP_EXECUTION_ID
The default id for a step execution (1234L)

See Also:
Constant Field Values
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=DEFAULT_JOB_NAME, id=DEFAULT_JOB_INSTANCE_ID and empty parameters

createJobExecution

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

Returns:
a JobExecution with id=DEFAULT_JOB_EXECUTION_ID

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=DEFAULT_STEP_EXECUTION_ID

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

createStepExecution

public static StepExecution createStepExecution(JobParameters jobParameters,
                                                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 StepExecution createStepExecution(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 StepExecution createStepExecution(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


Copyright © 2013 SpringSource. All Rights Reserved.