List of usage examples for org.springframework.batch.core JobExecution getStepExecutions
public Collection<StepExecution> getStepExecutions()
From source file:uk.ac.ebi.intact.editor.controller.admin.AdminJobController.java
public List<StepExecution> getStepExecutions(JobExecution jobExecution) { return new ArrayList<StepExecution>(jobExecution.getStepExecutions()); }
From source file:uk.ac.ebi.intact.editor.controller.admin.AdminJobController.java
public Map<String, String> getImportStatistics(JobExecution jobExecution) { Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions(); Map<String, String> statistics = new HashMap<String, String>(); if (!stepExecutions.isEmpty()) { StepExecution firstStep = stepExecutions.iterator().next(); ExecutionContext stepContext = firstStep.getExecutionContext(); for (Map.Entry<String, Object> entry : stepContext.entrySet()) { // persisted count if (entry.getKey().startsWith(AbstractIntactDbImporter.PERSIST_MAP_COUNT)) { statistics.put(entry.getKey().substring(entry.getKey().lastIndexOf("_") + 1), Integer.toString((Integer) entry.getValue())); }//from w ww . j a va 2 s . c o m } } return statistics; }
From source file:com.javaetmoi.core.batch.test.TestParallelAndPartitioning.java
private StepExecution getStepExecution(JobExecution jobExecution, String stepName) { StepExecution stepExecution = null;//from w w w. j av a 2 s . c om List<String> stepNames = new ArrayList<String>(); for (StepExecution candidate : jobExecution.getStepExecutions()) { String name = candidate.getStepName(); stepNames.add(name); if (name.equals(stepName)) { stepExecution = candidate; } } if (stepExecution == null) { throw new IllegalArgumentException( "No such step in this job execution: " + stepName + " not in " + stepNames); } return stepExecution; }
From source file:de.langmi.spring.batch.examples.basics.purejava.jobruns.PureJavaJobRunTest.java
/** * Running the simple Job with a simple setup. * * @throws Exception//from w w w .jav a 2 s. c om */ @Test public void testJobConfiguration() throws Exception { // creating the job Job job = PureJavaJobFactory.createJob(jobRepository, transactionManager); // running the job JobExecution execution = this.jobLauncher.run(job, new JobParameters()); // assertions assertEquals(BatchStatus.COMPLETED, execution.getStatus()); assertEquals(1, execution.getStepExecutions().size()); assertEquals("Hello World!", newSysOut.toString()); }
From source file:admin.jmx.SimpleJobExecutionMetrics.java
private StepExecution getLatestStepExecution(JobExecution jobExecution) { Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions(); StepExecution stepExecution = null;// ww w . j a v a 2s .com if (!stepExecutions.isEmpty()) { Date latest = new Date(0L); for (StepExecution candidate : stepExecutions) { Date stepDate = candidate.getEndTime(); stepDate = stepDate == null ? new Date() : stepDate; if (stepDate.after(latest)) { latest = stepDate; stepExecution = candidate; } else if (stepExecution != null && stepDate.equals(latest) && candidate.getId() > stepExecution.getId()) { // Tie breaker using ID stepExecution = candidate; } } } return stepExecution; }
From source file:org.cloudfoundry.identity.uaa.scim.job.BackwardMigrationJobIntegrationTests.java
@Test public void testJobRuns() throws Exception { TestUtils.deleteFrom(cloudControllerDataSource, "users"); TestUtils.deleteFrom(uaaDataSource, "users"); JdbcTemplate uaaTemplate = new JdbcTemplate(uaaDataSource); uaaTemplate.update(/* w w w .j a v a 2s. c om*/ "insert into users " + "(id, active, userName, email, password, familyName, givenName, created, lastModified) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)", "FOO", true, "uniqua", "uniqua@test.org", "ENCRYPT_ME", "Una", "Uniqua", new Date(), new Date()); JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addDate("start.date", new Date(0L)).toJobParameters()); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); Iterator<StepExecution> iterator = execution.getStepExecutions().iterator(); StepExecution step = iterator.next(); assertEquals(1, step.getReadCount()); assertEquals(1, step.getWriteCount()); JdbcTemplate jdbcTemplate = new JdbcTemplate(cloudControllerDataSource); assertEquals(1, jdbcTemplate.queryForInt("select count(*) from users")); }
From source file:org.cloudfoundry.identity.uaa.scim.job.ClearNamesJobIntegrationTests.java
@Test public void testJobRuns() throws Exception { TestUtils.deleteFrom(cloudControllerDataSource, "users"); TestUtils.deleteFrom(uaaDataSource, "users"); JdbcTemplate uaaTemplate = new JdbcTemplate(uaaDataSource); uaaTemplate.update(// ww w .j a v a 2 s .c o m "insert into users " + "(id, active, userName, email, password, familyName, givenName, created, lastModified) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)", "FOO", true, "uniqua", "uniqua@test.org", "ENCRYPT_ME", "Una", "Uniqua", new Date(), new Date()); uaaTemplate.update( "insert into users " + "(id, active, userName, email, password, familyName, givenName, created, lastModified) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)", "BAR", true, "username", "uniqua@test.org", "ENCRYPT_ME", "uniqua", "test.org", new Date(), new Date()); uaaTemplate.update( "insert into users " + "(id, active, userName, email, password, familyName, givenName, created, lastModified) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)", "SPAM", true, "another", "uniqua@test.org", "ENCRYPT_ME", "another", "another", new Date(), new Date()); JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addDate("start.date", new Date(0L)).toJobParameters()); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); Iterator<StepExecution> iterator = execution.getStepExecutions().iterator(); StepExecution step = iterator.next(); assertEquals(3, step.getReadCount()); assertEquals(2, step.getWriteCount()); assertEquals(2, uaaTemplate.queryForInt("select count(*) from users where givenName is null")); }
From source file:de.langmi.spring.batch.examples.listeners.fileoutput.FileOutputJobConfigurationTest.java
/** Launch Test. */ @Test/*from w ww . j a v a 2 s. com*/ public void launchJob() throws Exception { // Job parameters Map<String, JobParameter> jobParametersMap = new HashMap<String, JobParameter>(); jobParametersMap.put("time", new JobParameter(System.currentTimeMillis())); jobParametersMap.put("output.file", new JobParameter("file:target/test-outputs/file-output/output.txt")); // launch the job JobExecution jobExecution = jobLauncherTestUtils.launchJob(new JobParameters(jobParametersMap)); // assert job run status assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); // output step summaries for (StepExecution step : jobExecution.getStepExecutions()) { LOG.debug(step.getSummary()); assertTrue("Read Count mismatch.", step.getReadCount() == TestDataFactoryBean.COUNT); } }
From source file:de.langmi.spring.batch.examples.listeners.SimpleJobConfigurationTest.java
/** Launch Test. */ @Test//from ww w . ja v a2s . co m public void launchJob() throws Exception { // Job parameters Map<String, JobParameter> jobParametersMap = new HashMap<String, JobParameter>(); jobParametersMap.put("time", new JobParameter(System.currentTimeMillis())); jobParametersMap.put("output.file", new JobParameter("file:target/test-outputs/simple/output.txt")); // launch the job JobExecution jobExecution = jobLauncherTestUtils.launchJob(new JobParameters(jobParametersMap)); // assert job run status assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); // output step summaries for (StepExecution step : jobExecution.getStepExecutions()) { LOG.debug(step.getSummary()); assertTrue("Read Count mismatch.", step.getReadCount() == TestDataFactoryBean.COUNT); } }
From source file:org.cloudfoundry.identity.uaa.scim.job.UserSyncJobIntegrationTests.java
@Test public void testJobRunsWithFilters() throws Exception { Date dateInTheFuture = new Date(System.currentTimeMillis() + 10000); setUpModifiedUaaData(dateInTheFuture); JobExecution execution = jobLauncher.run(job, new JobParametersBuilder() .addDate("start.date", new Date(System.currentTimeMillis() - 100000)).toJobParameters()); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); StepExecution stepExecution = execution.getStepExecutions().iterator().next(); assertEquals(3, stepExecution.getReadCount()); assertEquals(3, stepExecution.getFilterCount()); assertEquals(0, stepExecution.getWriteCount()); }