Refine contribution #3932
* Add default methods in interfaces * Update tests/Javadoc * Optimize imports * Apply code style formatting
This commit is contained in:
@@ -95,14 +95,17 @@ public interface JobExplorer {
|
||||
JobInstance getJobInstance(@Nullable Long instanceId);
|
||||
|
||||
/**
|
||||
* @param jobName {@link String} name for the jobInstance.
|
||||
* @param jobParameters {@link JobParameters} parameters for the jobInstance.
|
||||
* @return the {@link JobInstance} with this name and parameters, or null
|
||||
* @param jobName {@link String} name of the job.
|
||||
* @param jobParameters {@link JobParameters} parameters for the job instance.
|
||||
* @return the {@link JobInstance} with the given name and parameters, or
|
||||
* {@code null}.
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
JobInstance getJobInstance(String jobName, JobParameters jobParameters);
|
||||
default JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve job executions by their job instance. The corresponding step executions
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.util.Set;
|
||||
* @author Will Schipp
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Parikshit Dutta
|
||||
*
|
||||
* @see JobExplorer
|
||||
* @see JobInstanceDao
|
||||
* @see JobExecutionDao
|
||||
@@ -191,8 +190,7 @@ public class SimpleJobExplorer implements JobExplorer {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.batch.core.explore.JobExplorer#getJobInstance(java
|
||||
* @see org.springframework.batch.core.explore.JobExplorer#getJobInstance(java
|
||||
* .lang.String, org.springframework.batch.core.JobParameters)
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -188,14 +188,17 @@ public interface JobRepository {
|
||||
void updateExecutionContext(JobExecution jobExecution);
|
||||
|
||||
/**
|
||||
* @param jobName {@link String} the name of the jobInstance
|
||||
* @param jobParameters {@link JobParameters} parameters identifying the {@link JobInstance}
|
||||
* @return the {@link JobInstance} with name and parameters, or null
|
||||
* @param jobName {@link String} name of the job.
|
||||
* @param jobParameters {@link JobParameters} parameters for the job instance.
|
||||
* @return the {@link JobInstance} with the given name and parameters, or
|
||||
* {@code null}.
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
JobInstance getJobInstance(String jobName, JobParameters jobParameters);
|
||||
default JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jobInstance {@link JobInstance} instance containing the step executions.
|
||||
|
||||
@@ -54,7 +54,6 @@ import java.util.List;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Baris Cubukcuoglu
|
||||
* @author Parikshit Dutta
|
||||
*
|
||||
* @see JobRepository
|
||||
* @see JobInstanceDao
|
||||
* @see JobExecutionDao
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.springframework.lang.Nullable;
|
||||
* @author David Turanski
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Parikshit Dutta
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public class DummyJobRepository implements JobRepository, BeanNameAware {
|
||||
|
||||
@@ -19,10 +19,6 @@ package org.springframework.batch.core.explore.support;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -155,11 +151,18 @@ class SimpleJobExplorerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobInstanceWithNameAndParameters() throws Exception {
|
||||
when(jobInstanceDao.getJobInstance("job", new JobParameters())).thenReturn(jobInstance);
|
||||
JobInstance jobInstance = jobExplorer.getJobInstance("job", new JobParameters());
|
||||
verify(jobInstanceDao).getJobInstance(anyString(), any(JobParameters.class));
|
||||
assertEquals(jobInstance, jobInstance);
|
||||
public void testGetJobInstanceWithNameAndParameters() {
|
||||
// given
|
||||
String jobName = "job";
|
||||
JobParameters jobParameters = new JobParameters();
|
||||
|
||||
// when
|
||||
when(jobInstanceDao.getJobInstance(jobName, jobParameters)).thenReturn(this.jobInstance);
|
||||
JobInstance jobInstance = jobExplorer.getJobInstance(jobName, jobParameters);
|
||||
|
||||
// then
|
||||
verify(jobInstanceDao).getJobInstance(jobName, jobParameters);
|
||||
assertEquals(this.jobInstance, jobInstance);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,8 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -332,12 +330,19 @@ class SimpleJobRepositoryTests {
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetJobInstanceWithNameAndParameters() throws Exception {
|
||||
when(jobInstanceDao.getJobInstance("job", new JobParameters())).thenReturn(jobInstance);
|
||||
JobInstance jobInstance = jobRepository.getJobInstance("job", new JobParameters());
|
||||
verify(jobInstanceDao).getJobInstance(anyString(), any(JobParameters.class));
|
||||
assertEquals(jobInstance, jobInstance);
|
||||
public void testGetJobInstanceWithNameAndParameters() {
|
||||
// given
|
||||
String jobName = "job";
|
||||
JobParameters jobParameters = new JobParameters();
|
||||
|
||||
// when
|
||||
when(jobInstanceDao.getJobInstance(jobName, jobParameters)).thenReturn(this.jobInstance);
|
||||
JobInstance jobInstance = jobRepository.getJobInstance(jobName, jobParameters);
|
||||
|
||||
// then
|
||||
verify(jobInstanceDao).getJobInstance(jobName, jobParameters);
|
||||
assertEquals(this.jobInstance, jobInstance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,14 +48,17 @@ public class JobRepositorySupport implements JobRepository {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.repository.JobRepository#getJobInstance(java.lang.String,
|
||||
* org.springframework.batch.core.JobParameters)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.batch.core.repository.JobRepository#getJobInstance(java.lang.
|
||||
* String, org.springframework.batch.core.JobParameters)
|
||||
*/
|
||||
public JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.batch.core.repository.JobRepository#getLastStepExecution(org.
|
||||
|
||||
Reference in New Issue
Block a user