@Override public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); stepExecutionDao.updateStepExecution(stepExecution); checkForInterruption(stepExecution); }
/** * Long exit descriptions are truncated on both save and update. */ @Transactional @Test public void testTruncateExitDescription() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 100; i++) { sb.append("too long exit description"); } String longDescription = sb.toString(); ExitStatus exitStatus = ExitStatus.FAILED.addExitDescription(longDescription); stepExecution.setExitStatus(exitStatus); ((JdbcStepExecutionDao) dao).setExitMessageLength(250); dao.saveStepExecution(stepExecution); 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, stepExecution.getId()); assertTrue("Exit description should be truncated", retrievedAfterUpdate.getExitStatus().getExitDescription() .length() < stepExecution.getExitStatus().getExitDescription().length()); }
/** * Exception should be raised when the version of update argument doesn't * match the version of persisted entity. */ @Transactional @Test public void testConcurrentModificationException() { step = new StepSupport("foo"); StepExecution exec1 = new StepExecution(step.getName(), jobExecution); dao.saveStepExecution(exec1); StepExecution exec2 = new StepExecution(step.getName(), jobExecution); exec2.setId(exec1.getId()); exec2.incrementVersion(); assertEquals(new Integer(0), exec1.getVersion()); assertEquals(exec1.getVersion(), exec2.getVersion()); dao.updateStepExecution(exec1); assertEquals(new Integer(1), exec1.getVersion()); try { dao.updateStepExecution(exec2); fail(); } catch (OptimisticLockingFailureException e) { // expected } }
/** * Update and retrieve updated StepExecution - make sure the update is * reflected as expected and version number has been incremented */ @Transactional @Test public void testUpdateExecution() { stepExecution.setStatus(BatchStatus.STARTED); dao.saveStepExecution(stepExecution); Integer versionAfterSave = stepExecution.getVersion(); stepExecution.setStatus(BatchStatus.ABANDONED); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); dao.updateStepExecution(stepExecution); assertEquals(versionAfterSave + 1, stepExecution.getVersion().intValue()); StepExecution retrieved = dao.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution, retrieved); assertEquals(stepExecution.getLastUpdated(), retrieved.getLastUpdated()); assertEquals(BatchStatus.ABANDONED, retrieved.getStatus()); }
/** * Modifications to saved entity do not affect the persisted object. */ @Test public void testPersistentCopy() { StepExecutionDao tested = new MapStepExecutionDao(); JobExecution jobExecution = new JobExecution(77L); StepExecution stepExecution = new StepExecution("stepName", jobExecution); assertNull(stepExecution.getEndTime()); tested.saveStepExecution(stepExecution); stepExecution.setEndTime(new Date()); 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, stepExecution.getId()); assertNull(stored.getEndTime()); }
tested.updateStepExecution(repoStepExecution); StepExecution updatedStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution.getId(), updatedStepExecution.getId());
@Override public void updateExecutionContext(StepExecution stepExecution) { stepExecutionDao.updateStepExecution(stepExecution); }
@Override public void saveExecutionContext(StepExecution stepExecution) { stepExecution.incrementVersion(); stepExecutionDao.updateStepExecution(stepExecution); }
@Override public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); stepExecutionDao.updateStepExecution(stepExecution); checkForInterruption(stepExecution); }
@Override public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); stepExecutionDao.updateStepExecution(stepExecution); checkForInterruption(stepExecution); }
public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); stepExecutionDao.updateStepExecution(stepExecution); checkForInterruption(stepExecution); }
@Override public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); stepExecutionDao.updateStepExecution(stepExecution); checkForInterruption(stepExecution); }