Use id instead of name to locate existing step execution (more uniform interface).

This commit is contained in:
dsyer
2009-01-03 10:16:59 +00:00
parent 71ec0a602e
commit c668a1f5db
10 changed files with 72 additions and 67 deletions

View File

@@ -86,10 +86,10 @@ public class SimpleJobExplorerTests extends TestCase {
@Test
public void testGetStepExecution() throws Exception {
expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
expect(stepExecutionDao.getStepExecution(jobExecution, "foo")).andReturn(null);
expect(stepExecutionDao.getStepExecution(jobExecution, 123L)).andReturn(null);
expect(stepExecutionDao.getStepExecutions(jobExecution)).andReturn(null);
replay(jobExecutionDao, stepExecutionDao);
jobExplorer.getStepExecution(123L,"foo");
jobExplorer.getStepExecution(jobExecution.getId(), 123L);
verify(jobExecutionDao, stepExecutionDao);
}

View File

@@ -104,7 +104,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
stepExecution.setWriteCount(13);
dao.saveStepExecution(stepExecution);
StepExecution retrieved = dao.getStepExecution(jobExecution, step.getName());
StepExecution retrieved = dao.getStepExecution(jobExecution, stepExecution.getId());
assertStepExecutionsAreEqual(stepExecution, retrieved);
assertNotNull(retrieved.getVersion());
@@ -118,7 +118,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
@Transactional
@Test
public void testSaveAndGetNonExistentExecution() {
assertNull(dao.getStepExecution(jobExecution, "not-existing step"));
assertNull(dao.getStepExecution(jobExecution, 45677L));
}
@Transactional
@@ -138,7 +138,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
@Transactional
@Test
public void testGetForNotExistingJobExecution() {
assertNull(dao.getStepExecution(new JobExecution(jobInstance, (long) 777), step.getName()));
assertNull(dao.getStepExecution(new JobExecution(jobInstance, (long) 777), 11L));
}
/**
@@ -189,7 +189,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
dao.updateStepExecution(stepExecution);
assertEquals(versionAfterSave + 1, stepExecution.getVersion().intValue());
StepExecution retrieved = dao.getStepExecution(jobExecution, step.getName());
StepExecution retrieved = dao.getStepExecution(jobExecution, stepExecution.getId());
assertEquals(stepExecution, retrieved);
assertEquals(stepExecution.getLastUpdated(), retrieved.getLastUpdated());
assertEquals(BatchStatus.STOPPED, retrieved.getStatus());

View File

@@ -44,14 +44,14 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
((JdbcStepExecutionDao) dao).setExitMessageLength(250);
dao.saveStepExecution(stepExecution);
StepExecution retrievedAfterSave = dao.getStepExecution(jobExecution, step.getName());
StepExecution retrievedAfterSave = dao.getStepExecution(jobExecution, stepExecution.getId());
assertTrue("Exit description should be truncated", retrievedAfterSave.getExitStatus().getExitDescription()
.length() < stepExecution.getExitStatus().getExitDescription().length());
dao.updateStepExecution(stepExecution);
StepExecution retrievedAfterUpdate = dao.getStepExecution(jobExecution, step.getName());
StepExecution retrievedAfterUpdate = dao.getStepExecution(jobExecution, stepExecution.getId());
assertTrue("Exit description should be truncated", retrievedAfterUpdate.getExitStatus().getExitDescription()
.length() < stepExecution.getExitStatus().getExitDescription().length());

View File

@@ -1,16 +1,16 @@
package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNull;
import java.util.Date;
import org.junit.Test;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.internal.runners.JUnit4ClassRunner;
@RunWith(JUnit4ClassRunner.class)
public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
@@ -40,14 +40,14 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
tested.saveStepExecution(stepExecution);
stepExecution.setEndTime(new Date());
StepExecution retrieved = tested.getStepExecution(jobExecution, "stepName");
StepExecution retrieved = tested.getStepExecution(jobExecution, stepExecution.getId());
assertNull(retrieved.getEndTime());
stepExecution.setEndTime(null);
tested.updateStepExecution(stepExecution);
stepExecution.setEndTime(new Date());
StepExecution stored = tested.getStepExecution(jobExecution, "stepName");
StepExecution stored = tested.getStepExecution(jobExecution, stepExecution.getId());
assertNull(stored.getEndTime());
}