-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
122 additions
and
0 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
...tch-redis-infrastructure/src/test/java/com/redis/spring/batch/common/JobFactoryTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package com.redis.spring.batch.common; | ||
|
||
import java.util.Collection; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.batch.core.JobExecution; | ||
import org.springframework.batch.core.JobExecutionException; | ||
import org.springframework.batch.core.JobInstance; | ||
import org.springframework.batch.core.JobParameters; | ||
import org.springframework.batch.core.StepExecution; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
import org.springframework.batch.core.launch.support.SimpleJobLauncher; | ||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; | ||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; | ||
import org.springframework.batch.core.repository.JobRepository; | ||
import org.springframework.batch.core.repository.JobRestartException; | ||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager; | ||
|
||
class JobFactoryTests { | ||
|
||
@Test | ||
void testCheckExecution() throws JobExecutionException { | ||
JobExecution jobExecution = new JobExecution(10L); | ||
Assertions.assertEquals(10L, JobFactory.checkJobExecution(jobExecution).getId()); | ||
} | ||
|
||
private class SimpleJobRepository implements JobRepository { | ||
|
||
@Override | ||
public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
|
||
@Override | ||
public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public JobExecution createJobExecution(String jobName, JobParameters jobParameters) | ||
throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public void update(JobExecution jobExecution) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void add(StepExecution stepExecution) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void addAll(Collection<StepExecution> stepExecutions) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void update(StepExecution stepExecution) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void updateExecutionContext(StepExecution stepExecution) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void updateExecutionContext(JobExecution jobExecution) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public long getStepExecutionCount(JobInstance jobInstance, String stepName) { | ||
// TODO Auto-generated method stub | ||
return 0; | ||
} | ||
|
||
@Override | ||
public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} | ||
|
||
@Test | ||
void testSetters() { | ||
JobFactory factory = new JobFactory(); | ||
JobLauncher launcher = new SimpleJobLauncher(); | ||
SimpleJobRepository repository = new SimpleJobRepository(); | ||
String name = "name"; | ||
ResourcelessTransactionManager transactionManager = new ResourcelessTransactionManager(); | ||
factory.setJobLauncher(launcher); | ||
factory.setJobRepository(repository); | ||
factory.setName(name); | ||
factory.setPlatformTransactionManager(transactionManager); | ||
Assertions.assertEquals(name, factory.getName()); | ||
Assertions.assertEquals(repository, factory.getJobRepository()); | ||
Assertions.assertEquals(launcher, factory.getJobLauncher()); | ||
Assertions.assertEquals(transactionManager, factory.getPlatformTransactionManager()); | ||
} | ||
|
||
} |