Skip to content

Commit

Permalink
Merge pull request #8 from WiredNerd/spring-boot-2-5
Browse files Browse the repository at this point in the history
Compatible with spring-data-mongodb:3.2.8 (spring boot 2.5)
  • Loading branch information
WiredNerd committed Feb 15, 2022
2 parents 257a17d + 0dc3234 commit 5512b2f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=io.github.wirednerd
version=1.0.0
version=1.0.1
2 changes: 1 addition & 1 deletion spring-batch-mongo-example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.6.3'
id 'org.springframework.boot' version '2.5.9'
id "io.freefair.lombok" version "6.4.0"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ spring:
data:
mongodb:
uri: mongodb://localhost:27017/?replicaSet=rs0
database: Test
database: test
batch:
job:
enabled: false
Expand Down
4 changes: 2 additions & 2 deletions spring-batch-mongo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'java'
id 'java-library'
id "io.freefair.lombok" version "6.4.0"
// id 'jacoco'
id 'pmd'
Expand All @@ -19,7 +19,7 @@ repositories {

dependencies {
implementation 'org.springframework.batch:spring-batch-core:4.3.4'
implementation 'org.springframework.data:spring-data-mongodb:3.3.1'
implementation 'org.springframework.data:spring-data-mongodb:3.2.8'
implementation 'org.netbeans.api:org-netbeans-api-annotations-common:RELEASE126'

testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public JobExecution getLastJobExecution(JobInstance jobInstance) {
public Set<JobExecution> findRunningJobExecutions(String jobName) {
return mongoTemplate.find(Query.query(Criteria.where(JOB_NAME).is(jobName))
.addCriteria(Criteria.where(START_TIME).ne(null))
.addCriteria(Criteria.where(END_TIME).isNull())
.addCriteria(Criteria.where(END_TIME).is(null))
.with(Sort.by(JOB_EXECUTION_ID).descending()),
Document.class, jobCollectionName)
.stream().map(JobExecutionConverter::convert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private JobExecution insertNewJobExecution(JobExecution jobExecution) {
mongoTemplate.upsert(new Query()
.addCriteria(Criteria.where(JOB_NAME).is(jobExecution.getJobInstance().getJobName()))
.addCriteria(Criteria.where(JOB_KEY).is(jobKeyGenerator.generateKey(jobExecution.getJobParameters())))
.addCriteria(Criteria.where(JOB_EXECUTION_ID).isNull()),
.addCriteria(Criteria.where(JOB_EXECUTION_ID).is(null)),
Update.fromDocument(JobExecutionConverter.convert(jobExecution)), jobCollectionName);

return jobExecution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ void createJobExecutionWithConfigName() {
void createJobExecutionWithConfigName_replaceJobInstance() {
var jobInstance = repository.createJobInstance("New Job", jobExecution.getJobParameters());

assertEquals(1, mongoTemplate.find(new Query(Criteria.where("jobInstanceId").is(jobInstance.getId())).addCriteria(Criteria.where(JOB_EXECUTION_ID).isNull()), Document.class, jobCollectionName).size());
assertEquals(1, mongoTemplate.find(new Query(Criteria.where("jobInstanceId").is(jobInstance.getId())).addCriteria(Criteria.where(JOB_EXECUTION_ID).is(null)), Document.class, jobCollectionName).size());
assertEquals(0, mongoTemplate.find(new Query(Criteria.where("jobInstanceId").is(jobInstance.getId())).addCriteria(Criteria.where(JOB_EXECUTION_ID).gte(0L)), Document.class, jobCollectionName).size());

var jobExecution = repository.createJobExecution(jobInstance, this.jobExecution.getJobParameters(), this.jobExecution.getJobConfigurationName());

assertEquals(0, mongoTemplate.find(new Query(Criteria.where("jobInstanceId").is(jobInstance.getId())).addCriteria(Criteria.where(JOB_EXECUTION_ID).isNull()), Document.class, jobCollectionName).size());
assertEquals(0, mongoTemplate.find(new Query(Criteria.where("jobInstanceId").is(jobInstance.getId())).addCriteria(Criteria.where(JOB_EXECUTION_ID).is(null)), Document.class, jobCollectionName).size());
assertEquals(1, mongoTemplate.find(new Query(Criteria.where("jobInstanceId").is(jobInstance.getId())).addCriteria(Criteria.where(JOB_EXECUTION_ID).is(jobExecution.getId())), Document.class, jobCollectionName).size());
}

Expand Down

0 comments on commit 5512b2f

Please sign in to comment.