Unable to Test Launching Steps of a FlowJob when it is created using Java Config [BATCH-2291]
Faisal Feroz opened BATCH-2291 and commented
JobLauncherTestUtils uses the following code to locate the step in a job
StepLocator locator = (StepLocator) this.job;
Step step = locator.getStep(stepName);
if (step == null) {
step = locator.getStep(this.job.getName() + "." + stepName);
}
This isn't able to find the step if the Flow Job is created using java config using jobBuilders.
The issue is that the builder creates a SimpleFlow object inside who's afterPropertiesSet is never fired which calls initializeTransitions which is responsible for populating all the states in the state map. The issue never appears when the job is executed because the same method is fired in start method of the flow (which populates all the data structures etc.) but in case of launching a step using JobLauncherTestUtils it is trying to find the step the respective stateMaps etc. are never populated which results in the following exception every time:
java.lang.IllegalStateException: No Step found with name: [categoryClassificationStep]
at org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:237)
at org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:187)
at com.etilize.sde.core.category.CategoryClassificationStepTest.shouldClassifyAndPersistProduct(CategoryClassificationStepTest.java:18)
Affects: 3.0.1
Referenced from: commits https://github.com/spring-projects/spring-batch/commit/930177ec34618c73578d79d06e181a1962005da1, https://github.com/spring-projects/spring-batch/commit/f865eb0135f13675abaf4dcef5360d50916f1d6c
I am encountering this same issue. Was a resolution determined? If so, how do we use it?