BATCH-1053: Moved getStep() logic from AbstractJobTests to Job implementations. Added getStep(String) to AbstractJob. Added getState(String) to Flow.

This commit is contained in:
dhgarrette
2009-02-02 15:04:20 +00:00
parent 0edb22e4b8
commit ee11f65556
8 changed files with 85 additions and 88 deletions

View File

@@ -25,6 +25,7 @@ import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
@@ -170,6 +171,11 @@ public class AbstractJobTests {
return null;
}
@Override
public Step getStep(String stepName) {
return null;
}
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.core.job.flow.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -203,6 +204,24 @@ public class SimpleFlowTests {
assertEquals(FlowExecution.COMPLETED, execution.getStatus());
assertEquals("step3", execution.getName());
}
@Test
public void testGetStateExists() throws Exception {
flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState(
"step1"))));
flow.afterPropertiesSet();
State state = flow.getState("step1");
assertNotNull(state);
assertEquals("step1", state.getName());
}
@Test(expected = IllegalArgumentException.class)
public void testGetStateDoesNotExist() throws Exception {
flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState(
"step1"))));
flow.afterPropertiesSet();
flow.getState("bar");
}
private List<StateTransition> collect(StateTransition s1, StateTransition s2) {
List<StateTransition> list = new ArrayList<StateTransition>();