BATCH-1654: fix StepExecution equals and hashcode

This commit is contained in:
Dave Syer
2010-11-18 12:08:48 +00:00
parent 01f91f166b
commit b4cdc4ab9f
2 changed files with 19 additions and 5 deletions

View File

@@ -188,6 +188,14 @@ public class StepExecutionTests {
assertEquals("bar", execution.getExecutionContext().getString("foo"));
}
@Test
public void testEqualsWithSameName() throws Exception {
Step step = new StepSupport("stepName");
Entity stepExecution1 = newStepExecution(step,11L,4L);
Entity stepExecution2 = newStepExecution(step,11L,5L);
assertFalse(stepExecution1.equals(stepExecution2));
}
@Test
public void testEqualsWithSameIdentifier() throws Exception {
Step step = new StepSupport("stepName");
@@ -291,9 +299,13 @@ public class StepExecutionTests {
assertEquals(BatchStatus.FAILED, execution.getStatus());
}
private StepExecution newStepExecution(Step step, Long long2) {
JobInstance job = new JobInstance(new Long(3), new JobParameters(), "testJob");
StepExecution execution = new StepExecution(step.getName(), new JobExecution(job, long2), new Long(4));
private StepExecution newStepExecution(Step step, Long jobExecutionId) {
return newStepExecution(step, jobExecutionId, 4);
}
private StepExecution newStepExecution(Step step, Long jobExecutionId, long stepExecutionId) {
JobInstance job = new JobInstance(3L, new JobParameters(), "testJob");
StepExecution execution = new StepExecution(step.getName(), new JobExecution(job, jobExecutionId), stepExecutionId);
return execution;
}