From 8b015302c17d967ff492a7faf0121c586a166db8 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 15 May 2026 13:29:31 +0900 Subject: [PATCH 01/45] Bump versions for Spring Batch 6.0.3 support Signed-off-by: Taeik Lim --- gradle/libs.versions.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 487983a..973ea98 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -spring-boot = "3.4.0" -spring-batch = "5.2.0" +spring-boot = "4.0.5" +spring-batch = "6.0.3" # spring-jdbc version should follow minor version described in 'spring-framework.version' # https://github.com/spring-projects/spring-batch/blob/main/pom.xml -spring-jdbc = "6.2.0" +spring-jdbc = "7.0.6" slf4j = "2.0.17" -reactor-core = "3.5.0" +reactor-core = "3.8.4" findbugs-jsr305 = "3.0.2" # test-only From 40aeadf7af92183df19956379a5a806175d7c572 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 15 May 2026 13:52:11 +0900 Subject: [PATCH 02/45] Migrate Java module imports for Spring Batch 6.0.3 Signed-off-by: Taeik Lim --- ...StreamReaderProcessorWriterIntegrationTest.java | 14 +++++++------- .../ItemStreamReaderWriterIntegrationTest.java | 14 +++++++------- .../adapter/ItemStreamFluxReaderProcessorIT.java | 12 ++++++------ .../ItemStreamFluxReaderProcessorWriterIT.java | 14 +++++++------- .../step/adapter/ItemStreamFluxReaderWriterIT.java | 14 +++++++------- .../ItemStreamIterableReaderProcessorIT.java | 12 ++++++------ .../ItemStreamIterableReaderProcessorWriterIT.java | 14 +++++++------- .../adapter/ItemStreamIterableReaderWriterIT.java | 14 +++++++------- .../ItemStreamIteratorReaderProcessorIT.java | 12 ++++++------ .../ItemStreamIteratorReaderProcessorWriterIT.java | 14 +++++++------- .../adapter/ItemStreamIteratorReaderWriterIT.java | 14 +++++++------- .../adapter/ItemStreamSimpleReaderProcessorIT.java | 12 ++++++------ .../ItemStreamSimpleReaderProcessorWriterIT.java | 14 +++++++------- .../adapter/ItemStreamSimpleReaderWriterIT.java | 14 +++++++------- .../batch/plus/item/adapter/AdapterFactory.java | 6 +++--- .../plus/item/adapter/ItemProcessorAdapter.java | 2 +- .../plus/item/adapter/ItemProcessorDelegate.java | 2 +- .../plus/item/adapter/ItemStreamReaderAdapter.java | 4 ++-- .../item/adapter/ItemStreamReaderDelegate.java | 4 ++-- .../adapter/ItemStreamReaderProcessorWriter.java | 6 +++--- .../plus/item/adapter/ItemStreamReaderWriter.java | 4 ++-- .../plus/item/adapter/ItemStreamWriterAdapter.java | 6 +++--- .../item/adapter/ItemStreamWriterDelegate.java | 6 +++--- .../item/adapter/StepScopeItemStreamReader.java | 6 +++--- .../batch/plus/job/ClearRunIdIncrementer.java | 8 ++++---- .../CheckMaxJobInstanceIdToDeleteTasklet.java | 12 ++++++------ .../job/metadata/DeleteMetadataJobBuilder.java | 8 ++++---- .../plus/job/metadata/DeleteMetadataTasklet.java | 12 ++++++------ .../batch/plus/step/adapter/AdapterFactory.java | 6 +++--- .../plus/step/adapter/ItemProcessorAdapter.java | 2 +- .../plus/step/adapter/ItemProcessorDelegate.java | 2 +- .../step/adapter/ItemStreamFluxReaderAdapter.java | 4 ++-- .../step/adapter/ItemStreamFluxReaderDelegate.java | 4 ++-- .../adapter/ItemStreamFluxReaderProcessor.java | 4 ++-- .../ItemStreamFluxReaderProcessorWriter.java | 6 +++--- .../step/adapter/ItemStreamFluxReaderWriter.java | 4 ++-- .../adapter/ItemStreamIterableReaderAdapter.java | 4 ++-- .../adapter/ItemStreamIterableReaderDelegate.java | 4 ++-- .../adapter/ItemStreamIterableReaderProcessor.java | 4 ++-- .../ItemStreamIterableReaderProcessorWriter.java | 6 +++--- .../adapter/ItemStreamIterableReaderWriter.java | 4 ++-- .../adapter/ItemStreamIteratorReaderAdapter.java | 4 ++-- .../adapter/ItemStreamIteratorReaderDelegate.java | 4 ++-- .../adapter/ItemStreamIteratorReaderProcessor.java | 4 ++-- .../ItemStreamIteratorReaderProcessorWriter.java | 6 +++--- .../adapter/ItemStreamIteratorReaderWriter.java | 4 ++-- .../adapter/ItemStreamSimpleReaderAdapter.java | 4 ++-- .../adapter/ItemStreamSimpleReaderDelegate.java | 6 +++--- .../adapter/ItemStreamSimpleReaderProcessor.java | 4 ++-- .../ItemStreamSimpleReaderProcessorWriter.java | 6 +++--- .../step/adapter/ItemStreamSimpleReaderWriter.java | 4 ++-- .../plus/step/adapter/ItemStreamWriterAdapter.java | 6 +++--- .../step/adapter/ItemStreamWriterDelegate.java | 6 +++--- .../step/adapter/StepScopeItemStreamReader.java | 6 +++--- .../plus/item/adapter/AdapterFactoryTest.java | 6 +++--- .../item/adapter/ItemProcessorAdapterTest.java | 2 +- .../item/adapter/ItemStreamReaderAdapterTest.java | 4 ++-- .../item/adapter/ItemStreamWriterAdapterTest.java | 6 +++--- .../adapter/StepScopeItemStreamReaderTest.java | 6 +++--- .../batch/plus/job/ClearRunIdIncrementerTest.java | 6 +++--- .../CheckMaxJobInstanceIdToDeleteTaskletTest.java | 14 +++++++------- .../job/metadata/DeleteMetadataJobBuilderTest.java | 8 ++++---- .../plus/job/metadata/DeleteMetadataJobTest.java | 14 +++++++------- .../job/metadata/DeleteMetadataTaskletTest.java | 14 +++++++------- .../plus/job/metadata/JobMetadataDaoTest.java | 6 +++--- .../plus/job/metadata/MetadataTestSupports.java | 4 ++-- .../plus/step/adapter/AdapterFactoryTest.java | 6 +++--- .../step/adapter/ItemProcessorAdapterTest.java | 2 +- .../adapter/ItemStreamFluxReaderAdapterTest.java | 4 ++-- .../ItemStreamIterableReaderAdapterTest.java | 4 ++-- .../ItemStreamIteratorReaderAdapterTest.java | 4 ++-- .../adapter/ItemStreamSimpleReaderAdapterTest.java | 4 ++-- .../step/adapter/ItemStreamWriterAdapterTest.java | 6 +++--- .../adapter/StepScopeItemStreamReaderTest.java | 6 +++--- 74 files changed, 259 insertions(+), 259 deletions(-) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java index 48dd63b..638888a 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java @@ -30,19 +30,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java index 33411f2..68c23d4 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java @@ -30,19 +30,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java index cdd2480..1b024ca 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java @@ -31,18 +31,18 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java index 8d1a768..1bcc0f8 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java @@ -32,19 +32,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java index ecd4804..30da241 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java @@ -31,19 +31,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java index 23e0760..299a677 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java @@ -32,18 +32,18 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java index 91d8348..140a6da 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java @@ -33,19 +33,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java index fd5f062..e9b585f 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java @@ -32,19 +32,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java index 8193f12..cfa985c 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java @@ -32,18 +32,18 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java index 3432998..787e84c 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java @@ -33,19 +33,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java index 8058a92..b7c08df 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java @@ -32,19 +32,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java index 16ee812..1986616 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java @@ -31,18 +31,18 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java index 5981602..2398e5e 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java @@ -32,19 +32,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java index 8ef4948..9440aa6 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java @@ -31,19 +31,19 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java index 09cb711..bd80914 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java @@ -21,9 +21,9 @@ import java.util.Objects; import org.springframework.batch.core.scope.StepScope; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import org.springframework.lang.NonNull; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderDelegate; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java index cc240bf..aab8bdd 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java @@ -20,7 +20,7 @@ import java.util.Objects; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java index 73e3d5b..17155ac 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.item.adapter; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java index 784fc34..0f60384 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java @@ -21,8 +21,8 @@ import java.util.Iterator; import java.util.Objects; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java index 3774633..f72b3fc 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.item.adapter; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriter.java index 563fc08..daf2fa5 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriter.java @@ -18,9 +18,9 @@ package com.navercorp.spring.batch.plus.item.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderProcessorWriter; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriter.java index 21e7c10..9e2d2b8 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriter.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.item.adapter; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderWriter; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java index 3a29ab9..63ac669 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java @@ -20,9 +20,9 @@ import java.util.Objects; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java index 381a7f0..3a16e4f 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java @@ -18,9 +18,9 @@ package com.navercorp.spring.batch.plus.item.adapter; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReader.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReader.java index e671a17..2288810 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReader.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReader.java @@ -27,9 +27,9 @@ import org.springframework.batch.core.scope.StepScope; import org.springframework.batch.core.scope.context.StepContext; import org.springframework.batch.core.scope.context.StepSynchronizationManager; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamException; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamException; +import org.springframework.batch.infrastructure.item.ItemStreamReader; /** * A {@link StepScope} bound proxy implementation. diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java index 9a53742..1429f7a 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java @@ -21,10 +21,10 @@ import java.util.Objects; import java.util.Optional; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.JobParametersIncrementer; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.job.parameters.JobParametersIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java index 8b0eb11..6895f9b 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java @@ -27,15 +27,15 @@ import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.StepExecutionListener; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.core.listener.StepExecutionListener; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.scope.context.StepContext; import org.springframework.batch.core.step.tasklet.Tasklet; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; /** * A tasklet to check metadata of job instances to delete. diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java index 7172045..35b6566 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java @@ -23,14 +23,14 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.Step; -import org.springframework.batch.core.job.DefaultJobParametersValidator; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.step.Step; +import org.springframework.batch.core.job.parameters.DefaultJobParametersValidator; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.lang.NonNull; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java index 0ceb253..f6fe67c 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java @@ -22,14 +22,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.StepExecutionListener; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.core.listener.StepExecutionListener; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; /** * A tasklet to delete metadata of Spring Batch. diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java index d861862..8c104b9 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java @@ -21,9 +21,9 @@ import java.util.Objects; import org.springframework.batch.core.scope.StepScope; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java index 96f3701..e83b515 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java @@ -20,7 +20,7 @@ import java.util.Objects; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java index 6b0934a..5164428 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java index 373612a..1fb3d09 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java @@ -22,8 +22,8 @@ import java.util.Objects; import java.util.Optional; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java index c135796..d0cb5a3 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessor.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessor.java index b09d481..318848a 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessor.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessor.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriter.java index dc49d93..a56b36e 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriter.java @@ -18,9 +18,9 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriter.java index 0c964df..5763d14 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriter.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java index 253a1f4..44b34b5 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java @@ -22,8 +22,8 @@ import java.util.Objects; import java.util.Optional; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java index b003905..f5d545e 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessor.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessor.java index 3dbf137..4a3d269 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessor.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessor.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; /** * An {@link Iterable} based adapter for stream reader, processor. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriter.java index 6f01e26..5d9f24e 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriter.java @@ -18,9 +18,9 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** * An {@link Iterable} based adapter for stream reader, processor, writer. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriter.java index 5bd932e..4fe7524 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriter.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** * An {@link Iterable} based adapter for stream reader, writer. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java index 803f9f8..b2b10c5 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java @@ -21,8 +21,8 @@ import java.util.Iterator; import java.util.Objects; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java index 056a8cc..8c2e19e 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java @@ -20,8 +20,8 @@ import java.util.Iterator; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessor.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessor.java index c64969c..9c99dcc 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessor.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessor.java @@ -20,8 +20,8 @@ import java.util.Iterator; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; /** * An {@link Iterator} based adapter for stream reader, processor. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriter.java index f03e7e1..dfb5441 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriter.java @@ -20,9 +20,9 @@ import java.util.Iterator; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** * An {@link Iterator} based adapter for stream reader, processor, writer. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriter.java index 8d383a0..a41b4df 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriter.java @@ -20,8 +20,8 @@ import java.util.Iterator; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** * An {@link Iterator} based adapter for stream reader, writer. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java index b3378d3..a4b7d8f 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java @@ -20,8 +20,8 @@ import java.util.Objects; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java index 92727bb..ea92042 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; @@ -41,7 +41,7 @@ default void onOpenRead(@NonNull ExecutionContext executionContext) { /** * Read each item. * @return an item to read. null if it's end of data. - * Return contract is same as {@link org.springframework.batch.item.ItemReader} + * Return contract is same as {@link org.springframework.batch.infrastructure.item.ItemReader} */ @Nullable T read(); diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessor.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessor.java index c0f9461..d569d4e 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessor.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessor.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; /** * An item ({@link I}) based adapter for stream reader, processor. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriter.java index 4523bba..11bc86f 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriter.java @@ -18,9 +18,9 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** * An item ({@link I}) based adapter for stream reader, processor, writer. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriter.java index 3dc0916..2696e88 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriter.java @@ -18,8 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** * An item ({@link T}) based adapter for stream reader, writer. It can represent diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java index 89e72bc..74d2f88 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java @@ -20,9 +20,9 @@ import java.util.Objects; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java index 12880be..996b57b 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java @@ -18,9 +18,9 @@ package com.navercorp.spring.batch.plus.step.adapter; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java index b50c31b..b52e5fa 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java @@ -27,9 +27,9 @@ import org.springframework.batch.core.scope.StepScope; import org.springframework.batch.core.scope.context.StepContext; import org.springframework.batch.core.scope.context.StepSynchronizationManager; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamException; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamException; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.lang.NonNull; /** diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactoryTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactoryTest.java index 85be5db..08f5953 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactoryTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactoryTest.java @@ -22,9 +22,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapterTest.java index 2dc64e0..71f5a1d 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapterTest.java @@ -27,7 +27,7 @@ import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; // note: it's deprecated. Do not change it. @SuppressWarnings({"unchecked", "deprecation"}) diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapterTest.java index 3fd7685..36addb6 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapterTest.java @@ -30,8 +30,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapterTest.java index 90392b9..04672de 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapterTest.java @@ -25,9 +25,9 @@ import static org.mockito.Mockito.verify; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; // note: it's deprecated. Do not change it. @SuppressWarnings({"unchecked", "deprecation"}) diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReaderTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReaderTest.java index cb6cd78..8a8e67b 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReaderTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/item/adapter/StepScopeItemStreamReaderTest.java @@ -29,9 +29,9 @@ import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.batch.test.MetaDataInstanceFactory; import org.springframework.batch.test.StepScopeTestUtils; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerTest.java index 07cc0a0..df5880f 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerTest.java @@ -25,9 +25,9 @@ import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.JobParametersIncrementer; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.job.parameters.JobParametersIncrementer; class ClearRunIdIncrementerTest { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java index 34513d5..a75a7ba 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java @@ -29,16 +29,16 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.scope.context.StepContext; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.batch.test.MetaDataInstanceFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java index 20bc07b..b01f230 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java @@ -28,10 +28,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.jdbc.BadSqlGrammarException; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java index 7c19b89..bcd1c1a 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java @@ -30,12 +30,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.JobParametersInvalidException; -import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.job.parameters.InvalidJobParametersException; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; @@ -83,7 +83,7 @@ void testRunFailWithInvalidParameter() { .toJobParameters(); // when, then - assertThatExceptionOfType(JobParametersInvalidException.class) + assertThatExceptionOfType(InvalidJobParametersException.class) .isThrownBy(() -> jobLauncher.run(job, jobParameters) ) diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java index ac6f8aa..eb8d034 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java @@ -28,16 +28,16 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.scope.context.StepContext; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.batch.test.MetaDataInstanceFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java index 03e497b..e530f01 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java @@ -28,9 +28,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java index 9650004..be5d27c 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java @@ -23,8 +23,8 @@ import java.time.LocalDateTime; import java.util.concurrent.ThreadLocalRandom; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; class MetadataTestSupports { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactoryTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactoryTest.java index 2cf19dd..f48cb4c 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactoryTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactoryTest.java @@ -25,9 +25,9 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemStreamReader; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapterTest.java index 2719cf5..ef5ef66 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapterTest.java @@ -27,7 +27,7 @@ import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; @SuppressWarnings("unchecked") class ItemProcessorAdapterTest { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapterTest.java index 03f8586..3508a95 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapterTest.java @@ -30,8 +30,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import reactor.core.publisher.Flux; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapterTest.java index f807a89..2ccaabf 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapterTest.java @@ -30,8 +30,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; @SuppressWarnings("unchecked") class ItemStreamIterableReaderAdapterTest { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapterTest.java index 286df35..87a737d 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapterTest.java @@ -30,8 +30,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; @SuppressWarnings("unchecked") class ItemStreamIteratorReaderAdapterTest { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapterTest.java index 57cb45a..ccd8798 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapterTest.java @@ -29,8 +29,8 @@ import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; @SuppressWarnings("unchecked") class ItemStreamSimpleReaderAdapterTest { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapterTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapterTest.java index 3282437..cb210af 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapterTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapterTest.java @@ -25,9 +25,9 @@ import static org.mockito.Mockito.verify; import org.junit.jupiter.api.Test; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamWriter; @SuppressWarnings("unchecked") class ItemStreamWriterAdapterTest { diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReaderTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReaderTest.java index 3bc2fd4..fa40072 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReaderTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReaderTest.java @@ -29,9 +29,9 @@ import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamReader; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.batch.test.MetaDataInstanceFactory; import org.springframework.batch.test.StepScopeTestUtils; From e93e4228c0f0af178f9b114228940c20e2c07d76 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 15 May 2026 16:29:47 +0900 Subject: [PATCH 03/45] Bump test dependencies for JUnit Jupiter 6 and Spring Boot 4 Signed-off-by: Taeik Lim --- gradle/libs.versions.toml | 11 ++++++----- spring-batch-plus-kotlin/build.gradle.kts | 1 + spring-batch-plus/build.gradle.kts | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 973ea98..199478b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,12 +9,12 @@ reactor-core = "3.8.4" findbugs-jsr305 = "3.0.2" # test-only -junit = "5.11.+" +junit = "6.0.+" assertj = "3.27.+" -mockito = "5.15.+" -mockk = "1.13.+" -h2 = "2.3.+" -log4j = "2.24.+" +mockito = "5.20.+" +mockk = "1.14.+" +h2 = "2.4.+" +log4j = "2.25.+" [libraries] spring-boot-autoconfigure = { module = "org.springframework.boot:spring-boot-autoconfigure", version.ref = "spring-boot" } @@ -26,6 +26,7 @@ findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "f # test-only junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit" } assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" } mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } diff --git a/spring-batch-plus-kotlin/build.gradle.kts b/spring-batch-plus-kotlin/build.gradle.kts index 93eecbd..bcab002 100644 --- a/spring-batch-plus-kotlin/build.gradle.kts +++ b/spring-batch-plus-kotlin/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { testImplementation(libs.spring.batch.core) testImplementation(libs.spring.jdbc) testImplementation(libs.reactor.core) + testRuntimeOnly(libs.junit.platform.launcher) testRuntimeOnly(libs.h2) testRuntimeOnly(libs.log4j) } diff --git a/spring-batch-plus/build.gradle.kts b/spring-batch-plus/build.gradle.kts index 4c81d6d..7dfcbad 100644 --- a/spring-batch-plus/build.gradle.kts +++ b/spring-batch-plus/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { testImplementation(libs.spring.batch.core) testImplementation(libs.spring.batch.test) testImplementation(libs.reactor.core) + testRuntimeOnly(libs.junit.platform.launcher) testRuntimeOnly(libs.h2) testRuntimeOnly(libs.log4j) } From f18b67c0c6af3fa74b0cda1e6a207c9526096f7b Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 15 May 2026 17:55:17 +0900 Subject: [PATCH 04/45] Rewrite Java tests for Spring Batch 6.0 API Signed-off-by: Taeik Lim --- ...mReaderProcessorWriterIntegrationTest.java | 10 ++- ...ItemStreamReaderWriterIntegrationTest.java | 10 ++- .../ItemStreamFluxReaderProcessorIT.java | 13 ++-- ...ItemStreamFluxReaderProcessorWriterIT.java | 13 ++-- .../adapter/ItemStreamFluxReaderWriterIT.java | 13 ++-- .../ItemStreamIterableReaderProcessorIT.java | 13 ++-- ...StreamIterableReaderProcessorWriterIT.java | 13 ++-- .../ItemStreamIterableReaderWriterIT.java | 13 ++-- .../ItemStreamIteratorReaderProcessorIT.java | 13 ++-- ...StreamIteratorReaderProcessorWriterIT.java | 13 ++-- .../ItemStreamIteratorReaderWriterIT.java | 13 ++-- .../ItemStreamSimpleReaderProcessorIT.java | 13 ++-- ...emStreamSimpleReaderProcessorWriterIT.java | 13 ++-- .../ItemStreamSimpleReaderWriterIT.java | 13 ++-- .../CheckMaxJobInstanceIdToDeleteTasklet.java | 4 +- .../metadata/DeleteMetadataJobBuilder.java | 4 +- .../job/metadata/DeleteMetadataTasklet.java | 4 +- ...ckMaxJobInstanceIdToDeleteTaskletTest.java | 14 ++-- .../DeleteMetadataJobBuilderTest.java | 13 ++-- .../job/metadata/DeleteMetadataJobTest.java | 34 +++++---- .../metadata/DeleteMetadataTaskletTest.java | 34 +++++---- .../plus/job/metadata/JobMetadataDaoTest.java | 74 +++++++++---------- .../job/metadata/MetadataTestSupports.java | 15 ++++ 23 files changed, 218 insertions(+), 154 deletions(-) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java index 638888a..525dde6 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java @@ -30,13 +30,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -271,7 +272,8 @@ void testStepScopeReaderProcessorWriterWithSameTaskletShouldNotKeepCountContext( } @SuppressWarnings("unused") - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java index 68c23d4..eb111ba 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java @@ -30,13 +30,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -261,7 +262,8 @@ void testStepScopeReaderWriterWithSameTaskletShouldNotKeepCountContext() throws } @SuppressWarnings("unused") - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java index 1b024ca..bb679d3 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java @@ -31,13 +31,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -154,7 +155,8 @@ void fluxReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -182,7 +184,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java index 1bcc0f8..1622e78 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java @@ -32,13 +32,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -162,7 +163,8 @@ void fluxReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exceptio assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -190,7 +192,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java index 30da241..1db52d1 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java @@ -31,13 +31,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -157,7 +158,8 @@ void fluxReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -185,7 +187,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java index 299a677..da51e0c 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java @@ -32,13 +32,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -153,7 +154,8 @@ void iterableReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -181,7 +183,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java index 140a6da..043d46f 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java @@ -33,13 +33,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -161,7 +162,8 @@ void iterableReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -189,7 +191,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java index e9b585f..d4e9eac 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java @@ -32,13 +32,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -156,7 +157,8 @@ void iterableReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -184,7 +186,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java index cfa985c..5d08af0 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java @@ -32,13 +32,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -151,7 +152,8 @@ void iteratorReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -179,7 +181,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java index 787e84c..a5892ea 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java @@ -33,13 +33,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -161,7 +162,8 @@ void iteratorReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -189,7 +191,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java index b7c08df..173bc68 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java @@ -32,13 +32,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -156,7 +157,8 @@ void iteratorReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -184,7 +186,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java index 1986616..44ce5f7 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java @@ -31,13 +31,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -146,7 +147,8 @@ void simpleReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -173,7 +175,8 @@ TestTasklet testTasklet(InvokeCountContext invokeCountContext, int itemCount) { } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java index 2398e5e..f5192d4 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java @@ -32,13 +32,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -156,7 +157,8 @@ void simpleReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Except assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -184,7 +186,8 @@ TestTasklet testTasklet( } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java index 9440aa6..f255cab 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java @@ -31,13 +31,14 @@ import org.junit.jupiter.api.RepeatedTest; import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository; +import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; @@ -151,7 +152,8 @@ void simpleReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) @@ -178,7 +180,8 @@ TestTasklet testTasklet(InvokeCountContext invokeCountContext, int itemCount) { } } - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager" ) diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java index 6895f9b..534a5f8 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java @@ -28,11 +28,11 @@ import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.job.JobExecution; -import org.springframework.batch.core.step.StepContribution; -import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.listener.StepExecutionListener; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.scope.context.StepContext; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.repeat.RepeatStatus; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java index 35b6566..3b7048c 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java @@ -24,11 +24,11 @@ import javax.sql.DataSource; import org.springframework.batch.core.job.Job; -import org.springframework.batch.core.step.Step; -import org.springframework.batch.core.job.parameters.DefaultJobParametersValidator; import org.springframework.batch.core.job.builder.JobBuilder; +import org.springframework.batch.core.job.parameters.DefaultJobParametersValidator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao; +import org.springframework.batch.core.step.Step; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java index f6fe67c..861ac96 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTasklet.java @@ -23,10 +23,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.job.parameters.JobParameters; -import org.springframework.batch.core.step.StepContribution; -import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.listener.StepExecutionListener; import org.springframework.batch.core.scope.context.ChunkContext; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.repeat.RepeatStatus; diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java index a75a7ba..e02a7d4 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/CheckMaxJobInstanceIdToDeleteTaskletTest.java @@ -20,6 +20,8 @@ import static com.navercorp.spring.batch.plus.job.metadata.CheckMaxJobInstanceIdToDeleteTasklet.MAX_ID_KEY; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.buildJobParams; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createJobExecution; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createStepExecution; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.dateFrom; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.dateTo; import static org.assertj.core.api.Assertions.assertThat; @@ -32,11 +34,11 @@ import org.springframework.batch.core.job.JobExecution; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.step.StepContribution; -import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.scope.context.StepContext; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.batch.test.JobRepositoryTestUtils; @@ -81,11 +83,11 @@ void testExecuteWhenNoMetadata() { @Test void testExecuteWhenNeedToDelete() throws Exception { // given - JobExecution execution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); + JobExecution execution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); execution1.setCreateTime(dateTo(2022, 3, 14)); jobRepository.update(execution1); - JobExecution execution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); + JobExecution execution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); execution2.setCreateTime(dateFrom(2022, 3, 15)); jobRepository.update(execution2); @@ -105,13 +107,13 @@ void testExecuteWhenNeedToDelete() throws Exception { assertThat(exitStatus).isEqualTo(ExitStatus.COMPLETED); ExecutionContext jobExecutionContext = stepExecution.getJobExecution().getExecutionContext(); long maxJobInstanceId = jobExecutionContext.getLong(MAX_ID_KEY); - assertThat(maxJobInstanceId).isEqualTo(execution1.getJobId()); + assertThat(maxJobInstanceId).isEqualTo(execution1.getJobInstanceId()); } @Test void testExecuteWhenNoNeedToDelete() throws Exception { // given - JobExecution execution = jobRepository.createJobExecution("testJob2", buildJobParams()); + JobExecution execution = createJobExecution(jobRepository, "testJob2", buildJobParams()); execution.setCreateTime(dateFrom(2022, 2, 15)); jobRepository.update(execution); diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java index b01f230..bd65f54 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilderTest.java @@ -18,6 +18,7 @@ package com.navercorp.spring.batch.plus.job.metadata; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createJobExecution; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -51,7 +52,7 @@ void testBuildAndExecuteJobWithDefaults() throws Exception { .toJobParameters(); Job job = new DeleteMetadataJobBuilder(jobRepository, dataSource).build(); - JobExecution jobExecution = jobRepository.createJobExecution("deleteMetadataJob", jobParams); + JobExecution jobExecution = createJobExecution(jobRepository, "deleteMetadataJob", jobParams); job.execute(jobExecution); // then @@ -76,7 +77,7 @@ void testBuildAndExecuteJobWithCustomTablePrefix() throws Exception { .addString("baseDate", "2022/03/14") .toJobParameters(); - JobExecution jobExecution = jobRepository.createJobExecution("testJob", jobParams); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob", jobParams); job.execute(jobExecution); // then @@ -102,7 +103,7 @@ void testBuildAndExecuteJobWithCustomBaseDateParameterName() throws Exception { .addString(baseDateParameterName, "2022/03/14") .toJobParameters(); - JobExecution jobExecution = jobRepository.createJobExecution("testJob", jobParams); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob", jobParams); job.execute(jobExecution); // then @@ -128,7 +129,7 @@ void testBuildAndExecuteJobWithCustomFormatter() throws Exception { .addString("baseDate", "2022-03-14") .toJobParameters(); - JobExecution jobExecution = jobRepository.createJobExecution("testJob", jobParams); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob", jobParams); job.execute(jobExecution); // then @@ -155,7 +156,7 @@ void testBuildAndExecuteJobWithCustomDryRun() throws Exception { .addString(dryRunParameterName, "true") .toJobParameters(); - JobExecution jobExecution = jobRepository.createJobExecution("testJob", jobParams); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob", jobParams); job.execute(jobExecution); // then @@ -179,7 +180,7 @@ void testBuildAndExecuteJobWithWrongTablePrefix() throws Exception { .tablePrefix("WRONG_") .build(); - JobExecution jobExecution = jobRepository.createJobExecution("testJob", jobParams); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob", jobParams); job.execute(jobExecution); // then diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java index bcd1c1a..512d782 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java @@ -19,6 +19,8 @@ package com.navercorp.spring.batch.plus.job.metadata; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.buildJobParams; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createJobExecution; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createStepExecution; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.dateFrom; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.dateTo; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.randomBetween; @@ -32,14 +34,13 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.InvalidJobParametersException; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.job.parameters.InvalidJobParametersException; -import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.task.SyncTaskExecutor; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -60,8 +61,7 @@ class DeleteMetadataJobTest { @BeforeEach void setUp( @Autowired DataSource dataSource, - @Autowired String tablePrefix, - @Autowired JobRepositoryTestUtils testUtils + @Autowired String tablePrefix ) { TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(this.jobRepository); @@ -72,7 +72,13 @@ void setUp( .tablePrefix(tablePrefix) .build(); - testUtils.removeJobExecutions(); + // JobLauncher.run() in Spring Batch 6.0 creates the JobInstance before validating parameters, + // so failed validations leave orphan instances. Delete by instance to also drop their executions. + for (String jobName : this.jobRepository.getJobNames()) { + for (JobInstance instance : this.jobRepository.findJobInstances(jobName)) { + this.jobRepository.deleteJobInstance(instance); + } + } } @Test @@ -95,10 +101,10 @@ void testRunWhenNeedNotToDelete() throws Exception { // given int countToCreate = randomBetween(10, 50); for (int i = 0; i < countToCreate; ++i) { - JobExecution jobExecution = jobRepository.createJobExecution("testJobToRemove" + i, buildJobParams()); + JobExecution jobExecution = createJobExecution(jobRepository, "testJobToRemove" + i, buildJobParams()); jobExecution.setCreateTime(dateFrom(2022, 3, 15)); jobRepository.update(jobExecution); - jobRepository.add(new StepExecution("testStep", jobExecution)); + createStepExecution(jobRepository, "testStep", jobExecution); } JobParameters jobParameters = new JobParametersBuilder() .addString("baseDate", "2022/03/15") @@ -127,17 +133,17 @@ void testRunWhenNeedToDelete() throws Exception { // given int countToCreateBeforeBaseDate = randomBetween(10, 50); for (int i = 0; i < countToCreateBeforeBaseDate; ++i) { - JobExecution jobExecution = jobRepository.createJobExecution("testJobToRemove" + i, buildJobParams()); + JobExecution jobExecution = createJobExecution(jobRepository, "testJobToRemove" + i, buildJobParams()); jobExecution.setCreateTime(dateTo(2022, 3, 14)); jobRepository.update(jobExecution); - jobRepository.add(new StepExecution("testStep", jobExecution)); + createStepExecution(jobRepository, "testStep", jobExecution); } int countToCreateAfterBaseDate = randomBetween(10, 50); for (int i = 0; i < countToCreateAfterBaseDate; ++i) { - JobExecution jobExecution = jobRepository.createJobExecution("testJobToRemains" + i, buildJobParams()); + JobExecution jobExecution = createJobExecution(jobRepository, "testJobToRemains" + i, buildJobParams()); jobExecution.setCreateTime(dateFrom(2022, 3, 15)); jobRepository.update(jobExecution); - jobRepository.add(new StepExecution("testStep", jobExecution)); + createStepExecution(jobRepository, "testStep", jobExecution); } // when @@ -166,10 +172,10 @@ void testRunShouldNotRemoveWhenDryRun() throws Exception { // given int countToCreate = randomBetween(10, 50); for (int i = 0; i < countToCreate; ++i) { - JobExecution jobExecution = jobRepository.createJobExecution("testJobToRemove" + i, buildJobParams()); + JobExecution jobExecution = createJobExecution(jobRepository, "testJobToRemove" + i, buildJobParams()); jobExecution.setCreateTime(dateTo(2022, 3, 14)); jobRepository.update(jobExecution); - jobRepository.add(new StepExecution("testStep", jobExecution)); + createStepExecution(jobRepository, "testStep", jobExecution); } // when diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java index eb8d034..c2d74b3 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataTaskletTest.java @@ -21,6 +21,8 @@ import static com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataTasklet.DELETION_RANGE_LENGTH; import static com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataTasklet.LOW_ID_KEY; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.buildJobParams; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createJobExecution; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createStepExecution; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.randomBetween; import static org.assertj.core.api.Assertions.assertThat; @@ -31,11 +33,11 @@ import org.springframework.batch.core.job.JobExecution; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.step.StepContribution; -import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.scope.context.StepContext; +import org.springframework.batch.core.step.StepContribution; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.batch.test.JobRepositoryTestUtils; @@ -67,9 +69,9 @@ void testExecuteWhen1stStart() throws Exception { int countToDelete = countToCreate - randomBetween(1, countToCreate - 1); long lastJobInstanceId = 0; for (int i = 0; i < countToCreate; i++) { - JobExecution jobExecution = jobRepository.createJobExecution("testJob" + i, buildJobParams()); - jobRepository.add(new StepExecution("testStep", jobExecution)); - lastJobInstanceId = jobExecution.getJobId(); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob" + i, buildJobParams()); + createStepExecution(jobRepository, "testStep", jobExecution); + lastJobInstanceId = jobExecution.getJobInstanceId(); } StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(); @@ -108,8 +110,8 @@ void testExecuteWhenNothingToDelete() throws Exception { // given int countToCreate = randomBetween(10, 300); for (int i = 0; i < countToCreate; i++) { - JobExecution jobExecution = jobRepository.createJobExecution("testJob" + i, buildJobParams()); - jobRepository.add(new StepExecution("testStep", jobExecution)); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob" + i, buildJobParams()); + createStepExecution(jobRepository, "testStep", jobExecution); } StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(); @@ -147,9 +149,9 @@ void testExecuteWhenRestart() throws Exception { int countToCreate = randomBetween(10, 300); long lastJobInstanceId = 0; for (int i = 0; i < countToCreate; i++) { - JobExecution jobExecution = jobRepository.createJobExecution("testJob" + i, buildJobParams()); - jobRepository.add(new StepExecution("testStep", jobExecution)); - lastJobInstanceId = jobExecution.getJobId(); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob" + i, buildJobParams()); + createStepExecution(jobRepository, "testStep", jobExecution); + lastJobInstanceId = jobExecution.getJobInstanceId(); } StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(); @@ -185,9 +187,9 @@ void testExecuteShouldNotRemoveWhenDryRunIsTrue() throws Exception { int countToCreate = randomBetween(1, 10); long lastJobInstanceId = 0; for (int i = 0; i < countToCreate; i++) { - JobExecution jobExecution = jobRepository.createJobExecution("testJob" + i, buildJobParams()); - jobRepository.add(new StepExecution("testStep", jobExecution)); - lastJobInstanceId = jobExecution.getJobId(); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob" + i, buildJobParams()); + createStepExecution(jobRepository, "testStep", jobExecution); + lastJobInstanceId = jobExecution.getJobInstanceId(); } JobParameters jobParameters = new JobParametersBuilder() @@ -229,9 +231,9 @@ void testExecuteShouldNotRemoveWhenDryRunIsNotTrue() throws Exception { int countToCreate = randomBetween(1, 10); long lastJobInstanceId = 0; for (int i = 0; i < countToCreate; i++) { - JobExecution jobExecution = jobRepository.createJobExecution("testJob" + i, buildJobParams()); - jobRepository.add(new StepExecution("testStep", jobExecution)); - lastJobInstanceId = jobExecution.getJobId(); + JobExecution jobExecution = createJobExecution(jobRepository, "testJob" + i, buildJobParams()); + createStepExecution(jobRepository, "testStep", jobExecution); + lastJobInstanceId = jobExecution.getJobInstanceId(); } JobParameters jobParameters = new JobParametersBuilder() diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java index e530f01..eafdaa2 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDaoTest.java @@ -19,6 +19,8 @@ package com.navercorp.spring.batch.plus.job.metadata; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.buildJobParams; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createJobExecution; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.createStepExecution; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.dateFrom; import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.dateTo; import static org.assertj.core.api.Assertions.assertThat; @@ -30,8 +32,8 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.job.JobExecution; import org.springframework.batch.core.job.JobInstance; -import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.StepExecution; import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -53,7 +55,7 @@ void setUp(@Autowired JobRepositoryTestUtils testUtils) { @Test void selectMaxJobInstanceIdLessThanCreateTimeWhenEmpty() throws Exception { // given - JobExecution execution = jobRepository.createJobExecution("testJob1", buildJobParams()); + JobExecution execution = createJobExecution(jobRepository, "testJob1", buildJobParams()); execution.setCreateTime(dateFrom(2022, 3, 14)); jobRepository.update(execution); @@ -67,11 +69,11 @@ void selectMaxJobInstanceIdLessThanCreateTimeWhenEmpty() throws Exception { @Test void selectMaxJobInstanceIdLessThanCreateTimeWhenExists() throws Exception { // given - JobExecution execution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); + JobExecution execution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); execution1.setCreateTime(dateTo(2022, 3, 14)); jobRepository.update(execution1); - JobExecution execution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); + JobExecution execution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); execution2.setCreateTime(dateFrom(2022, 3, 15)); jobRepository.update(execution2); @@ -80,7 +82,7 @@ void selectMaxJobInstanceIdLessThanCreateTimeWhenExists() throws Exception { // then assertThat(maxJobInstanceId).isPresent(); - assertThat(maxJobInstanceId.get()).isEqualTo(execution1.getJobId()); + assertThat(maxJobInstanceId.get()).isEqualTo(execution1.getJobInstanceId()); } @Test @@ -112,10 +114,10 @@ void testDeleteJobInstancesByJobInstanceIdRange() { @Test void testDeleteJobExecutionsParamsByJobInstanceIdRange() throws Exception { // given - JobExecution execution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); - JobExecution execution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); - long lowJobInstanceId = execution1.getJobId(); - long highJobInstanceId = execution2.getJobId(); + JobExecution execution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); + JobExecution execution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); + long lowJobInstanceId = execution1.getJobInstanceId(); + long highJobInstanceId = execution2.getJobInstanceId(); // when int deletedCount = dao.deleteJobExecutionParamsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); @@ -127,10 +129,10 @@ void testDeleteJobExecutionsParamsByJobInstanceIdRange() throws Exception { @Test void testDeleteJobExecutionContextsByJobInstanceIdRange() throws Exception { // given - JobExecution execution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); - JobExecution execution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); - long lowJobInstanceId = execution1.getJobId(); - long highJobInstanceId = execution2.getJobId(); + JobExecution execution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); + JobExecution execution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); + long lowJobInstanceId = execution1.getJobInstanceId(); + long highJobInstanceId = execution2.getJobInstanceId(); // when int deletedCount = dao.deleteJobExecutionContextsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); @@ -142,12 +144,12 @@ void testDeleteJobExecutionContextsByJobInstanceIdRange() throws Exception { @Test void testDeleteJobExecutionsByJobInstanceIdRange() throws Exception { // given - JobExecution execution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); - JobExecution execution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); - jobRepository.createJobExecution("testJob3", buildJobParams()); + JobExecution execution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); + JobExecution execution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); + createJobExecution(jobRepository, "testJob3", buildJobParams()); - long lowJobInstanceId = execution1.getJobId(); - long highJobInstanceId = execution2.getJobId(); + long lowJobInstanceId = execution1.getJobInstanceId(); + long highJobInstanceId = execution2.getJobInstanceId(); dao.deleteJobExecutionContextsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); dao.deleteJobExecutionParamsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); @@ -161,17 +163,15 @@ void testDeleteJobExecutionsByJobInstanceIdRange() throws Exception { @Test void testDeleteStepExecutionContextsByJobInstanceIdRange() throws Exception { // given - JobExecution jobExecution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); - jobExecution1.createStepExecution("testStep1"); - jobExecution1.createStepExecution("testStep2"); - jobRepository.add(new StepExecution("testStep1", jobExecution1)); - jobRepository.add(new StepExecution("testStep2", jobExecution1)); + JobExecution jobExecution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); + createStepExecution(jobRepository, "testStep1", jobExecution1); + createStepExecution(jobRepository, "testStep2", jobExecution1); - JobExecution jobExecution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); - jobRepository.add(new StepExecution("testStep3", jobExecution2)); + JobExecution jobExecution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); + createStepExecution(jobRepository, "testStep3", jobExecution2); - long lowJobInstanceId = jobExecution1.getJobId(); - long highJobInstanceId = jobExecution2.getJobId(); + long lowJobInstanceId = jobExecution1.getJobInstanceId(); + long highJobInstanceId = jobExecution2.getJobInstanceId(); // when int deletedCount = dao.deleteStepExecutionContextsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); @@ -183,20 +183,18 @@ void testDeleteStepExecutionContextsByJobInstanceIdRange() throws Exception { @Test void testDeleteStepExecutionsByJobInstanceIdRange() throws Exception { // given - JobExecution jobExecution1 = jobRepository.createJobExecution("testJob1", buildJobParams()); - jobExecution1.createStepExecution("testStep1"); - jobExecution1.createStepExecution("testStep2"); - jobRepository.add(new StepExecution("testStep1", jobExecution1)); - jobRepository.add(new StepExecution("testStep2", jobExecution1)); + JobExecution jobExecution1 = createJobExecution(jobRepository, "testJob1", buildJobParams()); + createStepExecution(jobRepository, "testStep1", jobExecution1); + createStepExecution(jobRepository, "testStep2", jobExecution1); - JobExecution jobExecution2 = jobRepository.createJobExecution("testJob2", buildJobParams()); - jobRepository.add(new StepExecution("testStep3", jobExecution2)); + JobExecution jobExecution2 = createJobExecution(jobRepository, "testJob2", buildJobParams()); + createStepExecution(jobRepository, "testStep3", jobExecution2); - JobExecution jobExecution3 = jobRepository.createJobExecution("testJob3", buildJobParams()); - jobRepository.add(new StepExecution("testStep4", jobExecution3)); + JobExecution jobExecution3 = createJobExecution(jobRepository, "testJob3", buildJobParams()); + createStepExecution(jobRepository, "testStep4", jobExecution3); - long lowJobInstanceId = jobExecution1.getJobId(); - long highJobInstanceId = jobExecution2.getJobId(); + long lowJobInstanceId = jobExecution1.getJobInstanceId(); + long highJobInstanceId = jobExecution2.getJobInstanceId(); dao.deleteStepExecutionContextsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); // when diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java index be5d27c..c3ad20e 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/MetadataTestSupports.java @@ -23,11 +23,26 @@ import java.time.LocalDateTime; import java.util.concurrent.ThreadLocalRandom; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.ExecutionContext; class MetadataTestSupports { + static JobExecution createJobExecution(JobRepository jobRepository, String jobName, JobParameters parameters) { + JobInstance jobInstance = jobRepository.createJobInstance(jobName, parameters); + return jobRepository.createJobExecution(jobInstance, parameters, new ExecutionContext()); + } + + static StepExecution createStepExecution(JobRepository jobRepository, String stepName, JobExecution jobExecution) { + return jobRepository.createStepExecution(stepName, jobExecution); + } + + static LocalDateTime dateTo(int year, int month, int day) { LocalDate to = LocalDate.of(year, month, day); LocalDate from = to.minusDays(10); From 9f040de90c9f83b83e7f54cab559ba8cc73b8847 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 18 May 2026 15:47:55 +0900 Subject: [PATCH 05/45] Migrate Java module to JSpecify nullability annotations Signed-off-by: Taeik Lim --- gradle/libs.versions.toml | 2 ++ spring-batch-plus/build.gradle.kts | 2 ++ ...mReaderProcessorWriterIntegrationTest.java | 31 +++++++++---------- ...ItemStreamReaderWriterIntegrationTest.java | 27 +++++++--------- .../ItemStreamFluxReaderProcessorIT.java | 10 +++--- ...ItemStreamFluxReaderProcessorWriterIT.java | 16 +++++----- .../adapter/ItemStreamFluxReaderWriterIT.java | 14 ++++----- .../ItemStreamIterableReaderProcessorIT.java | 10 +++--- ...StreamIterableReaderProcessorWriterIT.java | 16 +++++----- .../ItemStreamIterableReaderWriterIT.java | 14 ++++----- .../ItemStreamIteratorReaderProcessorIT.java | 10 +++--- ...StreamIteratorReaderProcessorWriterIT.java | 16 +++++----- .../ItemStreamIteratorReaderWriterIT.java | 14 ++++----- .../ItemStreamSimpleReaderProcessorIT.java | 7 ++--- ...emStreamSimpleReaderProcessorWriterIT.java | 13 ++++---- .../ItemStreamSimpleReaderWriterIT.java | 11 +++---- .../plus/item/adapter/AdapterFactory.java | 7 ++--- .../item/adapter/ItemProcessorAdapter.java | 3 +- .../item/adapter/ItemProcessorDelegate.java | 5 ++- .../item/adapter/ItemStreamReaderAdapter.java | 3 +- .../adapter/ItemStreamReaderDelegate.java | 8 ++--- .../item/adapter/ItemStreamWriterAdapter.java | 3 +- .../adapter/ItemStreamWriterDelegate.java | 7 ++--- .../batch/plus/item/adapter/package-info.java | 3 ++ .../batch/plus/job/ClearRunIdIncrementer.java | 4 +-- .../metadata/DeleteMetadataJobBuilder.java | 13 ++++---- .../batch/plus/job/metadata/package-info.java | 3 ++ .../spring/batch/plus/job/package-info.java | 3 ++ .../plus/step/adapter/AdapterFactory.java | 13 ++++---- .../step/adapter/ItemProcessorAdapter.java | 5 ++- .../step/adapter/ItemProcessorDelegate.java | 5 ++- .../adapter/ItemStreamFluxReaderAdapter.java | 7 ++--- .../adapter/ItemStreamFluxReaderDelegate.java | 8 ++--- .../ItemStreamIterableReaderAdapter.java | 7 ++--- .../ItemStreamIterableReaderDelegate.java | 8 ++--- .../ItemStreamIteratorReaderAdapter.java | 7 ++--- .../ItemStreamIteratorReaderDelegate.java | 8 ++--- .../ItemStreamSimpleReaderAdapter.java | 7 ++--- .../ItemStreamSimpleReaderDelegate.java | 7 ++--- .../step/adapter/ItemStreamWriterAdapter.java | 9 +++--- .../adapter/ItemStreamWriterDelegate.java | 7 ++--- .../adapter/StepScopeItemStreamReader.java | 5 ++- .../batch/plus/step/adapter/package-info.java | 3 ++ 43 files changed, 171 insertions(+), 210 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 199478b..a3e9318 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ spring-jdbc = "7.0.6" slf4j = "2.0.17" reactor-core = "3.8.4" findbugs-jsr305 = "3.0.2" +jspecify = "1.0.0" # test-only junit = "6.0.+" @@ -23,6 +24,7 @@ spring-jdbc = { module = "org.springframework:spring-jdbc", version.ref = "sprin slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } reactor-core = { module = "io.projectreactor:reactor-core", version.ref = "reactor-core" } findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "findbugs-jsr305" } +jspecify = { module = "org.jspecify:jspecify", version.ref = "jspecify" } # test-only junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" } diff --git a/spring-batch-plus/build.gradle.kts b/spring-batch-plus/build.gradle.kts index 7dfcbad..9d63082 100644 --- a/spring-batch-plus/build.gradle.kts +++ b/spring-batch-plus/build.gradle.kts @@ -4,6 +4,8 @@ plugins { } dependencies { + api(libs.jspecify) + compileOnly(libs.findbugs.jsr305) compileOnly(libs.spring.batch.core) compileOnly(libs.spring.jdbc) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java index 525dde6..1b9eaa1 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java @@ -49,7 +49,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; import reactor.core.publisher.Flux; @@ -300,13 +299,12 @@ ItemStreamReaderProcessorWriter testTasklet() { private int count = 0; @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { ++onOpenReadCallCount; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { ++readContextCallCount; return Flux.generate(sink -> { if (count < itemCount) { @@ -319,7 +317,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { ++onUpdateReadCallCount; } @@ -329,23 +327,23 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { ++processCallCount; return item; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { ++onOpenWriteCallCount; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { ++writeCallCount; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { ++onUpdateWriteCallCount; } @@ -364,13 +362,12 @@ ItemStreamReaderProcessorWriter stepScopeTestTasklet() { private int count = 0; @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { ++onOpenReadCallCount; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { ++readContextCallCount; return Flux.generate(sink -> { if (count < itemCount) { @@ -383,7 +380,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { ++onUpdateReadCallCount; } @@ -393,23 +390,23 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { ++onOpenWriteCallCount; } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { ++processCallCount; return item; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { ++writeCallCount; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { ++onUpdateWriteCallCount; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java index eb111ba..4c4e008 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java @@ -49,7 +49,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; import reactor.core.publisher.Flux; @@ -290,13 +289,12 @@ ItemStreamReaderWriter testTasklet() { private int count = 0; @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { ++onOpenReadCallCount; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { ++readContextCallCount; return Flux.generate(sink -> { if (count < itemCount) { @@ -309,7 +307,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { ++onUpdateReadCallCount; } @@ -319,17 +317,17 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { ++onOpenWriteCallCount; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { ++writeCallCount; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { ++onUpdateWriteCallCount; } @@ -348,13 +346,12 @@ ItemStreamReaderWriter stepScopeTestTasklet() { private int count = 0; @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { ++onOpenReadCallCount; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { ++readContextCallCount; return Flux.generate(sink -> { if (count < itemCount) { @@ -367,7 +364,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { ++onUpdateReadCallCount; } @@ -377,17 +374,17 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { ++onOpenWriteCallCount; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { ++writeCallCount; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { ++onUpdateWriteCallCount; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java index bb679d3..ce49f29 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java @@ -49,7 +49,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; import reactor.core.publisher.Flux; @@ -224,13 +223,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return Flux.generate(sink -> { if (count < itemCount) { @@ -243,7 +241,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -253,7 +251,7 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java index 1622e78..d00fcf2 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java @@ -51,7 +51,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; import reactor.core.publisher.Flux; @@ -232,13 +231,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return Flux.generate(sink -> { if (count < itemCount) { @@ -251,7 +249,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -261,23 +259,23 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java index 1db52d1..2285443 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java @@ -50,7 +50,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; import reactor.core.publisher.Flux; @@ -227,13 +226,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return Flux.generate(sink -> { if (count < itemCount) { @@ -246,7 +244,7 @@ public Flux readFlux(@NonNull ExecutionContext executionContext) { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -256,17 +254,17 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java index da51e0c..938c02d 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java @@ -50,7 +50,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -223,13 +222,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Iterable readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return () -> new Iterator<>() { @Override @@ -249,7 +247,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -259,7 +257,7 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java index 043d46f..de2b424 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java @@ -52,7 +52,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -231,13 +230,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Iterable readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return () -> new Iterator<>() { @Override @@ -257,7 +255,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -267,23 +265,23 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java index d4e9eac..9fb0564 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java @@ -51,7 +51,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -226,13 +225,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Iterable readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return () -> new Iterator<>() { @Override @@ -252,7 +250,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -262,17 +260,17 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java index 5d08af0..09ee269 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java @@ -50,7 +50,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -221,13 +220,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Iterator readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return new Iterator<>() { @Override @@ -247,7 +245,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -257,7 +255,7 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java index a5892ea..965069e 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java @@ -52,7 +52,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -231,13 +230,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Iterator readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return new Iterator<>() { @Override @@ -257,7 +255,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -267,23 +265,23 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java index 173bc68..c364188 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java @@ -51,7 +51,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -226,13 +225,12 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } - @NonNull @Override - public Iterator readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { this.invokeCountContext.readContextCallCount++; return new Iterator<>() { @Override @@ -252,7 +250,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -262,17 +260,17 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java index 44ce5f7..e869909 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java @@ -49,7 +49,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -214,7 +213,7 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } @@ -228,7 +227,7 @@ public Integer read() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -238,7 +237,7 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java index f5192d4..3fec152 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java @@ -51,7 +51,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -225,7 +224,7 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } @@ -239,7 +238,7 @@ public Integer read() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -249,23 +248,23 @@ public void onCloseRead() { } @Override - public Integer process(@NonNull Integer item) { + public Integer process(Integer item) { this.invokeCountContext.processCallCount++; return item; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java index f255cab..a29fb06 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java @@ -50,7 +50,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.lang.NonNull; import org.springframework.transaction.TransactionManager; @SuppressWarnings({"unchecked", "unused"}) @@ -219,7 +218,7 @@ public TestTasklet(InvokeCountContext invokeCountContext, int itemCount) { } @Override - public void onOpenRead(@NonNull ExecutionContext executionContext) { + public void onOpenRead(ExecutionContext executionContext) { this.invokeCountContext.onOpenReadCallCount++; } @@ -233,7 +232,7 @@ public Integer read() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { this.invokeCountContext.onUpdateReadCallCount++; } @@ -243,17 +242,17 @@ public void onCloseRead() { } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { this.invokeCountContext.onOpenWriteCallCount++; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.invokeCountContext.writeCallCount++; } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { this.invokeCountContext.onUpdateWriteCallCount++; } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java index bd80914..03c66ee 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/AdapterFactory.java @@ -24,7 +24,6 @@ import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.batch.infrastructure.item.ItemStreamWriter; -import org.springframework.lang.NonNull; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderDelegate; @@ -50,7 +49,7 @@ public final class AdapterFactory { * @return an adapted ItemStreamReader */ @Deprecated - public static ItemStreamReader itemStreamReader(@NonNull ItemStreamReaderDelegate delegate) { + public static ItemStreamReader itemStreamReader(ItemStreamReaderDelegate delegate) { Objects.requireNonNull(delegate, "ItemStreamReader delegate is null"); return StepScopeItemStreamReader.of(() -> ItemStreamReaderAdapter.of(delegate)); } @@ -68,7 +67,7 @@ public static ItemStreamReader itemStreamReader(@NonNull ItemStreamReader * @return an adapted ItemProcessor */ @Deprecated - public static ItemProcessor itemProcessor(@NonNull ItemProcessorDelegate delegate) { + public static ItemProcessor itemProcessor(ItemProcessorDelegate delegate) { return ItemProcessorAdapter.of(delegate); } @@ -83,7 +82,7 @@ public static ItemProcessor itemProcessor(@NonNull ItemProcessorDel * @return an adapted ItemStreamWriter */ @Deprecated - public static ItemStreamWriter itemStreamWriter(@NonNull ItemStreamWriterDelegate delegate) { + public static ItemStreamWriter itemStreamWriter(ItemStreamWriterDelegate delegate) { return ItemStreamWriterAdapter.of(delegate); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java index aab8bdd..47ad9ec 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorAdapter.java @@ -21,7 +21,6 @@ import java.util.Objects; import org.springframework.batch.infrastructure.item.ItemProcessor; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemProcessorDelegate} to {@link ItemProcessor}. @@ -40,7 +39,7 @@ public class ItemProcessorAdapter implements ItemProcessor { * @param an item type to process * @param a processed item type */ - public static ItemProcessor of(@NonNull ItemProcessorDelegate delegate) { + public static ItemProcessor of(ItemProcessorDelegate delegate) { return new ItemProcessorAdapter<>(delegate); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java index 17155ac..faa2368 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemProcessorDelegate.java @@ -18,9 +18,8 @@ package com.navercorp.spring.batch.plus.item.adapter; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ItemProcessor; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; /** * A delegate for {@link ItemProcessor}. @@ -38,5 +37,5 @@ public interface ItemProcessorDelegate { * @return processed item */ @Nullable - O process(@NonNull I item); + O process(I item); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java index 0f60384..59d5abd 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderAdapter.java @@ -23,7 +23,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; @@ -45,7 +44,7 @@ public class ItemStreamReaderAdapter implements ItemStreamReader { * @return an adapted ItemStreamReader * @param a read item type */ - public static ItemStreamReader of(@NonNull ItemStreamReaderDelegate delegate) { + public static ItemStreamReader of(ItemStreamReaderDelegate delegate) { return new ItemStreamReaderAdapter<>(delegate); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java index f72b3fc..c1d3b6f 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderDelegate.java @@ -20,7 +20,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; @@ -40,7 +39,7 @@ public interface ItemStreamReaderDelegate { * * @param executionContext an execution context */ - default void onOpenRead(@NonNull ExecutionContext executionContext) { + default void onOpenRead(ExecutionContext executionContext) { } /** @@ -49,15 +48,14 @@ default void onOpenRead(@NonNull ExecutionContext executionContext) { * @param executionContext an execution context * @return a flux to read item. */ - @NonNull - Flux readFlux(@NonNull ExecutionContext executionContext); + Flux readFlux(ExecutionContext executionContext); /** * A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. * * @param executionContext an execution context */ - default void onUpdateRead(@NonNull ExecutionContext executionContext) { + default void onUpdateRead(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java index 63ac669..e89cd69 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterAdapter.java @@ -23,7 +23,6 @@ import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamWriter; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemStreamWriterDelegate} to {@link ItemStreamWriter}. @@ -41,7 +40,7 @@ public class ItemStreamWriterAdapter implements ItemStreamWriter { * @return an adapted ItemStreamWriter * @param an item type to write */ - public static ItemStreamWriter of(@NonNull ItemStreamWriterDelegate delegate) { + public static ItemStreamWriter of(ItemStreamWriterDelegate delegate) { return new ItemStreamWriterAdapter<>(delegate); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java index 3a16e4f..13c0361 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamWriterDelegate.java @@ -21,7 +21,6 @@ import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamWriter; -import org.springframework.lang.NonNull; /** * A delegate for {@link ItemStreamWriter}. @@ -36,20 +35,20 @@ public interface ItemStreamWriterDelegate { * A delegate method for {@link ItemStreamWriter#open(ExecutionContext)}. * @param executionContext an execution context */ - default void onOpenWrite(@NonNull ExecutionContext executionContext) { + default void onOpenWrite(ExecutionContext executionContext) { } /** * A delegate method for {@link ItemStreamWriter#write(Chunk)}. * @param chunk chunk to write */ - void write(@NonNull Chunk chunk); + void write(Chunk chunk); /** * A delegate method for {@link ItemStreamWriter#update(ExecutionContext)}. * @param executionContext an execution context */ - default void onUpdateWrite(@NonNull ExecutionContext executionContext) { + default void onUpdateWrite(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/package-info.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/package-info.java index a43e167..d812a5d 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/package-info.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/item/adapter/package-info.java @@ -19,4 +19,7 @@ /** * An extensions for spring batch item adapter concerns. */ +@NullMarked package com.navercorp.spring.batch.plus.item.adapter; + +import org.jspecify.annotations.NullMarked; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java index 1429f7a..f05d71b 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementer.java @@ -25,7 +25,6 @@ import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.job.parameters.JobParametersIncrementer; import org.springframework.batch.core.job.parameters.RunIdIncrementer; -import org.springframework.lang.NonNull; /** * Alternative to {@link RunIdIncrementer}. @@ -52,7 +51,7 @@ public static JobParametersIncrementer create() { * @param runId a run id * @return a new ClearRunIdIncrementer instance */ - public static JobParametersIncrementer create(@NonNull String runId) { + public static JobParametersIncrementer create(String runId) { return new ClearRunIdIncrementer(runId); } @@ -62,7 +61,6 @@ protected ClearRunIdIncrementer(String runId) { this.runId = Objects.requireNonNull(runId, "Run id must not be null"); } - @NonNull @Override public JobParameters getNext(JobParameters parameters) { long nextId = Optional.ofNullable(parameters) diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java index 3b7048c..cc2c10d 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobBuilder.java @@ -32,7 +32,6 @@ import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.lang.NonNull; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.interceptor.DefaultTransactionAttribute; @@ -62,7 +61,7 @@ public class DeleteMetadataJobBuilder { * @param jobRepository the target job repository to delete old metadata. * @param dataSource the data source of the job repository */ - public DeleteMetadataJobBuilder(@NonNull JobRepository jobRepository, @NonNull DataSource dataSource) { + public DeleteMetadataJobBuilder(JobRepository jobRepository, DataSource dataSource) { Objects.requireNonNull(jobRepository, "JobRepository must not be null"); Objects.requireNonNull(dataSource, "DataSource must not be null"); @@ -74,7 +73,7 @@ public DeleteMetadataJobBuilder(@NonNull JobRepository jobRepository, @NonNull D * @param name the name of the job to delete metadata. The default value is 'deleteMetaDataJob'. * @return The current instance of the builder for method chaining */ - public DeleteMetadataJobBuilder name(@NonNull String name) { + public DeleteMetadataJobBuilder name(String name) { this.name = Objects.requireNonNull(name, "Job name must not be null"); return this; } @@ -83,7 +82,7 @@ public DeleteMetadataJobBuilder name(@NonNull String name) { * @param tablePrefix The prefix of tables for metadata. The default value is 'BATCH_'. * @return The current instance of the builder for method chaining */ - public DeleteMetadataJobBuilder tablePrefix(@NonNull String tablePrefix) { + public DeleteMetadataJobBuilder tablePrefix(String tablePrefix) { this.tablePrefix = Objects.requireNonNull(tablePrefix, "Metadata table prefix must not be null"); return this; } @@ -93,7 +92,7 @@ public DeleteMetadataJobBuilder tablePrefix(@NonNull String tablePrefix) { * The default value is "baseDate" * @return The current instance of the builder for method chaining */ - public DeleteMetadataJobBuilder baseDateParameterName(@NonNull String baseDateParameterName) { + public DeleteMetadataJobBuilder baseDateParameterName(String baseDateParameterName) { this.baseDateParameterName = Objects.requireNonNull(baseDateParameterName, "BaseDate parameter name must not be null"); return this; @@ -104,7 +103,7 @@ public DeleteMetadataJobBuilder baseDateParameterName(@NonNull String baseDatePa * The default value is DateTimeFormatter.ofPattern("yyyy/MM/dd") * @return The current instance of the builder for method chaining */ - public DeleteMetadataJobBuilder baseDateFormatter(@NonNull DateTimeFormatter baseDateFormatter) { + public DeleteMetadataJobBuilder baseDateFormatter(DateTimeFormatter baseDateFormatter) { this.baseDateFormatter = Objects.requireNonNull(baseDateFormatter, "BaseDate formatter must not be null"); return this; } @@ -114,7 +113,7 @@ public DeleteMetadataJobBuilder baseDateFormatter(@NonNull DateTimeFormatter bas * The default value is "dryRun" * @return The current instance of the builder for method chaining */ - public DeleteMetadataJobBuilder dryRunParameterName(@NonNull String dryRunParameterName) { + public DeleteMetadataJobBuilder dryRunParameterName(String dryRunParameterName) { this.dryRunParameterName = Objects.requireNonNull(dryRunParameterName, "DryRun parameter name must not be null"); return this; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/package-info.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/package-info.java index 7639e82..29d1c0b 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/package-info.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/package-info.java @@ -19,4 +19,7 @@ /** * The job to delete old Spring Batch metadata */ +@NullMarked package com.navercorp.spring.batch.plus.job.metadata; + +import org.jspecify.annotations.NullMarked; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/package-info.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/package-info.java index e8c1586..11247f6 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/package-info.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/package-info.java @@ -19,4 +19,7 @@ /** * An extensions for spring batch job concerns. */ +@NullMarked package com.navercorp.spring.batch.plus.job; + +import org.jspecify.annotations.NullMarked; diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java index 8c104b9..cabbf52 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/AdapterFactory.java @@ -24,7 +24,6 @@ import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.batch.infrastructure.item.ItemStreamReader; import org.springframework.batch.infrastructure.item.ItemStreamWriter; -import org.springframework.lang.NonNull; /** * An adapter factory for these interfaces @@ -47,7 +46,7 @@ public final class AdapterFactory { * @param delegate a delegate * @return an adapted ItemStreamReader */ - public static ItemStreamReader itemStreamReader(@NonNull ItemStreamFluxReaderDelegate delegate) { + public static ItemStreamReader itemStreamReader(ItemStreamFluxReaderDelegate delegate) { Objects.requireNonNull(delegate, "ItemStreamReader delegate is null"); return StepScopeItemStreamReader.of(() -> ItemStreamFluxReaderAdapter.of(delegate)); } @@ -60,7 +59,7 @@ public static ItemStreamReader itemStreamReader(@NonNull ItemStreamFluxRe * @param delegate a delegate * @return an adapted ItemStreamReader */ - public static ItemStreamReader itemStreamReader(@NonNull ItemStreamIterableReaderDelegate delegate) { + public static ItemStreamReader itemStreamReader(ItemStreamIterableReaderDelegate delegate) { Objects.requireNonNull(delegate, "ItemStreamReader delegate is null"); return StepScopeItemStreamReader.of(() -> ItemStreamIterableReaderAdapter.of(delegate)); } @@ -73,7 +72,7 @@ public static ItemStreamReader itemStreamReader(@NonNull ItemStreamIterab * @param delegate a delegate * @return an adapted ItemStreamReader */ - public static ItemStreamReader itemStreamReader(@NonNull ItemStreamIteratorReaderDelegate delegate) { + public static ItemStreamReader itemStreamReader(ItemStreamIteratorReaderDelegate delegate) { Objects.requireNonNull(delegate, "ItemStreamReader delegate is null"); return StepScopeItemStreamReader.of(() -> ItemStreamIteratorReaderAdapter.of(delegate)); } @@ -86,7 +85,7 @@ public static ItemStreamReader itemStreamReader(@NonNull ItemStreamIterat * @param delegate a delegate * @return an adapted ItemStreamReader */ - public static ItemStreamReader itemStreamReader(@NonNull ItemStreamSimpleReaderDelegate delegate) { + public static ItemStreamReader itemStreamReader(ItemStreamSimpleReaderDelegate delegate) { Objects.requireNonNull(delegate, "ItemStreamReader delegate is null"); return StepScopeItemStreamReader.of(() -> ItemStreamSimpleReaderAdapter.of(delegate)); } @@ -99,7 +98,7 @@ public static ItemStreamReader itemStreamReader(@NonNull ItemStreamSimple * @param delegate a delegate * @return an adapted ItemProcessor */ - public static ItemProcessor itemProcessor(@NonNull ItemProcessorDelegate delegate) { + public static ItemProcessor itemProcessor(ItemProcessorDelegate delegate) { return ItemProcessorAdapter.of(delegate); } @@ -110,7 +109,7 @@ public static ItemProcessor itemProcessor(@NonNull ItemProcessorDel * @param delegate a delegate * @return an adapted ItemStreamWriter */ - public static ItemStreamWriter itemStreamWriter(@NonNull ItemStreamWriterDelegate delegate) { + public static ItemStreamWriter itemStreamWriter(ItemStreamWriterDelegate delegate) { return ItemStreamWriterAdapter.of(delegate); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java index e83b515..75b31f8 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorAdapter.java @@ -21,7 +21,6 @@ import java.util.Objects; import org.springframework.batch.infrastructure.item.ItemProcessor; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemProcessorDelegate} to {@link ItemProcessor}. @@ -38,7 +37,7 @@ public class ItemProcessorAdapter implements ItemProcessor { * @param an item type to process * @param a processed item type */ - public static ItemProcessor of(@NonNull ItemProcessorDelegate delegate) { + public static ItemProcessor of(ItemProcessorDelegate delegate) { return new ItemProcessorAdapter<>(delegate); } @@ -49,7 +48,7 @@ protected ItemProcessorAdapter(ItemProcessorDelegate delegate) { } @Override - public O process(@NonNull I item) { + public O process(I item) { return this.delegate.process(item); } } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java index 5164428..69b118c 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemProcessorDelegate.java @@ -18,9 +18,8 @@ package com.navercorp.spring.batch.plus.step.adapter; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ItemProcessor; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; /** * A delegate for {@link ItemProcessor}. @@ -36,5 +35,5 @@ public interface ItemProcessorDelegate { * @return processed item */ @Nullable - O process(@NonNull I item); + O process(I item); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java index 1fb3d09..4a3ead4 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderAdapter.java @@ -24,7 +24,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; @@ -42,7 +41,7 @@ public class ItemStreamFluxReaderAdapter implements ItemStreamReader { * @return an adapted ItemStreamReader * @param a read item type */ - public static ItemStreamReader of(@NonNull ItemStreamFluxReaderDelegate delegate) { + public static ItemStreamReader of(ItemStreamFluxReaderDelegate delegate) { return new ItemStreamFluxReaderAdapter<>(delegate); } @@ -59,7 +58,7 @@ protected ItemStreamFluxReaderAdapter(ItemStreamFluxReaderDelegate delegate) } @Override - public void open(@NonNull ExecutionContext executionContext) { + public void open(ExecutionContext executionContext) { this.delegate.onOpenRead(executionContext); this.flux = this.delegate.readFlux(executionContext); } @@ -75,7 +74,7 @@ public T read() { } @Override - public void update(@NonNull ExecutionContext executionContext) { + public void update(ExecutionContext executionContext) { this.delegate.onUpdateRead(executionContext); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java index d0cb5a3..7c1822e 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderDelegate.java @@ -20,7 +20,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; import reactor.core.publisher.Flux; @@ -36,7 +35,7 @@ public interface ItemStreamFluxReaderDelegate { * * @param executionContext an execution context */ - default void onOpenRead(@NonNull ExecutionContext executionContext) { + default void onOpenRead(ExecutionContext executionContext) { } /** @@ -45,15 +44,14 @@ default void onOpenRead(@NonNull ExecutionContext executionContext) { * @param executionContext an execution context * @return a flux to read item */ - @NonNull - Flux readFlux(@NonNull ExecutionContext executionContext); + Flux readFlux(ExecutionContext executionContext); /** * A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. * * @param executionContext an execution context */ - default void onUpdateRead(@NonNull ExecutionContext executionContext) { + default void onUpdateRead(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java index 44b34b5..eed63e1 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderAdapter.java @@ -24,7 +24,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemStreamIterableReaderDelegate} to {@link ItemStreamReader}. @@ -40,7 +39,7 @@ public class ItemStreamIterableReaderAdapter implements ItemStreamReader { * @return an adapted ItemStreamReader * @param a read item type */ - public static ItemStreamReader of(@NonNull ItemStreamIterableReaderDelegate delegate) { + public static ItemStreamReader of(ItemStreamIterableReaderDelegate delegate) { return new ItemStreamIterableReaderAdapter<>(delegate); } @@ -55,7 +54,7 @@ protected ItemStreamIterableReaderAdapter(ItemStreamIterableReaderDelegate de } @Override - public void open(@NonNull ExecutionContext executionContext) { + public void open(ExecutionContext executionContext) { this.delegate.onOpenRead(executionContext); this.iterable = this.delegate.readIterable(executionContext); } @@ -71,7 +70,7 @@ public T read() { } @Override - public void update(@NonNull ExecutionContext executionContext) { + public void update(ExecutionContext executionContext) { this.delegate.onUpdateRead(executionContext); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java index f5d545e..ba9d8c3 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderDelegate.java @@ -20,7 +20,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; /** * A delegate for {@link ItemStreamReader} which uses {@link Iterable}. @@ -34,7 +33,7 @@ public interface ItemStreamIterableReaderDelegate { * * @param executionContext an execution context */ - default void onOpenRead(@NonNull ExecutionContext executionContext) { + default void onOpenRead(ExecutionContext executionContext) { } /** @@ -43,15 +42,14 @@ default void onOpenRead(@NonNull ExecutionContext executionContext) { * @param executionContext an execution context * @return an iterable to read item */ - @NonNull - Iterable readIterable(@NonNull ExecutionContext executionContext); + Iterable readIterable(ExecutionContext executionContext); /** * A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. * * @param executionContext an execution context */ - default void onUpdateRead(@NonNull ExecutionContext executionContext) { + default void onUpdateRead(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java index b2b10c5..c802306 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderAdapter.java @@ -23,7 +23,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemStreamIteratorReaderDelegate} to {@link ItemStreamReader}. @@ -39,7 +38,7 @@ public class ItemStreamIteratorReaderAdapter implements ItemStreamReader { * @return an adapted ItemStreamReader * @param a read item type */ - public static ItemStreamReader of(@NonNull ItemStreamIteratorReaderDelegate delegate) { + public static ItemStreamReader of(ItemStreamIteratorReaderDelegate delegate) { return new ItemStreamIteratorReaderAdapter<>(delegate); } @@ -52,7 +51,7 @@ protected ItemStreamIteratorReaderAdapter(ItemStreamIteratorReaderDelegate de } @Override - public void open(@NonNull ExecutionContext executionContext) { + public void open(ExecutionContext executionContext) { this.delegate.onOpenRead(executionContext); this.iterator = this.delegate.readIterator(executionContext); } @@ -68,7 +67,7 @@ public T read() { } @Override - public void update(@NonNull ExecutionContext executionContext) { + public void update(ExecutionContext executionContext) { this.delegate.onUpdateRead(executionContext); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java index 8c2e19e..6c2eec4 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderDelegate.java @@ -22,7 +22,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; /** * A delegate for {@link ItemStreamReader} which uses {@link Iterator}. @@ -36,7 +35,7 @@ public interface ItemStreamIteratorReaderDelegate { * * @param executionContext an execution context */ - default void onOpenRead(@NonNull ExecutionContext executionContext) { + default void onOpenRead(ExecutionContext executionContext) { } /** @@ -45,15 +44,14 @@ default void onOpenRead(@NonNull ExecutionContext executionContext) { * @param executionContext an execution context * @return an iterator to read item */ - @NonNull - Iterator readIterator(@NonNull ExecutionContext executionContext); + Iterator readIterator(ExecutionContext executionContext); /** * A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. * * @param executionContext an execution context */ - default void onUpdateRead(@NonNull ExecutionContext executionContext) { + default void onUpdateRead(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java index a4b7d8f..b8517b2 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderAdapter.java @@ -22,7 +22,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemStreamSimpleReaderDelegate} to {@link ItemStreamReader}. @@ -38,7 +37,7 @@ public class ItemStreamSimpleReaderAdapter implements ItemStreamReader { * @return an adapted ItemStreamReader * @param a read item type */ - public static ItemStreamReader of(@NonNull ItemStreamSimpleReaderDelegate delegate) { + public static ItemStreamReader of(ItemStreamSimpleReaderDelegate delegate) { return new ItemStreamSimpleReaderAdapter<>(delegate); } @@ -49,7 +48,7 @@ protected ItemStreamSimpleReaderAdapter(ItemStreamSimpleReaderDelegate delega } @Override - public void open(@NonNull ExecutionContext executionContext) { + public void open(ExecutionContext executionContext) { this.delegate.onOpenRead(executionContext); } @@ -59,7 +58,7 @@ public T read() { } @Override - public void update(@NonNull ExecutionContext executionContext) { + public void update(ExecutionContext executionContext) { this.delegate.onUpdateRead(executionContext); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java index ea92042..78c569d 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderDelegate.java @@ -18,10 +18,9 @@ package com.navercorp.spring.batch.plus.step.adapter; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; /** * A simple delegate for {@link ItemStreamReader}. @@ -35,7 +34,7 @@ public interface ItemStreamSimpleReaderDelegate { * * @param executionContext an execution context */ - default void onOpenRead(@NonNull ExecutionContext executionContext) { + default void onOpenRead(ExecutionContext executionContext) { } /** @@ -51,7 +50,7 @@ default void onOpenRead(@NonNull ExecutionContext executionContext) { * * @param executionContext an execution context */ - default void onUpdateRead(@NonNull ExecutionContext executionContext) { + default void onUpdateRead(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java index 74d2f88..50e0c9f 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterAdapter.java @@ -23,7 +23,6 @@ import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamWriter; -import org.springframework.lang.NonNull; /** * An adapter which adapt {@link ItemStreamWriterDelegate} to {@link ItemStreamWriter}. @@ -39,7 +38,7 @@ public class ItemStreamWriterAdapter implements ItemStreamWriter { * @return an adapted ItemStreamWriter * @param an item type to write */ - public static ItemStreamWriter of(@NonNull ItemStreamWriterDelegate delegate) { + public static ItemStreamWriter of(ItemStreamWriterDelegate delegate) { return new ItemStreamWriterAdapter<>(delegate); } @@ -50,17 +49,17 @@ protected ItemStreamWriterAdapter(ItemStreamWriterDelegate delegate) { } @Override - public void open(@NonNull ExecutionContext executionContext) { + public void open(ExecutionContext executionContext) { this.delegate.onOpenWrite(executionContext); } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { this.delegate.write(chunk); } @Override - public void update(@NonNull ExecutionContext executionContext) { + public void update(ExecutionContext executionContext) { this.delegate.onUpdateWrite(executionContext); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java index 996b57b..27fa4cb 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamWriterDelegate.java @@ -21,7 +21,6 @@ import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamWriter; -import org.springframework.lang.NonNull; /** * A delegate for {@link ItemStreamWriter}. @@ -34,20 +33,20 @@ public interface ItemStreamWriterDelegate { * A delegate method for {@link ItemStreamWriter#open(ExecutionContext)}. * @param executionContext an execution context */ - default void onOpenWrite(@NonNull ExecutionContext executionContext) { + default void onOpenWrite(ExecutionContext executionContext) { } /** * A delegate method for {@link ItemStreamWriter#write(Chunk)}. * @param chunk chunk to write */ - void write(@NonNull Chunk chunk); + void write(Chunk chunk); /** * A delegate method for {@link ItemStreamWriter#update(ExecutionContext)}. * @param executionContext an execution context */ - default void onUpdateWrite(@NonNull ExecutionContext executionContext) { + default void onUpdateWrite(ExecutionContext executionContext) { } /** diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java index b52e5fa..1d5f067 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/StepScopeItemStreamReader.java @@ -30,7 +30,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamException; import org.springframework.batch.infrastructure.item.ItemStreamReader; -import org.springframework.lang.NonNull; /** * A {@link StepScope} bound proxy implementation. @@ -62,7 +61,7 @@ protected StepScopeItemStreamReader(Supplier> readerGenerato } @Override - public void open(@NonNull ExecutionContext executionContext) throws ItemStreamException { + public void open(ExecutionContext executionContext) throws ItemStreamException { getDelegate().open(executionContext); } @@ -72,7 +71,7 @@ public T read() throws Exception { } @Override - public void update(@NonNull ExecutionContext executionContext) throws ItemStreamException { + public void update(ExecutionContext executionContext) throws ItemStreamException { getDelegate().update(executionContext); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/package-info.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/package-info.java index 66df924..772c5ea 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/package-info.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/step/adapter/package-info.java @@ -19,4 +19,7 @@ /** * An extensions for spring batch step adapter concerns. */ +@NullMarked package com.navercorp.spring.batch.plus.step.adapter; + +import org.jspecify.annotations.NullMarked; From 3745b46b5c76d78174810ce8e57859190255d8df Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 18 May 2026 20:47:33 +0900 Subject: [PATCH 06/45] Replace Spring Batch 6.0 deprecated APIs in Java tests Signed-off-by: Taeik Lim --- ...mReaderProcessorWriterIntegrationTest.java | 38 ++++++++++--------- ...ItemStreamReaderWriterIntegrationTest.java | 38 ++++++++++--------- .../ItemStreamFluxReaderProcessorIT.java | 16 ++++---- ...ItemStreamFluxReaderProcessorWriterIT.java | 16 ++++---- .../adapter/ItemStreamFluxReaderWriterIT.java | 16 ++++---- .../ItemStreamIterableReaderProcessorIT.java | 16 ++++---- ...StreamIterableReaderProcessorWriterIT.java | 16 ++++---- .../ItemStreamIterableReaderWriterIT.java | 16 ++++---- .../ItemStreamIteratorReaderProcessorIT.java | 16 ++++---- ...StreamIteratorReaderProcessorWriterIT.java | 16 ++++---- .../ItemStreamIteratorReaderWriterIT.java | 16 ++++---- .../ItemStreamSimpleReaderProcessorIT.java | 16 ++++---- ...emStreamSimpleReaderProcessorWriterIT.java | 16 ++++---- .../ItemStreamSimpleReaderWriterIT.java | 16 ++++---- .../job/metadata/DeleteMetadataJobTest.java | 24 ++++++------ .../job/metadata/TestJobRepositoryConfig.java | 4 +- 16 files changed, 164 insertions(+), 132 deletions(-) diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java index 1b9eaa1..c74a50e 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderProcessorWriterIntegrationTest.java @@ -38,7 +38,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -109,20 +109,21 @@ void testReaderProcessorWriter() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .processor(AdapterFactory.itemProcessor(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -130,7 +131,7 @@ void testReaderProcessorWriter() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); @@ -154,20 +155,21 @@ void testReaderProcessorWriterWithSameTaskletShouldKeepContext() throws Exceptio Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .processor(AdapterFactory.itemProcessor(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -175,7 +177,7 @@ void testReaderProcessorWriterWithSameTaskletShouldKeepContext() throws Exceptio JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); @@ -195,20 +197,21 @@ void testStepScopeReaderProcessorWriter() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .processor(AdapterFactory.itemProcessor(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -216,7 +219,7 @@ void testStepScopeReaderProcessorWriter() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); @@ -240,20 +243,21 @@ void testStepScopeReaderProcessorWriterWithSameTaskletShouldNotKeepCountContext( Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .processor(AdapterFactory.itemProcessor(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -261,7 +265,7 @@ void testStepScopeReaderProcessorWriterWithSameTaskletShouldNotKeepCountContext( JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java index 4c4e008..b636bce 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamReaderWriterIntegrationTest.java @@ -38,7 +38,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -105,19 +105,20 @@ void testReaderWriter() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -125,7 +126,7 @@ void testReaderWriter() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); @@ -149,19 +150,20 @@ void testReaderWriterWithSameTaskletShouldKeepCountContext() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -169,7 +171,7 @@ void testReaderWriterWithSameTaskletShouldKeepCountContext() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); @@ -188,19 +190,20 @@ void testStepScopeReaderWriter() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -208,7 +211,7 @@ void testStepScopeReaderWriter() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); @@ -232,19 +235,20 @@ void testStepScopeReaderWriterWithSameTaskletShouldNotKeepCountContext() throws Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(AdapterFactory.itemStreamReader(testTasklet)) .writer(AdapterFactory.itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int beforeRepeatCount = ThreadLocalRandom.current().nextInt(0, 3); for (int i = 0; i < beforeRepeatCount; ++i) { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - jobLauncher.run(job, jobParameters); + jobOperator.start(job, jobParameters); } logger.debug("beforeRepeatCount: {}", beforeRepeatCount); @@ -252,7 +256,7 @@ void testStepScopeReaderWriterWithSameTaskletShouldNotKeepCountContext() throws JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); // then assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java index ce49f29..3c73329 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java @@ -39,7 +39,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.ExecutionContext; @@ -74,7 +74,8 @@ void fluxReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -82,7 +83,7 @@ void fluxReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -90,7 +91,7 @@ void fluxReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -122,7 +123,8 @@ void fluxReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -130,7 +132,7 @@ void fluxReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -138,7 +140,7 @@ void fluxReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java index d00fcf2..b3fe852 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -76,14 +76,15 @@ void fluxReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exceptio Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -91,7 +92,7 @@ void fluxReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exceptio JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -127,14 +128,15 @@ void fluxReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exceptio Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -142,7 +144,7 @@ void fluxReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exceptio JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java index 2285443..aa95a8c 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java @@ -39,7 +39,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -75,13 +75,14 @@ void fluxReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -89,7 +90,7 @@ void fluxReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -124,13 +125,14 @@ void fluxReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -138,7 +140,7 @@ void fluxReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java index 938c02d..26f0627 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.ExecutionContext; @@ -73,7 +73,8 @@ void iterableReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -81,7 +82,7 @@ void iterableReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -89,7 +90,7 @@ void iterableReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -121,7 +122,8 @@ void iterableReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -129,7 +131,7 @@ void iterableReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -137,7 +139,7 @@ void iterableReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java index de2b424..c38e293 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java @@ -41,7 +41,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -75,14 +75,15 @@ void iterableReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exce Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -90,7 +91,7 @@ void iterableReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exce JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -126,14 +127,15 @@ void iterableReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -141,7 +143,7 @@ void iterableReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java index 9fb0564..700f330 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -74,13 +74,14 @@ void iterableReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -88,7 +89,7 @@ void iterableReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -123,13 +124,14 @@ void iterableReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -137,7 +139,7 @@ void iterableReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java index 09ee269..c2a2e64 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.ExecutionContext; @@ -73,7 +73,8 @@ void iteratorReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -81,7 +82,7 @@ void iteratorReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -89,7 +90,7 @@ void iteratorReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -120,7 +121,8 @@ void iteratorReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -128,7 +130,7 @@ void iteratorReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -136,7 +138,7 @@ void iteratorReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java index 965069e..b3b5f0d 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java @@ -41,7 +41,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -75,14 +75,15 @@ void iteratorReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exce Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -90,7 +91,7 @@ void iteratorReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exce JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -126,14 +127,15 @@ void iteratorReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -141,7 +143,7 @@ void iteratorReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java index c364188..5f31191 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -74,13 +74,14 @@ void iteratorReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -88,7 +89,7 @@ void iteratorReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -123,13 +124,14 @@ void iteratorReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -137,7 +139,7 @@ void iteratorReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java index e869909..4165430 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java @@ -39,7 +39,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.ExecutionContext; @@ -72,7 +72,8 @@ void simpleReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -80,7 +81,7 @@ void simpleReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -88,7 +89,7 @@ void simpleReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -117,7 +118,8 @@ void simpleReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer($ -> { @@ -125,7 +127,7 @@ void simpleReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -133,7 +135,7 @@ void simpleReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java index 3fec152..d0c1cfd 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java @@ -40,7 +40,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -74,14 +74,15 @@ void simpleReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Except Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -89,7 +90,7 @@ void simpleReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Except JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -123,14 +124,15 @@ void simpleReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Except Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .processor(itemProcessor(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -138,7 +140,7 @@ void simpleReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Except JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java index a29fb06..09cf9b9 100644 --- a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java @@ -39,7 +39,7 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.infrastructure.item.Chunk; @@ -73,13 +73,14 @@ void simpleReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -87,7 +88,7 @@ void simpleReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } @@ -120,13 +121,14 @@ void simpleReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { Job job = new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(chunkCount, new ResourcelessTransactionManager()) + .chunk(chunkCount) + .transactionManager(new ResourcelessTransactionManager()) .reader(itemStreamReader(testTasklet)) .writer(itemStreamWriter(testTasklet)) .build() ) .build(); - JobLauncher jobLauncher = context.getBean(JobLauncher.class); + JobOperator jobOperator = context.getBean(JobOperator.class); int repeatCount = ThreadLocalRandom.current().nextInt(1, 5); List jobExecutions = new ArrayList<>(); @@ -134,7 +136,7 @@ void simpleReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString(UUID.randomUUID().toString(), UUID.randomUUID().toString()) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); jobExecutions.add(jobExecution); } diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java index 512d782..b82a25b 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/DeleteMetadataJobTest.java @@ -38,8 +38,8 @@ import org.springframework.batch.core.job.parameters.InvalidJobParametersException; import org.springframework.batch.core.job.parameters.JobParameters; import org.springframework.batch.core.job.parameters.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; +import org.springframework.batch.core.launch.JobOperator; +import org.springframework.batch.core.launch.support.TaskExecutorJobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.task.SyncTaskExecutor; @@ -56,23 +56,23 @@ class DeleteMetadataJobTest { Job job; - JobLauncher jobLauncher; + JobOperator jobOperator; @BeforeEach void setUp( @Autowired DataSource dataSource, @Autowired String tablePrefix ) { - TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); - jobLauncher.setJobRepository(this.jobRepository); - jobLauncher.setTaskExecutor(new SyncTaskExecutor()); - this.jobLauncher = jobLauncher; + TaskExecutorJobOperator jobOperator = new TaskExecutorJobOperator(); + jobOperator.setJobRepository(this.jobRepository); + jobOperator.setTaskExecutor(new SyncTaskExecutor()); + this.jobOperator = jobOperator; this.job = new DeleteMetadataJobBuilder(this.jobRepository, dataSource) .tablePrefix(tablePrefix) .build(); - // JobLauncher.run() in Spring Batch 6.0 creates the JobInstance before validating parameters, + // JobOperator.start() in Spring Batch 6.0 creates the JobInstance before validating parameters, // so failed validations leave orphan instances. Delete by instance to also drop their executions. for (String jobName : this.jobRepository.getJobNames()) { for (JobInstance instance : this.jobRepository.findJobInstances(jobName)) { @@ -91,7 +91,7 @@ void testRunFailWithInvalidParameter() { // when, then assertThatExceptionOfType(InvalidJobParametersException.class) .isThrownBy(() -> - jobLauncher.run(job, jobParameters) + jobOperator.start(job, jobParameters) ) .withMessageContaining("do not contain required keys: [baseDate]"); } @@ -111,7 +111,7 @@ void testRunWhenNeedNotToDelete() throws Exception { .toJobParameters(); // when - JobExecution actualExecution = jobLauncher.run(job, jobParameters); + JobExecution actualExecution = jobOperator.start(job, jobParameters); // then assertThat(actualExecution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED); @@ -150,7 +150,7 @@ void testRunWhenNeedToDelete() throws Exception { JobParameters jobParameters = new JobParametersBuilder() .addString("baseDate", "2022/03/15") .toJobParameters(); - JobExecution actualExecution = jobLauncher.run(job, jobParameters); + JobExecution actualExecution = jobOperator.start(job, jobParameters); // then assertThat(actualExecution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED); @@ -183,7 +183,7 @@ void testRunShouldNotRemoveWhenDryRun() throws Exception { .addString("baseDate", "2022/03/15") .addString("dryRun", "true") .toJobParameters(); - JobExecution actualExecution = jobLauncher.run(job, jobParameters); + JobExecution actualExecution = jobOperator.start(job, jobParameters); // then assertThat(actualExecution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED); diff --git a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/TestJobRepositoryConfig.java b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/TestJobRepositoryConfig.java index df8403e..864bb2f 100644 --- a/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/TestJobRepositoryConfig.java +++ b/spring-batch-plus/src/test/java/com/navercorp/spring/batch/plus/job/metadata/TestJobRepositoryConfig.java @@ -31,7 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; +import org.springframework.batch.core.repository.support.JdbcJobRepositoryFactoryBean; import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.context.annotation.Bean; import org.springframework.core.io.ClassPathResource; @@ -70,7 +70,7 @@ String tablePrefix() { @Bean JobRepository jobRepository(DataSource dataSource, String tablePrefix) throws Exception { - JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); + JdbcJobRepositoryFactoryBean factory = new JdbcJobRepositoryFactoryBean(); factory.setDataSource(dataSource); factory.setTransactionManager(new DataSourceTransactionManager(dataSource)); factory.setTablePrefix(tablePrefix); From e9fdb214ab85edb1d60a7c331c02606b262596ba Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 20 May 2026 15:17:57 +0900 Subject: [PATCH 07/45] Migrate Java samples to Spring Batch 6.0 and Boot 4.0 Signed-off-by: Taeik Lim --- .../build.gradle.kts | 6 +- .../sample/clear/SampleApplicationTest.java | 25 ++---- .../plus/sample/clear/TestJobConfig.java | 4 +- .../clearwithid/SampleApplicationTest.java | 23 ++--- .../sample/clearwithid/TestJobConfig.java | 4 +- .../comparison/bad/SampleApplicationTest.java | 83 +++++++++++-------- .../sample/comparison/bad/TestJobConfig.java | 34 +------- .../good/SampleApplicationTest.java | 83 +++++++++++-------- .../sample/comparison/good/TestJobConfig.java | 34 +------- .../build.gradle.kts | 6 +- .../customdryrun/JdbcConfig.java | 2 +- .../customdryrun/SampleApplicationTest.java | 10 +-- .../customdryrun/TestJobConfig.java | 8 +- .../deletemetadata/dryrun/JdbcConfig.java | 2 +- .../dryrun/SampleApplicationTest.java | 10 +-- .../deletemetadata/dryrun/TestJobConfig.java | 8 +- .../deletemetadata/formatter/JdbcConfig.java | 2 +- .../formatter/SampleApplicationTest.java | 10 +-- .../formatter/TestJobConfig.java | 8 +- .../deletemetadata/jobname/JdbcConfig.java | 2 +- .../jobname/SampleApplicationTest.java | 10 +-- .../deletemetadata/jobname/TestJobConfig.java | 8 +- .../parametername/JdbcConfig.java | 2 +- .../parametername/SampleApplicationTest.java | 10 +-- .../parametername/TestJobConfig.java | 8 +- .../deletemetadata/plain/JdbcConfig.java | 2 +- .../plain/SampleApplicationTest.java | 10 +-- .../deletemetadata/plain/TestJobConfig.java | 8 +- .../deletemetadata/prefix/JdbcConfig.java | 2 +- .../prefix/SampleApplicationTest.java | 10 +-- .../deletemetadata/prefix/TestJobConfig.java | 8 +- .../prefixfromvariable/JdbcConfig.java | 2 +- .../SampleApplicationTest.java | 10 +-- .../prefixfromvariable/TestJobConfig.java | 14 ++-- .../test/resources/sql/schema-h2-custom.sql | 2 +- .../build.gradle.kts | 8 +- .../flux/callback/SampleApplicationTest.java | 8 +- .../sample/flux/callback/SampleTasklet.java | 4 +- .../sample/flux/callback/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../flux/readerprocessor/SampleTasklet.java | 2 +- .../flux/readerprocessor/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../readerprocessorwriter/SampleTasklet.java | 4 +- .../readerprocessorwriter/TestJobConfig.java | 2 +- .../readerwriter/SampleApplicationTest.java | 8 +- .../flux/readerwriter/SampleTasklet.java | 4 +- .../flux/readerwriter/TestJobConfig.java | 2 +- .../callback/SampleApplicationTest.java | 8 +- .../iterable/callback/SampleTasklet.java | 4 +- .../iterable/callback/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../readerprocessor/SampleTasklet.java | 2 +- .../readerprocessor/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../readerprocessorwriter/SampleTasklet.java | 4 +- .../readerprocessorwriter/TestJobConfig.java | 2 +- .../readerwriter/SampleApplicationTest.java | 8 +- .../iterable/readerwriter/SampleTasklet.java | 4 +- .../iterable/readerwriter/TestJobConfig.java | 2 +- .../callback/SampleApplicationTest.java | 8 +- .../iterator/callback/SampleTasklet.java | 4 +- .../iterator/callback/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../readerprocessor/SampleTasklet.java | 2 +- .../readerprocessor/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../readerprocessorwriter/SampleTasklet.java | 4 +- .../readerprocessorwriter/TestJobConfig.java | 2 +- .../readerwriter/SampleApplicationTest.java | 8 +- .../iterator/readerwriter/SampleTasklet.java | 4 +- .../iterator/readerwriter/TestJobConfig.java | 2 +- .../callback/SampleApplicationTest.java | 8 +- .../sample/simple/callback/SampleTasklet.java | 4 +- .../sample/simple/callback/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../simple/readerprocessor/TestJobConfig.java | 2 +- .../SampleApplicationTest.java | 8 +- .../readerprocessorwriter/SampleTasklet.java | 2 +- .../readerprocessorwriter/TestJobConfig.java | 2 +- .../readerwriter/SampleApplicationTest.java | 8 +- .../simple/readerwriter/SampleTasklet.java | 2 +- .../simple/readerwriter/TestJobConfig.java | 2 +- 83 files changed, 318 insertions(+), 370 deletions(-) diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts b/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts index 495c792..18dec13 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts @@ -27,14 +27,14 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.5") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus")) - runtimeOnly("com.h2database:h2:2.1.214") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.java index e0fcc87..4161006 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.java @@ -22,12 +22,9 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -37,19 +34,11 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); - JobExplorer jobExplorer = applicationContext.getBean(JobExplorer.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean(Job.class); - JobParameters firstJobParameters = new JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters(); - JobExecution firstJobExecution = jobLauncher.run(job, firstJobParameters); - - JobParameters secondJobParameters = new JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters(); - JobExecution secondJobExecution = jobLauncher.run(job, secondJobParameters); + JobExecution firstJobExecution = jobOperator.startNextInstance(job); + JobExecution secondJobExecution = jobOperator.startNextInstance(job); // first assert BatchStatus.COMPLETED.equals(firstJobExecution.getStatus()); @@ -57,7 +46,7 @@ void run() throws Exception { System.out.printf("first: %s, jobParameters: %s%n", firstJobExecution.getStatus(), firstJobExecution.getJobParameters()); - // second) + // second assert BatchStatus.COMPLETED.equals(secondJobExecution.getStatus()); assert 2L == Objects.requireNonNull(secondJobExecution.getJobParameters().getLong("run.id")); System.out.printf("second: %s, jobParameters: %s%n", secondJobExecution.getStatus(), diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.java index f008e2b..b77061d 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.java @@ -18,11 +18,11 @@ package com.navercorp.spring.batch.plus.sample.clear; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.java index 5400eb9..65670ba 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.java @@ -22,12 +22,9 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -37,19 +34,11 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); - JobExplorer jobExplorer = applicationContext.getBean(JobExplorer.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean(Job.class); - JobParameters firstJobParameters = new JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters(); - JobExecution firstJobExecution = jobLauncher.run(job, firstJobParameters); - - JobParameters secondJobParameters = new JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters(); - JobExecution secondJobExecution = jobLauncher.run(job, secondJobParameters); + JobExecution firstJobExecution = jobOperator.startNextInstance(job); + JobExecution secondJobExecution = jobOperator.startNextInstance(job); // first assert BatchStatus.COMPLETED.equals(firstJobExecution.getStatus()); diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.java index 8f0c58e..ef0d551 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.java @@ -18,11 +18,11 @@ package com.navercorp.spring.batch.plus.sample.clearwithid; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/SampleApplicationTest.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/SampleApplicationTest.java index ec80898..73f95ca 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/SampleApplicationTest.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/SampleApplicationTest.java @@ -22,58 +22,69 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.launch.JobOperator; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; +/** + * Demonstrates the residual {@link org.springframework.batch.core.job.parameters.RunIdIncrementer} + * behavior that {@link com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer} was designed to + * address: previous identifying parameters are copied forward into each new JobInstance. + * + *

The Spring Batch 6.0 standard flow ({@code JobOperator.start} + {@code startNextInstance}) + * never produces a prev JobExecution whose JobParameters contain keys other than {@code run.id}, + * so the difference between {@code RunIdIncrementer} and {@code ClearRunIdIncrementer} is + * invisible in a clean 6.0 project. The legacy state seeded here reproduces a 5.x → 6.0 + * migration: prior executions populated {@code BATCH_JOB_EXECUTION_PARAMS} via the now-removed + * {@code JobParametersBuilder.getNextJobParameters} pattern, leaving non-runId keys on the + * latest JobInstance. When the upgraded application then calls {@code startNextInstance}, + * {@code RunIdIncrementer} keeps those legacy keys alive on every subsequent JobInstance + * forever. The companion {@code good} sample uses {@code ClearRunIdIncrementer} to cut that + * chain. + */ @SpringBootApplication public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); - JobExplorer jobExplorer = applicationContext.getBean(JobExplorer.class); + JobRepository jobRepository = applicationContext.getBean(JobRepository.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean(Job.class); - JobParameters firstJobParameters = new JobParametersBuilder(jobExplorer) + // Seed the legacy state a 5.x project would leave behind after upgrading to 6.0. + // See the class-level Javadoc for the migration context. + JobParameters legacyParams = new JobParametersBuilder() .addString("stringValue", "1") .addString("longValue", "10") - .getNextJobParameters(job) + .addLong("run.id", 5L) .toJobParameters(); - JobExecution firstJobExecution = jobLauncher.run(job, firstJobParameters); + JobInstance legacyInstance = jobRepository.createJobInstance(job.getName(), legacyParams); + JobExecution legacyExecution = jobRepository.createJobExecution(legacyInstance, legacyParams, + new ExecutionContext()); + legacyExecution.setStatus(BatchStatus.COMPLETED); + legacyExecution.setExitStatus(ExitStatus.COMPLETED); + jobRepository.update(legacyExecution); - JobParameters secondJobParameters = new JobParametersBuilder(jobExplorer) - .addString("longValue", "20") - .getNextJobParameters(job) - .toJobParameters(); - JobExecution secondJobExecution = jobLauncher.run(job, secondJobParameters); + // Launch the next instance: incrementer.getNext(legacyParams) is invoked under the hood. + JobExecution nextExecution = jobOperator.startNextInstance(job); - // first - assert BatchStatus.COMPLETED.equals(firstJobExecution.getStatus()); - assert 1L == Objects.requireNonNull(firstJobExecution.getJobParameters().getLong("run.id")); - assert "1".equals(firstJobExecution.getJobParameters().getString("stringValue")); - assert "10".equals(firstJobExecution.getJobParameters().getString("longValue")); - assert 11L == firstJobExecution.getExecutionContext().getLong("result"); - System.out.printf("first: %s, jobParameters: %s, result: %d%n", - firstJobExecution.getStatus(), - firstJobExecution.getJobParameters(), - firstJobExecution.getExecutionContext().getLong("result")); + assert BatchStatus.COMPLETED.equals(nextExecution.getStatus()); + JobParameters nextParams = nextExecution.getJobParameters(); - // second - assert BatchStatus.COMPLETED.equals(secondJobExecution.getStatus()); - assert 2L == Objects.requireNonNull(secondJobExecution.getJobParameters().getLong("run.id")); - assert "1".equals(secondJobExecution.getJobParameters().getString("stringValue")); - assert "20".equals(secondJobExecution.getJobParameters().getString("longValue")); - assert 21L == secondJobExecution.getExecutionContext().getLong("result"); - System.out.printf("second: %s, jobParameters: %s, result: %d%n", - secondJobExecution.getStatus(), - secondJobExecution.getJobParameters(), - secondJobExecution.getExecutionContext().getLong("result")); + // RunIdIncrementer copies the entire previous parameter set, so non-runId identifying + // keys persist into every subsequent JobInstance. + assert 6L == Objects.requireNonNull(nextParams.getLong("run.id")); + assert "1".equals(nextParams.getString("stringValue")); + assert "10".equals(nextParams.getString("longValue")); + System.out.printf("bad: params=%s%n", nextParams); } } diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/TestJobConfig.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/TestJobConfig.java index da4a5c5..df17fc3 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/TestJobConfig.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/bad/TestJobConfig.java @@ -18,16 +18,12 @@ package com.navercorp.spring.batch.plus.sample.comparison.bad; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.configuration.annotation.StepScope; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.core.step.tasklet.Tasklet; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; @@ -45,33 +41,11 @@ public Job testJob( .start( new StepBuilder("testStep", jobRepository) .tasklet( - testTasklet(null, null), + (contribution, chunkContext) -> RepeatStatus.FINISHED, transactionManager ) .build() ) .build(); } - - @StepScope - @Bean - public Tasklet testTasklet( - @Value("#{jobParameters['longValue']}") Long longValue, - @Value("#{jobParameters['stringValue']}") String stringValue - ) { - return (contribution, chunkContext) -> { - Long result; - if (stringValue != null) { - result = longValue + Long.parseLong(stringValue); - } else { - result = 999L; - } - - ExecutionContext jobExecutionContext = contribution.getStepExecution() - .getJobExecution() - .getExecutionContext(); - jobExecutionContext.putLong("result", result); - return RepeatStatus.FINISHED; - }; - } } diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/SampleApplicationTest.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/SampleApplicationTest.java index b1ea2fd..f4518d0 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/SampleApplicationTest.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/SampleApplicationTest.java @@ -22,58 +22,69 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.launch.JobOperator; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; +/** + * Demonstrates how {@link com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer} drops + * every previous identifying parameter so each new JobInstance carries only the incremented + * {@code run.id}. + * + *

The Spring Batch 6.0 standard flow ({@code JobOperator.start} + {@code startNextInstance}) + * never produces a prev JobExecution whose JobParameters contain keys other than {@code run.id}, + * so the difference between + * {@link org.springframework.batch.core.job.parameters.RunIdIncrementer} and + * {@code ClearRunIdIncrementer} is invisible in a clean 6.0 project. The legacy state seeded + * here reproduces a 5.x → 6.0 migration: prior executions populated + * {@code BATCH_JOB_EXECUTION_PARAMS} via the now-removed + * {@code JobParametersBuilder.getNextJobParameters} pattern, leaving non-runId keys on the + * latest JobInstance. {@code ClearRunIdIncrementer} cuts the chain so the next JobInstance + * starts from a minimal identity. The companion {@code bad} sample shows what + * {@code RunIdIncrementer} does with the same seed. + */ @SpringBootApplication public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); - JobExplorer jobExplorer = applicationContext.getBean(JobExplorer.class); + JobRepository jobRepository = applicationContext.getBean(JobRepository.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean(Job.class); - JobParameters firstJobParameters = new JobParametersBuilder(jobExplorer) + // Same legacy seed as the "bad" scenario for an apples-to-apples comparison. + // See the class-level Javadoc for the migration context. + JobParameters legacyParams = new JobParametersBuilder() .addString("stringValue", "1") .addString("longValue", "10") - .getNextJobParameters(job) + .addLong("run.id", 5L) .toJobParameters(); - JobExecution firstJobExecution = jobLauncher.run(job, firstJobParameters); + JobInstance legacyInstance = jobRepository.createJobInstance(job.getName(), legacyParams); + JobExecution legacyExecution = jobRepository.createJobExecution(legacyInstance, legacyParams, + new ExecutionContext()); + legacyExecution.setStatus(BatchStatus.COMPLETED); + legacyExecution.setExitStatus(ExitStatus.COMPLETED); + jobRepository.update(legacyExecution); - JobParameters secondJobParameters = new JobParametersBuilder(jobExplorer) - .addString("longValue", "20") - .getNextJobParameters(job) - .toJobParameters(); - JobExecution secondJobExecution = jobLauncher.run(job, secondJobParameters); + JobExecution nextExecution = jobOperator.startNextInstance(job); - // first - assert BatchStatus.COMPLETED.equals(firstJobExecution.getStatus()); - assert 1L == Objects.requireNonNull(firstJobExecution.getJobParameters().getLong("run.id")); - assert "1".equals(firstJobExecution.getJobParameters().getString("stringValue")); - assert "10".equals(firstJobExecution.getJobParameters().getString("longValue")); - assert 11L == firstJobExecution.getExecutionContext().getLong("result"); - System.out.printf("first: %s, jobParameters: %s, result: %d%n", - firstJobExecution.getStatus(), - firstJobExecution.getJobParameters(), - firstJobExecution.getExecutionContext().getLong("result")); + assert BatchStatus.COMPLETED.equals(nextExecution.getStatus()); + JobParameters nextParams = nextExecution.getJobParameters(); - // second - assert BatchStatus.COMPLETED.equals(secondJobExecution.getStatus()); - assert 2L == Objects.requireNonNull(secondJobExecution.getJobParameters().getLong("run.id")); - assert null == secondJobExecution.getJobParameters().getString("stringValue"); - assert "20".equals(secondJobExecution.getJobParameters().getString("longValue")); - assert 999L == secondJobExecution.getExecutionContext().getLong("result"); - System.out.printf("second: %s, jobParameters: %s, result: %d%n", - secondJobExecution.getStatus(), - secondJobExecution.getJobParameters(), - secondJobExecution.getExecutionContext().getLong("result")); + // ClearRunIdIncrementer drops every previous identifying key and keeps only run.id, + // so legacy keys never propagate into the new JobInstance. + assert 6L == Objects.requireNonNull(nextParams.getLong("run.id")); + assert nextParams.getString("stringValue") == null; + assert nextParams.getString("longValue") == null; + System.out.printf("good: params=%s%n", nextParams); } } diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/TestJobConfig.java b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/TestJobConfig.java index 97e5c2d..4d36629 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/TestJobConfig.java +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/good/TestJobConfig.java @@ -18,15 +18,11 @@ package com.navercorp.spring.batch.plus.sample.comparison.good; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.configuration.annotation.StepScope; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.core.step.tasklet.Tasklet; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; @@ -42,37 +38,15 @@ public Job testJob( PlatformTransactionManager transactionManager ) { return new JobBuilder("testJob", jobRepository) - .incrementer(ClearRunIdIncrementer.create()) // use ClearRunIdIncrementer + .incrementer(ClearRunIdIncrementer.create()) .start( new StepBuilder("testStep", jobRepository) .tasklet( - testTasklet(null, null), + (contribution, chunkContext) -> RepeatStatus.FINISHED, transactionManager ) .build() ) .build(); } - - @StepScope - @Bean - public Tasklet testTasklet( - @Value("#{jobParameters['longValue']}") Long longValue, - @Value("#{jobParameters['stringValue']}") String stringValue - ) { - return (contribution, chunkContext) -> { - Long result; - if (stringValue != null) { - result = longValue + Long.parseLong(stringValue); - } else { - result = 999L; - } - - ExecutionContext jobExecutionContext = contribution.getStepExecution() - .getJobExecution() - .getExecutionContext(); - jobExecutionContext.putLong("result", result); - return RepeatStatus.FINISHED; - }; - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts b/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts index 495c792..18dec13 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts @@ -27,14 +27,14 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.5") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus")) - runtimeOnly("com.h2database:h2:2.1.214") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/JdbcConfig.java index 2ce4523..a9d6526 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/SampleApplicationTest.java index 7795e23..5789025 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/SampleApplicationTest.java @@ -24,11 +24,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/TestJobConfig.java index 8e133b1..276e231 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/customdryrun/TestJobConfig.java @@ -20,13 +20,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/JdbcConfig.java index d3d3ad7..b11d43a 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/SampleApplicationTest.java index 63bdc28..0ad2423 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/SampleApplicationTest.java @@ -24,11 +24,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/TestJobConfig.java index ca771e3..5aeb956 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/dryrun/TestJobConfig.java @@ -20,13 +20,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/JdbcConfig.java index 9bfe1ff..54df5b6 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/SampleApplicationTest.java index 46ce3c4..a6a985a 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/SampleApplicationTest.java @@ -24,11 +24,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/TestJobConfig.java index f9ce258..f7cd0e5 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/formatter/TestJobConfig.java @@ -22,13 +22,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/JdbcConfig.java index b153ef3..b576f20 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/SampleApplicationTest.java index 269fff5..ad0dfab 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/SampleApplicationTest.java @@ -24,11 +24,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/TestJobConfig.java index 4ef9d93..6e638b0 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/jobname/TestJobConfig.java @@ -20,13 +20,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/JdbcConfig.java index 63e42ea..7dd315b 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/SampleApplicationTest.java index a3efe26..fa75c67 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/SampleApplicationTest.java @@ -24,11 +24,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/TestJobConfig.java index 1ee7087..465b6d1 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/parametername/TestJobConfig.java @@ -20,13 +20,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/JdbcConfig.java index 52aa8c7..15c47cf 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/SampleApplicationTest.java index be64330..ade72d2 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/SampleApplicationTest.java @@ -24,11 +24,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/TestJobConfig.java index c22e28c..48cadd7 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/plain/TestJobConfig.java @@ -20,13 +20,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/JdbcConfig.java index b2d2cab..086c001 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/SampleApplicationTest.java index fd1c8c7..6c6e903 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/SampleApplicationTest.java @@ -25,11 +25,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/TestJobConfig.java index 5869531..9e6c415 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefix/TestJobConfig.java @@ -20,13 +20,13 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/JdbcConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/JdbcConfig.java index f233359..453477a 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/JdbcConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/JdbcConfig.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/SampleApplicationTest.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/SampleApplicationTest.java index 1559daf..8a33ed0 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/SampleApplicationTest.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/SampleApplicationTest.java @@ -25,11 +25,11 @@ import java.util.stream.LongStream; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.boot.SpringApplication; diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/TestJobConfig.java b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/TestJobConfig.java index ba8a47d..f25627f 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/TestJobConfig.java +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/java/com/navercorp/spring/batch/plus/sample/deletemetadata/prefixfromvariable/TestJobConfig.java @@ -20,14 +20,14 @@ import javax.sql.DataSource; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.boot.autoconfigure.batch.BatchDataSource; -import org.springframework.boot.autoconfigure.batch.BatchProperties; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource; +import org.springframework.boot.batch.jdbc.autoconfigure.BatchJdbcProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.PlatformTransactionManager; @@ -41,9 +41,9 @@ public class TestJobConfig { public Job removeJob( @BatchDataSource DataSource dataSource, JobRepository jobRepository, - BatchProperties properties + BatchJdbcProperties properties ) { - String tablePrefix = properties.getJdbc().getTablePrefix(); + String tablePrefix = properties.getTablePrefix(); return new DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .tablePrefix(tablePrefix) diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/resources/sql/schema-h2-custom.sql b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/resources/sql/schema-h2-custom.sql index 718302f..a65cc0f 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/resources/sql/schema-h2-custom.sql +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/src/test/resources/sql/schema-h2-custom.sql @@ -73,4 +73,4 @@ CREATE TABLE CUSTOM_JOB_EXECUTION_CONTEXT ( CREATE SEQUENCE CUSTOM_STEP_EXECUTION_SEQ; CREATE SEQUENCE CUSTOM_JOB_EXECUTION_SEQ; -CREATE SEQUENCE CUSTOM_JOB_SEQ; +CREATE SEQUENCE CUSTOM_JOB_INSTANCE_SEQ; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts index 8a80ce2..3ed49be 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts @@ -27,15 +27,15 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.5") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus")) - implementation("io.projectreactor:reactor-core:3.5.0") - runtimeOnly("com.h2database:h2:2.1.214") + implementation("io.projectreactor:reactor-core:3.8.4") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.java index d64b8fa..0ca69d3 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.java index bb2e08c..6554230 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.java @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.flux.callback; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.java index 851ecba..df47010 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.java index d9eeba3..2ebcd96 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.java index abeb765..86ab461 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.java @@ -19,7 +19,7 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessor; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.java index 3b1d6c1..ebfb586 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemProcessor; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.java index ab9348c..65537f4 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.java index 795b599..e0410cd 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.java @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.java index f685bf9..de9bc5b 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.java index d6bfb71..25aa00d 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.java index de12d48..816ed0d 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.java @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.flux.readerwriter; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.java index 40f7685..43b8c65 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.java index 9f732a8..514e0f3 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.java index d9b036f..76781bd 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.java index a31924a..52a7c60 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.java index 874cace..27156ad 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.java index 5302802..bfef6a4 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.java @@ -21,7 +21,7 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.java index 7ff6e34..c135dd0 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemProcessor; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.java index 015f649..19eb7cf 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.java index f433c18..e753a62 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.java index 4e891c6..ae40c64 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.java index 6b48cb2..f82b91e 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.java index b0a9065..0f6d1de 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.java index d096c16..5b21cea 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.java index 83903d1..3c2a47a 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.java index 3e2cba4..1538329 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.java index bb87717..faf5f94 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.java index 7f7a57c..dbee635 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.java index db14fdb..13ebf97 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.java @@ -21,7 +21,7 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.java index 13aa896..e11d8ee 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemProcessor; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.java index 21f2579..27e78ce 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.java index a287e2a..0e4583b 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.java index 226da47..5dd1420 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.java index e01e204..ead9094 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.java index d974aeb..55ffa77 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.java index cfd347a..ca8778f 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.java index 5e35ad4..5f5c65b 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.java index 0723f2c..7504071 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.java @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.simple.callback; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.java index 242ea67..b689920 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.java index ce39cd1..673a5b2 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.java index 716ad77..ddd2011 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemProcessor; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.java index 4e4003f..864ed13 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.java index 06f037a..e45ec7d 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.java @@ -19,7 +19,7 @@ package com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; +import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.java index 14b91e1..3efb2b6 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.java @@ -22,7 +22,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.java index 80a3ea0..2e16ae2 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.java index 2e30dfc..25195a9 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.java @@ -19,7 +19,7 @@ package com.navercorp.spring.batch.plus.sample.simple.readerwriter; import org.springframework.batch.core.configuration.annotation.StepScope; -import org.springframework.batch.item.Chunk; +import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.beans.factory.annotation.Value; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.java index 6e6e25a..34e7e5a 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.java @@ -21,7 +21,7 @@ import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamReader; import static com.navercorp.spring.batch.plus.step.adapter.AdapterFactory.itemStreamWriter; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; From 2e681507ee985b27b7a5e5a4b71eb28dd7db2063 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 20 May 2026 18:33:50 +0900 Subject: [PATCH 08/45] Bump Kotlin toolchain to 2.2.21 for Spring Batch 6 Signed-off-by: Taeik Lim --- buildSrc/build.gradle.kts | 4 ++-- .../kotlin/spring.batch.plus.kotlin-conventions.gradle.kts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index facf8fd..90c82df 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,6 +10,6 @@ repositories { dependencies { // see also (compatibility matrix) : https://docs.gradle.org/current/userguide/compatibility.html - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") - implementation("org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin:11.6.1") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.21") + implementation("org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin:14.2.0") } diff --git a/buildSrc/src/main/kotlin/spring.batch.plus.kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/spring.batch.plus.kotlin-conventions.gradle.kts index aebc0ef..f268b59 100644 --- a/buildSrc/src/main/kotlin/spring.batch.plus.kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/spring.batch.plus.kotlin-conventions.gradle.kts @@ -21,7 +21,7 @@ kotlin { "-Xjsr305=strict", // enable jsr305 null-safety in kotlin ) jvmTarget = JvmTarget.JVM_17 // make class files for this version - languageVersion = KotlinVersion.KOTLIN_1_6 // language feature level - apiVersion = KotlinVersion.KOTLIN_1_6 // std api level + languageVersion = KotlinVersion.KOTLIN_2_2 // language feature level + apiVersion = KotlinVersion.KOTLIN_2_2 // std api level } } From 9fc0e1de619fba3243372f2566a0a17bf8710acc Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 20 May 2026 19:03:00 +0900 Subject: [PATCH 09/45] Migrate Kotlin module imports for Spring Batch 6.0.3 Signed-off-by: Taeik Lim --- .../ConcreteFlowBuilderDslIntegrationTest.kt | 6 ++-- ...iderTransitionBuilderDslIntegrationTest.kt | 2 +- .../FlowJobBuilderDslIntegrationTest.kt | 6 ++-- ...FlowTransitionBuilderDslIntegrationTest.kt | 6 ++-- .../SimpleJobBuilderDslIntegrationTest.kt | 6 ++-- .../SplitBuilderDslIntegrationTest.kt | 6 ++-- .../StepBuilderDslIntegrationTest.kt | 10 +++--- ...StepTransitionBuilderDslIntegrationTest.kt | 6 ++-- .../TransitionBuilderDslIntegrationTest.kt | 6 ++-- .../plus/kotlin/configuration/BatchDsl.kt | 4 +-- .../configuration/ConcreteFlowBuilderDsl.kt | 2 +- .../kotlin/configuration/FlowBuilderDsl.kt | 2 +- .../kotlin/configuration/FlowJobBuilderDsl.kt | 2 +- .../kotlin/configuration/JobBuilderDsl.kt | 10 +++--- .../configuration/SimpleJobBuilderDsl.kt | 4 +-- .../SimpleJobBuilderDslAdapter.kt | 4 +-- .../kotlin/configuration/StepBuilderDsl.kt | 10 +++--- .../configuration/StepTransitionBuilderDsl.kt | 2 +- .../configuration/TransitionBuilderDsl.kt | 2 +- .../configuration/step/FlowStepBuilderDsl.kt | 2 +- .../configuration/step/JobStepBuilderDsl.kt | 2 +- .../step/PartitionStepBuilderDsl.kt | 6 ++-- .../step/SimpleStepBuilderDsl.kt | 24 ++++++------- .../step/TaskletStepBuilderDsl.kt | 10 +++--- .../plus/kotlin/item/adapter/ItemDelegates.kt | 6 ++-- .../plus/kotlin/step/adapter/ItemDelegates.kt | 6 ++-- .../configuration/JobBuilderDslHelperTest.kt | 6 ++-- .../SimpleJobBuilderDslAdapterTest.kt | 6 ++-- .../configuration/StepBuilderDslHelperTest.kt | 2 +- .../step/FaultTolerantStepBuilderDslTest.kt | 20 +++++------ .../step/FlowStepBuilderDslTest.kt | 2 +- .../step/JobStepBuilderDslTest.kt | 2 +- .../step/PartitionStepBuilderDslTest.kt | 12 +++---- .../step/SimpleStepBuilderDslTest.kt | 34 +++++++++---------- .../step/TaskletStepBuilderDslTest.kt | 22 ++++++------ .../kotlin/item/adapter/ItemDelegatesTest.kt | 4 +-- 36 files changed, 131 insertions(+), 131 deletions(-) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt index 88c0b69..043d020 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt @@ -22,14 +22,14 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt index 0dfbc5b..308ce22 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt @@ -24,7 +24,7 @@ import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt index 785c6d7..785ca2a 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt @@ -22,14 +22,14 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt index a362b24..87b3883 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt @@ -24,12 +24,12 @@ import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt index 90c7717..1b1003f 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt @@ -21,12 +21,12 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt index e2ec431..d1373a2 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt @@ -23,12 +23,12 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 9963680..422d700 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -22,15 +22,15 @@ import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.repeat.policy.SimpleCompletionPolicy -import org.springframework.batch.repeat.support.RepeatTemplate -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt index 1ee4c5b..10b807f 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt @@ -24,12 +24,12 @@ import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt index 885013b..940e155 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt @@ -23,14 +23,14 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt index 403a389..4f79be9 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.flow.Flow diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt index e58329c..871d36d 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt index 7fb4b95..e168f51 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt @@ -19,7 +19,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt index 680ed0f..bdbfc6b 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.builder.FlowJobBuilder /** diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt index bae7930..0268368 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt @@ -23,11 +23,11 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobExecutionListener -import org.springframework.batch.core.JobParametersIncrementer -import org.springframework.batch.core.JobParametersValidator -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.JobExecutionListener +import org.springframework.batch.core.job.parameters.JobParametersIncrementer +import org.springframework.batch.core.job.parameters.JobParametersValidator +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowJobBuilder import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.builder.JobBuilderHelper diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt index 92447f1..c0dbf81 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.SimpleJobBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.getBean diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt index c3d4f7b..a76abd3 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowJobBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index 864c902..87bdfe3 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -27,9 +27,9 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMark import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.core.StepExecutionListener +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.core.listener.StepExecutionListener import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.observability.BatchStepObservationConvention @@ -38,8 +38,8 @@ import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.CompletionPolicy -import org.springframework.batch.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.CompletionPolicy +import org.springframework.batch.infrastructure.repeat.RepeatOperations import org.springframework.beans.factory.getBean import org.springframework.transaction.PlatformTransactionManager diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt index 24d9f8c..8176168 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder /** diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt index 1ae5286..121e8bc 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt index 73e23c9..d674a2e 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.FlowStepBuilder /** diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt index c89bddb..570864e 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt index 310fee8..edab0ff 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt @@ -22,11 +22,11 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMark import com.navercorp.spring.batch.plus.kotlin.configuration.support.Configurer import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.partition.PartitionHandler import org.springframework.batch.core.partition.StepExecutionSplitter -import org.springframework.batch.core.partition.support.Partitioner -import org.springframework.batch.core.partition.support.StepExecutionAggregator +import org.springframework.batch.core.partition.Partitioner +import org.springframework.batch.core.partition.StepExecutionAggregator import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.core.task.TaskExecutor diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt index 1d14fc7..327d8a5 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt @@ -22,22 +22,22 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMark import com.navercorp.spring.batch.plus.kotlin.configuration.support.Configurer import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.ItemProcessListener -import org.springframework.batch.core.ItemReadListener -import org.springframework.batch.core.ItemWriteListener -import org.springframework.batch.core.SkipListener -import org.springframework.batch.core.Step +import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.listener.ItemProcessListener +import org.springframework.batch.core.listener.ItemReadListener +import org.springframework.batch.core.listener.ItemWriteListener +import org.springframework.batch.core.listener.SkipListener +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.FaultTolerantStepBuilder import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.item.KeyGenerator import org.springframework.batch.core.step.skip.SkipPolicy -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemStream -import org.springframework.batch.item.ItemWriter -import org.springframework.batch.repeat.RepeatOperations -import org.springframework.batch.repeat.exception.ExceptionHandler +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.batch.infrastructure.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler import org.springframework.core.task.TaskExecutor import org.springframework.retry.RetryListener import org.springframework.retry.RetryPolicy diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt index 3c6d3f8..c014f30 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt @@ -21,12 +21,12 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.Step +import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.TaskletStepBuilder -import org.springframework.batch.item.ItemStream -import org.springframework.batch.repeat.RepeatOperations -import org.springframework.batch.repeat.exception.ExceptionHandler +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler import org.springframework.core.task.TaskExecutor import org.springframework.transaction.interceptor.TransactionAttribute diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt index aefda05..3333d83 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt @@ -24,9 +24,9 @@ import com.navercorp.spring.batch.plus.item.adapter.AdapterFactory import com.navercorp.spring.batch.plus.item.adapter.ItemProcessorDelegate import com.navercorp.spring.batch.plus.item.adapter.ItemStreamReaderDelegate import com.navercorp.spring.batch.plus.item.adapter.ItemStreamWriterDelegate -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemStreamReader -import org.springframework.batch.item.ItemStreamWriter +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemStreamReader +import org.springframework.batch.infrastructure.item.ItemStreamWriter /** * An extensions to invoke [AdapterFactory.itemStreamReader]. diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt index d4b4a99..90ecf61 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt @@ -25,9 +25,9 @@ import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderDele import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderDelegate import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderDelegate import com.navercorp.spring.batch.plus.step.adapter.ItemStreamWriterDelegate -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemStreamReader -import org.springframework.batch.item.ItemStreamWriter +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemStreamReader +import org.springframework.batch.infrastructure.item.ItemStreamWriter /** * An extensions to invoke [AdapterFactory.itemStreamReader]. diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt index df330a1..46c7967 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt @@ -25,9 +25,9 @@ import io.mockk.mockk import io.mockk.spyk import io.mockk.verify import org.junit.jupiter.api.Test -import org.springframework.batch.core.JobExecutionListener -import org.springframework.batch.core.JobParametersIncrementer -import org.springframework.batch.core.JobParametersValidator +import org.springframework.batch.core.listener.JobExecutionListener +import org.springframework.batch.core.job.parameters.JobParametersIncrementer +import org.springframework.batch.core.job.parameters.JobParametersValidator import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.observability.BatchJobObservationConvention import org.springframework.batch.core.repository.JobRepository diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt index e9f3b50..6aafd68 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt @@ -22,10 +22,10 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import io.mockk.mockk import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager internal class SimpleJobBuilderDslAdapterTest { diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt index 9af85ad..9e24ceb 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt @@ -24,7 +24,7 @@ import io.micrometer.observation.ObservationRegistry import io.mockk.mockk import io.mockk.verify import org.junit.jupiter.api.Test -import org.springframework.batch.core.StepExecutionListener +import org.springframework.batch.core.listener.StepExecutionListener import org.springframework.batch.core.observability.BatchStepObservationConvention import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.builder.StepBuilder diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt index 187a687..b2f469d 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt @@ -24,22 +24,22 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.JobExecution -import org.springframework.batch.core.JobInstance -import org.springframework.batch.core.JobParameters -import org.springframework.batch.core.SkipListener -import org.springframework.batch.core.Step +import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.JobInstance +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.listener.SkipListener +import org.springframework.batch.core.step.Step import org.springframework.batch.core.annotation.OnSkipInRead import org.springframework.batch.core.scope.context.ChunkContext import org.springframework.batch.core.step.FatalStepExecutionException import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemStream -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.retry.RetryCallback import org.springframework.retry.RetryContext import org.springframework.retry.RetryListener diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt index ddf234d..02a2b47 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt @@ -22,7 +22,7 @@ import io.mockk.every import io.mockk.mockk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.FlowStepBuilder internal class FlowStepBuilderDslTest { diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt index 812c790..cf2933c 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt @@ -23,7 +23,7 @@ import io.mockk.mockk import io.mockk.verify import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.springframework.batch.core.Step +import org.springframework.batch.core.step.Step import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt index 97d3525..56e227f 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt @@ -27,17 +27,17 @@ import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.JobExecution -import org.springframework.batch.core.JobInstance -import org.springframework.batch.core.JobParameters -import org.springframework.batch.core.Step -import org.springframework.batch.core.StepExecution +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.JobInstance +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.step.Step +import org.springframework.batch.core.step.StepExecution import org.springframework.batch.core.partition.PartitionHandler import org.springframework.batch.core.partition.StepExecutionSplitter import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.batch.core.step.builder.StepBuilder -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ExecutionContext internal class PartitionStepBuilderDslTest { diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index c459c7e..fe6900a 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -26,26 +26,26 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.ItemProcessListener -import org.springframework.batch.core.ItemReadListener -import org.springframework.batch.core.ItemWriteListener -import org.springframework.batch.core.JobExecution -import org.springframework.batch.core.JobInstance -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.listener.ItemProcessListener +import org.springframework.batch.core.listener.ItemReadListener +import org.springframework.batch.core.listener.ItemWriteListener +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.JobInstance +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemStream -import org.springframework.batch.item.ItemWriter -import org.springframework.batch.repeat.RepeatCallback -import org.springframework.batch.repeat.RepeatOperations -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.repeat.exception.ExceptionHandler -import org.springframework.batch.repeat.support.RepeatTemplate -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.batch.infrastructure.repeat.RepeatCallback +import org.springframework.batch.infrastructure.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.core.task.SyncTaskExecutor import org.springframework.core.task.TaskExecutor import org.springframework.transaction.interceptor.TransactionAttribute diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index 646da3e..ffd6fc4 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -26,20 +26,20 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.JobExecution -import org.springframework.batch.core.JobInstance -import org.springframework.batch.core.JobParameters +import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.JobInstance +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.builder.TaskletStepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep -import org.springframework.batch.item.ItemStream -import org.springframework.batch.repeat.RepeatCallback -import org.springframework.batch.repeat.RepeatOperations -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.repeat.exception.ExceptionHandler -import org.springframework.batch.repeat.support.RepeatTemplate -import org.springframework.batch.support.transaction.ResourcelessTransactionManager +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.repeat.RepeatCallback +import org.springframework.batch.infrastructure.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.core.task.TaskExecutor import org.springframework.transaction.interceptor.TransactionAttribute import java.util.UUID diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt index 645ed07..74c4aa7 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt @@ -26,8 +26,8 @@ import com.navercorp.spring.batch.plus.item.adapter.ItemStreamWriterAdapter import com.navercorp.spring.batch.plus.item.adapter.StepScopeItemStreamReader import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import reactor.core.publisher.Flux internal class ItemDelegatesTest { From 385670d657c962ce45d65815eb904e9be140b733 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 20 May 2026 19:24:58 +0900 Subject: [PATCH 10/45] Reformat Kotlin sources with ktlint 14 Signed-off-by: Taeik Lim --- .../ConcreteFlowBuilderDslIntegrationTest.kt | 1267 ++++++------ ...iderTransitionBuilderDslIntegrationTest.kt | 62 +- .../FlowJobBuilderDslIntegrationTest.kt | 947 ++++----- ...FlowTransitionBuilderDslIntegrationTest.kt | 92 +- .../SimpleJobBuilderDslIntegrationTest.kt | 169 +- .../SplitBuilderDslIntegrationTest.kt | 245 +-- .../StepBuilderDslIntegrationTest.kt | 535 ++--- ...StepTransitionBuilderDslIntegrationTest.kt | 88 +- .../TransitionBuilderDslIntegrationTest.kt | 1808 +++++++++-------- .../plus/kotlin/configuration/BatchDsl.kt | 17 +- .../configuration/ConcreteFlowBuilderDsl.kt | 147 +- .../DeciderTransitionBuilderDsl.kt | 30 +- .../kotlin/configuration/FlowBuilderDsl.kt | 38 +- .../kotlin/configuration/FlowJobBuilderDsl.kt | 7 +- .../configuration/FlowTransitionBuilderDsl.kt | 30 +- .../kotlin/configuration/JobBuilderDsl.kt | 50 +- .../configuration/SimpleJobBuilderDsl.kt | 8 +- .../SimpleJobBuilderDslAdapter.kt | 74 +- .../kotlin/configuration/SplitBuilderDsl.kt | 11 +- .../kotlin/configuration/StepBuilderDsl.kt | 104 +- .../configuration/StepTransitionBuilderDsl.kt | 32 +- .../configuration/TransitionBuilderDsl.kt | 166 +- .../configuration/step/FlowStepBuilderDsl.kt | 6 +- .../configuration/step/JobStepBuilderDsl.kt | 8 +- .../step/PartitionStepBuilderDsl.kt | 19 +- .../step/SimpleStepBuilderDsl.kt | 17 +- .../step/TaskletStepBuilderDsl.kt | 3 +- .../plus/kotlin/item/adapter/ItemDelegates.kt | 18 +- .../plus/kotlin/step/adapter/ItemDelegates.kt | 18 +- .../configuration/JobBuilderDslHelperTest.kt | 86 +- .../SimpleJobBuilderDslAdapterTest.kt | 3 +- .../configuration/StepBuilderDslHelperTest.kt | 66 +- .../step/FaultTolerantStepBuilderDslTest.kt | 1195 +++++------ .../step/FlowStepBuilderDslTest.kt | 8 +- .../step/JobStepBuilderDslTest.kt | 24 +- .../step/PartitionStepBuilderDslTest.kt | 552 ++--- .../step/SimpleStepBuilderDslTest.kt | 241 +-- .../step/TaskletStepBuilderDslTest.kt | 117 +- .../support/LazyConfigurerTest.kt | 1 - .../kotlin/item/adapter/ItemDelegatesTest.kt | 10 +- .../kotlin/step/adapter/ItemDelegatesTest.kt | 1 - 41 files changed, 4371 insertions(+), 3949 deletions(-) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt index 043d020..01bc155 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt @@ -22,10 +22,10 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -44,7 +44,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class ConcreteFlowBuilderDslIntegrationTest { - @Test fun testStepBean() { // given @@ -53,28 +52,30 @@ internal class ConcreteFlowBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.apply { registerBean("testStep1") { testStep1 @@ -85,17 +86,19 @@ internal class ConcreteFlowBuilderDslIntegrationTest { } // when - val testFlow = batch { - flow("testFlow") { - stepBean("testStep1") - stepBean("testStep2") + val testFlow = + batch { + flow("testFlow") { + stepBean("testStep1") + stepBean("testStep2") + } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -115,33 +118,35 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val testFlow = batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -159,41 +164,45 @@ internal class ConcreteFlowBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val testFlow = batch { - flow("testFlow") { - step(testStep1) - step(testStep2) + val testFlow = + batch { + flow("testFlow") { + step(testStep1) + step(testStep2) + } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -213,28 +222,30 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.apply { registerBean("testStep1") { testStep1 @@ -245,44 +256,46 @@ internal class ConcreteFlowBuilderDslIntegrationTest { } // when - val testFlow = batch { - flow("testFlow") { - stepBean("testStep1") { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + stepBean("testStep1") { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - stepBean("testStep2") { - on("COMPLETED") { - end("TEST") + stepBean("testStep2") { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -306,66 +319,68 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val testFlow = batch { - flow("testFlow") { - step( - "testStep1", - { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - step("transitionStep1") { + val testFlow = + batch { + flow("testFlow") { + step( + "testStep1", + { tasklet( { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED + ++testStep1CallCount + throw RuntimeException("Error") }, ResourcelessTransactionManager(), ) + }, + ) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - on("FAILED") { - step("transitionStep2") { + step( + "testStep2", + { tasklet( { _, _ -> - ++transitionStep2CallCount + ++testStep2CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) + }, + ) { + on("COMPLETED") { + end("TEST") } } } - step( - "testStep2", - { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - end("TEST") - } - } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -387,102 +402,20 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) - } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when - val testFlow = batch { - flow("testFlow") { - step(testStep1) { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - step(testStep2) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStep1CallCount).isEqualTo(0) - assertThat(transitionStep2CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) - } - - @Test - fun testFlowBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { + val testStep1 = + batch { step("testStep1") { tasklet( { _, _ -> ++testStep1CallCount - RepeatStatus.FINISHED + throw RuntimeException("Error") }, ResourcelessTransactionManager(), ) } } - } - val testFlow2 = batch { - flow("testFlow2") { + val testStep2 = + batch { step("testStep2") { tasklet( { _, _ -> @@ -493,49 +426,69 @@ internal class ConcreteFlowBuilderDslIntegrationTest { ) } } - } - context.apply { - registerBean("testFlow1") { - testFlow1 - } - registerBean("testFlow2") { - testFlow2 - } - } // when - val testFlow = batch { - flow("testFlow") { - flowBean("testFlow1") - flowBean("testFlow2") + val testFlow = + batch { + flow("testFlow") { + step(testStep1) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + step(testStep2) { + on("COMPLETED") { + end("TEST") + } + } + } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStep1CallCount).isEqualTo(0) + assertThat(transitionStep2CallCount).isEqualTo(1) assertThat(testStep2CallCount).isEqualTo(1) } @Test - fun testFlowWithInit() { + fun testFlowBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobLauncher = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - - // when - val testFlow = batch { - flow("testFlow") { + val testFlow1 = + batch { flow("testFlow1") { step("testStep1") { tasklet( @@ -547,6 +500,9 @@ internal class ConcreteFlowBuilderDslIntegrationTest { ) } } + } + val testFlow2 = + batch { flow("testFlow2") { step("testStep2") { tasklet( @@ -559,12 +515,29 @@ internal class ConcreteFlowBuilderDslIntegrationTest { } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + context.apply { + registerBean("testFlow1") { + testFlow1 + } + registerBean("testFlow2") { + testFlow2 } } + + // when + val testFlow = + batch { + flow("testFlow") { + flowBean("testFlow1") + flowBean("testFlow2") + } + } + val job = + batch { + job("testJob") { + flow(testFlow) + } + } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -575,52 +548,108 @@ internal class ConcreteFlowBuilderDslIntegrationTest { } @Test - fun testFlowWithVariable() { + fun testFlowWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobLauncher = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + + // when + val testFlow = + batch { + flow("testFlow") { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + } + val job = + batch { + job("testJob") { + flow(testFlow) + } + } + val jobExecution = jobLauncher.run(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testStep2CallCount).isEqualTo(1) + } + + @Test + fun testFlowWithVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobLauncher = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testStep2CallCount = 0 + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val testFlow = batch { - flow("testFlow") { - flow(testFlow1) - flow(testFlow2) + val testFlow = + batch { + flow("testFlow") { + flow(testFlow1) + flow(testFlow2) + } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -640,32 +669,34 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } context.apply { registerBean("testFlow1") { testFlow1 @@ -676,44 +707,46 @@ internal class ConcreteFlowBuilderDslIntegrationTest { } // when - val testFlow = batch { - flow("testFlow") { - flowBean("testFlow1") { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + flowBean("testFlow1") { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - flowBean("testFlow2") { - on("COMPLETED") { - end("TEST") + flowBean("testFlow2") { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -737,70 +770,72 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val testFlow = batch { - flow("testFlow") { - flow( - "testFlow1", - { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) - } - }, - ) { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + flow( + "testFlow1", + { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } + }, + ) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - flow( - "testFlow2", - { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + flow( + "testFlow2", + { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + }, + ) { + on("COMPLETED") { + end("TEST") } - }, - ) { - on("COMPLETED") { - end("TEST") } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -822,72 +857,76 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val testFlow = batch { - flow("testFlow") { - flow(testFlow1) { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + flow(testFlow1) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - flow(testFlow2) { - on("COMPLETED") { - end("TEST") + flow(testFlow2) { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -906,29 +945,32 @@ internal class ConcreteFlowBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } context.registerBean("testDecider") { testDecider } // when - val testFlow = batch { - flow("testFlow") { - deciderBean("testDecider") { - on("COMPLETED") { - end("TEST") + val testFlow = + batch { + flow("testFlow") { + deciderBean("testDecider") { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -945,38 +987,41 @@ internal class ConcreteFlowBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } context.registerBean("testDecider") { testDecider } // when - val testFlow = batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - deciderBean("testDecider") { - on("COMPLETED") { - end("TEST") + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + deciderBean("testDecider") { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -993,26 +1038,29 @@ internal class ConcreteFlowBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 - val decider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val decider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } // when - val testFlow = batch { - flow("testFlow") { - decider(decider) { - on("COMPLETED") { - end("TEST") + val testFlow = + batch { + flow("testFlow") { + decider(decider) { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -1029,35 +1077,38 @@ internal class ConcreteFlowBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 - val decider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val decider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } // when - val testFlow = batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - decider(decider) { - on("COMPLETED") { - end("TEST") + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + decider(decider) { + on("COMPLETED") { + end("TEST") + } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -1077,49 +1128,52 @@ internal class ConcreteFlowBuilderDslIntegrationTest { var testStep1CallCount = 0 var testStep2CallCount = 0 val callerThread = Thread.currentThread().name - val taskExecutor = object : ThreadPoolTaskExecutor() { - override fun execute(task: Runnable) { - ++taskExecutorCallCount - super.execute(task) - } - }.apply { initialize() } + val taskExecutor = + object : ThreadPoolTaskExecutor() { + override fun execute(task: Runnable) { + ++taskExecutorCallCount + super.execute(task) + } + }.apply { initialize() } // when - val testFlow = batch { - flow("testFlow") { - split(taskExecutor) { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + split(taskExecutor) { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } - } - val job = batch { - job("testJob") { - flow(testFlow) + val job = + batch { + job("testJob") { + flow(testFlow) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -1136,28 +1190,25 @@ internal class ConcreteFlowBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt index 308ce22..7734198 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt @@ -24,10 +24,10 @@ import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.BeanFactory @@ -42,7 +42,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class DeciderTransitionBuilderDslIntegrationTest { - @RepeatedTest(10) fun testDeciderWithMultipleTransition() { // given @@ -51,24 +50,26 @@ internal class DeciderTransitionBuilderDslIntegrationTest { val batch = context.getBean() val expectedFlowExecutionStatus = randomFlowExecutionStatus() var testDeciderCallCount = 0 - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - expectedFlowExecutionStatus - } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + expectedFlowExecutionStatus + } // when - val job = batch { - job("testJob") { - decider(testDecider) { - on("UNKNOWN") { - end() - } - on("*") { - fail() + val job = + batch { + job("testJob") { + decider(testDecider) { + on("UNKNOWN") { + end() + } + on("*") { + fail() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -97,9 +98,10 @@ internal class DeciderTransitionBuilderDslIntegrationTest { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() - val testDecider = JobExecutionDecider { _, _ -> - FlowExecutionStatus.COMPLETED - } + val testDecider = + JobExecutionDecider { _, _ -> + FlowExecutionStatus.COMPLETED + } // when, then assertThatThrownBy { @@ -113,14 +115,13 @@ internal class DeciderTransitionBuilderDslIntegrationTest { }.hasMessageContaining("should set transition for decider") } - private fun randomFlowExecutionStatus(): FlowExecutionStatus { - return listOf( + private fun randomFlowExecutionStatus(): FlowExecutionStatus = + listOf( FlowExecutionStatus.COMPLETED, FlowExecutionStatus.FAILED, FlowExecutionStatus.UNKNOWN, FlowExecutionStatus.STOPPED, // when stopped, just stop the job ).random() - } @Configuration @EnableBatchProcessing( @@ -128,28 +129,25 @@ internal class DeciderTransitionBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt index 785ca2a..1fca2a3 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt @@ -22,10 +22,10 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -44,7 +44,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class FlowJobBuilderDslIntegrationTest { - @Test fun testStepBeanWithTransition() { // given @@ -55,28 +54,30 @@ internal class FlowJobBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.apply { registerBean("testStep1") { testStep1 @@ -87,39 +88,40 @@ internal class FlowJobBuilderDslIntegrationTest { } // when - val job = batch { - job("testJob") { - stepBean("testStep1") { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + stepBean("testStep1") { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - stepBean("testStep2") { - on("COMPLETED") { - end("TEST") + stepBean("testStep2") { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -143,61 +145,62 @@ internal class FlowJobBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val job = batch { - job("testJob") { - step( - "testStep1", - { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - step("transitionStep1") { + val job = + batch { + job("testJob") { + step( + "testStep1", + { tasklet( { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED + ++testStep1CallCount + throw RuntimeException("Error") }, ResourcelessTransactionManager(), ) + }, + ) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - on("FAILED") { - step("transitionStep2") { + step( + "testStep2", + { tasklet( { _, _ -> - ++transitionStep2CallCount + ++testStep2CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) + }, + ) { + on("COMPLETED") { + end("TEST") } } } - step( - "testStep2", - { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - end("TEST") - } - } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -219,63 +222,66 @@ internal class FlowJobBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - step(testStep2) { - on("COMPLETED") { - end("TEST") + step(testStep2) { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -295,32 +301,34 @@ internal class FlowJobBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } context.apply { registerBean("testFlow1") { testFlow1 @@ -331,12 +339,13 @@ internal class FlowJobBuilderDslIntegrationTest { } // when - val job = batch { - job("testJob") { - flowBean("testFlow1") - flowBean("testFlow2") + val job = + batch { + job("testJob") { + flowBean("testFlow1") + flowBean("testFlow2") + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -356,32 +365,33 @@ internal class FlowJobBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val job = batch { - job("testJob") { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -399,40 +409,43 @@ internal class FlowJobBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - flow(testFlow1) - flow(testFlow2) + val job = + batch { + job("testJob") { + flow(testFlow1) + flow(testFlow2) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -452,33 +465,35 @@ internal class FlowJobBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } context.apply { registerBean("testFlow1") { testFlow1 @@ -489,39 +504,40 @@ internal class FlowJobBuilderDslIntegrationTest { } // when - val job = batch { - job("testJob") { - flowBean("testFlow1") { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + flowBean("testFlow1") { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - flowBean("testFlow2") { - on("COMPLETED") { - end("TEST") + flowBean("testFlow2") { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -545,65 +561,66 @@ internal class FlowJobBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val job = batch { - job("testJob") { - flow( - "testFlow1", - { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) - } - }, - ) { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + flow( + "testFlow1", + { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } + }, + ) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - flow( - "testFlow2", - { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + flow( + "testFlow2", + { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + }, + ) { + on("COMPLETED") { + end("TEST") } - }, - ) { - on("COMPLETED") { - end("TEST") } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -625,67 +642,70 @@ internal class FlowJobBuilderDslIntegrationTest { var transitionStep1CallCount = 0 var transitionStep2CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - flow(testFlow1) { - on("COMPLETED") { - step("transitionStep1") { - tasklet( - { _, _ -> - ++transitionStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + flow(testFlow1) { + on("COMPLETED") { + step("transitionStep1") { + tasklet( + { _, _ -> + ++transitionStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + on("FAILED") { + step("transitionStep2") { + tasklet( + { _, _ -> + ++transitionStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - flow(testFlow2) { - on("COMPLETED") { - end("TEST") + flow(testFlow2) { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -704,24 +724,26 @@ internal class FlowJobBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } context.registerBean("testDecider") { testDecider } // when - val job = batch { - job("testJob") { - deciderBean("testDecider") { - on("COMPLETED") { - end("TEST") + val job = + batch { + job("testJob") { + deciderBean("testDecider") { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -738,33 +760,35 @@ internal class FlowJobBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } context.registerBean("testDecider") { testDecider } // when - val job = batch { - job("testJob") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - deciderBean("testDecider") { - on("COMPLETED") { - end("TEST") + val job = + batch { + job("testJob") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + deciderBean("testDecider") { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -781,21 +805,23 @@ internal class FlowJobBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 - val decider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val decider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } // when - val job = batch { - job("testJob") { - decider(decider) { - on("COMPLETED") { - end("TEST") + val job = + batch { + job("testJob") { + decider(decider) { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -812,30 +838,32 @@ internal class FlowJobBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 - val decider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } + val decider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } // when - val job = batch { - job("testJob") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - decider(decider) { - on("COMPLETED") { - end("TEST") + val job = + batch { + job("testJob") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + decider(decider) { + on("COMPLETED") { + end("TEST") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -855,44 +883,46 @@ internal class FlowJobBuilderDslIntegrationTest { var testStep1CallCount = 0 var testStep2CallCount = 0 val callerThread = Thread.currentThread().name - val taskExecutor = object : ThreadPoolTaskExecutor() { - override fun execute(task: Runnable) { - ++taskExecutorCallCount - super.execute(task) - } - }.apply { initialize() } + val taskExecutor = + object : ThreadPoolTaskExecutor() { + override fun execute(task: Runnable) { + ++taskExecutorCallCount + super.execute(task) + } + }.apply { initialize() } // when - val job = batch { - job("testJob") { - split(taskExecutor) { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + split(taskExecutor) { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -909,28 +939,25 @@ internal class FlowJobBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt index 87b3883..4837904 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt @@ -24,8 +24,8 @@ import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -42,7 +42,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class FlowTransitionBuilderDslIntegrationTest { - @RepeatedTest(10) fun testFlowWithMultipleTransition() { // given @@ -51,34 +50,36 @@ internal class FlowTransitionBuilderDslIntegrationTest { val batch = context.getBean() val expectedExitStatus = randomExitStatus() var testStep1CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { contribution, _ -> - ++testStep1CallCount - contribution.exitStatus = expectedExitStatus - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { contribution, _ -> + ++testStep1CallCount + contribution.exitStatus = expectedExitStatus + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - flow(testFlow1) { - on("COMPLETED") { - end() - } - on("*") { - fail() + val job = + batch { + job("testJob") { + flow(testFlow1) { + on("COMPLETED") { + end() + } + on("*") { + fail() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -101,18 +102,19 @@ internal class FlowTransitionBuilderDslIntegrationTest { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when, then assertThatThrownBy { @@ -126,8 +128,8 @@ internal class FlowTransitionBuilderDslIntegrationTest { }.hasMessageContaining("should set transition for flow") } - private fun randomExitStatus(): ExitStatus { - return listOf( + private fun randomExitStatus(): ExitStatus = + listOf( ExitStatus.UNKNOWN, ExitStatus.NOOP, ExitStatus.FAILED, @@ -135,7 +137,6 @@ internal class FlowTransitionBuilderDslIntegrationTest { ExitStatus.COMPLETED, // ExitStatus.EXECUTING, // why considered ExitStatus.COMPLETE? ).random() - } @Configuration @EnableBatchProcessing( @@ -143,28 +144,25 @@ internal class FlowTransitionBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt index 1b1003f..36c1025 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt @@ -21,8 +21,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -40,7 +40,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class SimpleJobBuilderDslIntegrationTest { - @Test fun testStepBean() { // given @@ -51,28 +50,30 @@ internal class SimpleJobBuilderDslIntegrationTest { var testStep1CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.apply { registerBean("testStep1") { testStep1 @@ -83,12 +84,13 @@ internal class SimpleJobBuilderDslIntegrationTest { } // when - val job = batch { - job("testJob") { - stepBean("testStep1") - stepBean("testStep2") + val job = + batch { + job("testJob") { + stepBean("testStep1") + stepBean("testStep2") + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -107,28 +109,29 @@ internal class SimpleJobBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -145,36 +148,39 @@ internal class SimpleJobBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val testStep2 = batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep2 = + batch { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) - step(testStep2) + val job = + batch { + job("testJob") { + step(testStep1) + step(testStep2) + } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -189,28 +195,25 @@ internal class SimpleJobBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt index d1373a2..b330ab8 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt @@ -23,8 +23,8 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -43,7 +43,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class SplitBuilderDslIntegrationTest { - @Test fun testFlowBean() { // given @@ -52,42 +51,45 @@ internal class SplitBuilderDslIntegrationTest { val batch = context.getBean() val callerThread = Thread.currentThread().name var taskExecutorCallCount = 0 - val taskExecutor = object : ThreadPoolTaskExecutor() { - override fun execute(task: Runnable) { - ++taskExecutorCallCount - super.execute(task) - } - }.apply { initialize() } + val taskExecutor = + object : ThreadPoolTaskExecutor() { + override fun execute(task: Runnable) { + ++taskExecutorCallCount + super.execute(task) + } + }.apply { initialize() } var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } context.apply { registerBean("testFlow1") { testFlow1 @@ -98,14 +100,15 @@ internal class SplitBuilderDslIntegrationTest { } // when - val job = batch { - job("testJob") { - split(taskExecutor) { - flowBean("testFlow1") - flowBean("testFlow2") + val job = + batch { + job("testJob") { + split(taskExecutor) { + flowBean("testFlow1") + flowBean("testFlow2") + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -126,44 +129,46 @@ internal class SplitBuilderDslIntegrationTest { var testStep1CallCount = 0 var testStep2CallCount = 0 val callerThread = Thread.currentThread().name - val taskExecutor = object : ThreadPoolTaskExecutor() { - override fun execute(task: Runnable) { - ++taskExecutorCallCount - super.execute(task) - } - }.apply { initialize() } + val taskExecutor = + object : ThreadPoolTaskExecutor() { + override fun execute(task: Runnable) { + ++taskExecutorCallCount + super.execute(task) + } + }.apply { initialize() } // when - val job = batch { - job("testJob") { - split(taskExecutor) { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + split(taskExecutor) { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -182,52 +187,56 @@ internal class SplitBuilderDslIntegrationTest { val batch = context.getBean() val callerThread = Thread.currentThread().name var taskExecutorCallCount = 0 - val taskExecutor = object : ThreadPoolTaskExecutor() { - override fun execute(task: Runnable) { - ++taskExecutorCallCount - super.execute(task) - } - }.apply { initialize() } + val taskExecutor = + object : ThreadPoolTaskExecutor() { + override fun execute(task: Runnable) { + ++taskExecutorCallCount + super.execute(task) + } + }.apply { initialize() } var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow1 = batch { - flow("testFlow1") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow1 = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } - val testFlow2 = batch { - flow("testFlow2") { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow2 = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + assertThat(Thread.currentThread().name).isNotEqualTo(callerThread) + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - split(taskExecutor) { - flow(testFlow1) - flow(testFlow2) + val job = + batch { + job("testJob") { + split(taskExecutor) { + flow(testFlow1) + flow(testFlow2) + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -243,9 +252,10 @@ internal class SplitBuilderDslIntegrationTest { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() - val taskExecutor = ThreadPoolTaskExecutor().apply { - initialize() - } + val taskExecutor = + ThreadPoolTaskExecutor().apply { + initialize() + } // when, then assertThatThrownBy { @@ -264,28 +274,25 @@ internal class SplitBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 422d700..09b5918 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -22,8 +22,8 @@ import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.tasklet.Tasklet @@ -45,17 +45,17 @@ import javax.sql.DataSource @Suppress("DEPRECATION") internal class StepBuilderDslIntegrationTest { - @Test fun testDeprecatedTaskletBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() var taskletCallCount = 0 - val tasklet = Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } + val tasklet = + Tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } context.registerBean("testTasklet") { tasklet } @@ -79,10 +79,11 @@ internal class StepBuilderDslIntegrationTest { val batch = context.getBean() var taskletCallCount = 0 var taskExecutorCallCount = 0 - val tasklet = Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } + val tasklet = + Tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } context.registerBean("testTasklet") { tasklet } @@ -269,22 +270,24 @@ internal class StepBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var taskletCallCount = 0 - val tasklet = Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } + val tasklet = + Tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } context.registerBean("testTasklet") { tasklet } // when - val job = batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet", ResourcelessTransactionManager()) + val job = + batch { + job("testJob") { + step("testStep") { + taskletBean("testTasklet", ResourcelessTransactionManager()) + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -300,27 +303,29 @@ internal class StepBuilderDslIntegrationTest { val batch = context.getBean() var taskletCallCount = 0 var taskExecutorCallCount = 0 - val tasklet = Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } + val tasklet = + Tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } context.registerBean("testTasklet") { tasklet } // when - val job = batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet", ResourcelessTransactionManager()) { - taskExecutor { - ++taskExecutorCallCount - it.run() + val job = + batch { + job("testJob") { + step("testStep") { + taskletBean("testTasklet", ResourcelessTransactionManager()) { + taskExecutor { + ++taskExecutorCallCount + it.run() + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -338,19 +343,20 @@ internal class StepBuilderDslIntegrationTest { var taskletCallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -368,24 +374,25 @@ internal class StepBuilderDslIntegrationTest { var taskExecutorCallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) { - taskExecutor { - ++taskExecutorCallCount - it.run() + val job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) { + taskExecutor { + ++taskExecutorCallCount + it.run() + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -406,25 +413,26 @@ internal class StepBuilderDslIntegrationTest { var writeCallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - chunk(chunkSize, ResourcelessTransactionManager()) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val job = + batch { + job("testJob") { + step("testStep") { + chunk(chunkSize, ResourcelessTransactionManager()) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++writeCallCount } - } - writer { - ++writeCallCount } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -445,25 +453,26 @@ internal class StepBuilderDslIntegrationTest { var writeCallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - chunk(SimpleCompletionPolicy(chunkSize), ResourcelessTransactionManager()) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val job = + batch { + job("testJob") { + step("testStep") { + chunk(SimpleCompletionPolicy(chunkSize), ResourcelessTransactionManager()) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++writeCallCount } - } - writer { - ++writeCallCount } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -484,30 +493,31 @@ internal class StepBuilderDslIntegrationTest { var writeCallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - chunk( - RepeatTemplate().apply { - setCompletionPolicy(SimpleCompletionPolicy(chunkSize)) - }, - ResourcelessTransactionManager(), - ) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val job = + batch { + job("testJob") { + step("testStep") { + chunk( + RepeatTemplate().apply { + setCompletionPolicy(SimpleCompletionPolicy(chunkSize)) + }, + ResourcelessTransactionManager(), + ) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++writeCallCount } - } - writer { - ++writeCallCount } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -525,19 +535,20 @@ internal class StepBuilderDslIntegrationTest { var partitionHandlerCallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - partitioner { - partitionHandler { _, _ -> - ++partitionHandlerCallCount - listOf() + val job = + batch { + job("testJob") { + step("testStep") { + partitioner { + partitionHandler { _, _ -> + ++partitionHandlerCallCount + listOf() + } + splitter("splitStep") { mapOf() } } - splitter("splitStep") { mapOf() } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -552,29 +563,31 @@ internal class StepBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var stepCallCount = 0 - val testJob2 = batch { - job("testJob2") { - step("testStep2") { - ++stepCallCount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++stepCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } } } - } context.registerBean("testJob2") { testJob2 } // when - val job = batch { - job("testJob") { - step("testStep") { - jobBean("testJob2") + val job = + batch { + job("testJob") { + step("testStep") { + jobBean("testJob2") + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -590,34 +603,36 @@ internal class StepBuilderDslIntegrationTest { val batch = context.getBean() var stepCallCount = 0 var jobParametersExtractorCallCount = 0 - val testJob2 = batch { - job("testJob2") { - step("testStep2") { - ++stepCallCount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++stepCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } } } - } context.registerBean("testJob2") { testJob2 } // when - val job = batch { - job("testJob") { - step("testStep") { - jobBean("testJob2") { - parametersExtractor { _, _ -> - ++jobParametersExtractorCallCount - JobParameters() + val job = + batch { + job("testJob") { + step("testStep") { + jobBean("testJob2") { + parametersExtractor { _, _ -> + ++jobParametersExtractorCallCount + JobParameters() + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -633,26 +648,28 @@ internal class StepBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var stepCallCount = 0 - val testJob2 = batch { - job("testJob2") { - step("testStep2") { - ++stepCallCount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++stepCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - step("testStep") { - job(testJob2) + val job = + batch { + job("testJob") { + step("testStep") { + job(testJob2) + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -668,31 +685,33 @@ internal class StepBuilderDslIntegrationTest { val batch = context.getBean() var jobCallcount = 0 var jobParametersExtractorCallCount = 0 - val testJob2 = batch { - job("testJob2") { - step("testStep2") { - ++jobCallcount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++jobCallcount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - step("testStep") { - job(testJob2) { - parametersExtractor { _, _ -> - ++jobParametersExtractorCallCount - JobParameters() + val job = + batch { + job("testJob") { + step("testStep") { + job(testJob2) { + parametersExtractor { _, _ -> + ++jobParametersExtractorCallCount + JobParameters() + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -709,40 +728,42 @@ internal class StepBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow = batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } context.registerBean("testFlow") { testFlow } // when - val job = batch { - job("testJob") { - step("testStep") { - flowBean("testFlow") + val job = + batch { + job("testJob") { + step("testStep") { + flowBean("testFlow") + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -761,32 +782,33 @@ internal class StepBuilderDslIntegrationTest { var testStep2CallCount = 0 // when - val job = batch { - job("testJob") { - step("testStep") { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step("testStep") { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -803,37 +825,39 @@ internal class StepBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 - val testFlow = batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } - } // when - val job = batch { - job("testJob") { - step("testStep") { - flow(testFlow) + val job = + batch { + job("testJob") { + step("testStep") { + flow(testFlow) + } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -848,28 +872,25 @@ internal class StepBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt index 10b807f..8a539ac 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt @@ -24,8 +24,8 @@ import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -42,7 +42,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class StepTransitionBuilderDslIntegrationTest { - @RepeatedTest(10) fun testStepWithMultipleTransition() { // given @@ -51,32 +50,34 @@ internal class StepTransitionBuilderDslIntegrationTest { val batch = context.getBean() val expectedExitStatus = randomExitStatus() var testStep1CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { contribution, _ -> - ++testStep1CallCount - contribution.exitStatus = expectedExitStatus - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { contribution, _ -> + ++testStep1CallCount + contribution.exitStatus = expectedExitStatus + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - end() - } - on("*") { - fail() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + end() + } + on("*") { + fail() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -99,16 +100,17 @@ internal class StepTransitionBuilderDslIntegrationTest { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when, then assertThatThrownBy { @@ -122,8 +124,8 @@ internal class StepTransitionBuilderDslIntegrationTest { }.hasMessageContaining("should set transition for step") } - private fun randomExitStatus(): ExitStatus { - return listOf( + private fun randomExitStatus(): ExitStatus = + listOf( ExitStatus.UNKNOWN, ExitStatus.NOOP, ExitStatus.FAILED, @@ -131,7 +133,6 @@ internal class StepTransitionBuilderDslIntegrationTest { ExitStatus.COMPLETED, // ExitStatus.EXECUTING, // why considered ExitStatus.COMPLETE? ).random() - } @Configuration @EnableBatchProcessing( @@ -139,28 +140,25 @@ internal class StepTransitionBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt index 940e155..bcaf9c7 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt @@ -23,10 +23,10 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus @@ -47,7 +47,6 @@ import javax.sql.DataSource * Separated from FlowJobBuilderDslIntegrationTest since it's too big. */ internal class TransitionBuilderDslIntegrationTest { - @Test fun testTransitionToStepBean() { // given @@ -56,42 +55,45 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.registerBean("transitionStep") { transitionStep } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stepBean("transitionStep") + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stepBean("transitionStep") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -109,36 +111,38 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -156,39 +160,42 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - step(transitionStep) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + step(transitionStep) + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -206,52 +213,55 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } - } context.registerBean("transitionStep") { transitionStep } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stepBean("transitionStep") { - on("COMPLETED") { - fail() - } - on("FAILED") { - end("TEST") - } - on("*") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stepBean("transitionStep") { + on("COMPLETED") { + fail() + } + on("FAILED") { + end("TEST") + } + on("*") { + end() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -269,49 +279,51 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - step( - "transitionStep", - { - tasklet( - { _, _ -> - ++transitionStepCallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - fail() - } - on("FAILED") { - end("TEST") - } - on("*") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + step( + "transitionStep", + { + tasklet( + { _, _ -> + ++transitionStepCallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + }, + ) { + on("COMPLETED") { + fail() + } + on("FAILED") { + end("TEST") + } + on("*") { + end() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -329,49 +341,52 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - throw RuntimeException("Error") - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + throw RuntimeException("Error") + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - step(transitionStep) { - on("COMPLETED") { - fail() - } - on("FAILED") { - end("TEST") - } - on("*") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + step(transitionStep) { + on("COMPLETED") { + fail() + } + on("FAILED") { + end("TEST") + } + on("*") { + end() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -389,44 +404,47 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } context.registerBean("transitionFlow") { transitionFlow } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flowBean("transitionFlow") + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flowBean("transitionFlow") + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -444,38 +462,40 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow("transitionFlow") { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -493,41 +513,44 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow(transitionFlow) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow(transitionFlow) + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -545,51 +568,54 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } context.registerBean("transitionFlow") { transitionFlow } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flowBean("transitionFlow") { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flowBean("transitionFlow") { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -607,48 +633,50 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow( - "transitionFlow", - { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow( + "transitionFlow", + { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + }, + ) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() } - }, - ) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -666,48 +694,51 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow(transitionFlow) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow(transitionFlow) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -725,45 +756,48 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus("SKIPPED") } - } - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus("SKIPPED") - } context.registerBean("testDecider") { testDecider } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - deciderBean("testDecider") { - on("COMPLETED") { - fail() - } - on("SKIPPED") { - end("TEST") - } - on("*") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + deciderBean("testDecider") { + on("COMPLETED") { + fail() + } + on("SKIPPED") { + end("TEST") + } + on("*") { + end() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -781,42 +815,45 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus("SKIPPED") } - } - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus("SKIPPED") - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - decider(testDecider) { - on("COMPLETED") { - fail() - } - on("SKIPPED") { - end("TEST") - } - on("*") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + decider(testDecider) { + on("COMPLETED") { + fail() + } + on("SKIPPED") { + end("TEST") + } + on("*") { + end() + } } } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -833,28 +870,30 @@ internal class TransitionBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stop() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -871,44 +910,47 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } context.registerBean("transitionFlow") { transitionFlow } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlowBean("transitionFlow") + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlowBean("transitionFlow") + } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -932,38 +974,40 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlow("transitionFlow") { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -987,41 +1031,44 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlow(transitionFlow) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow(transitionFlow) + } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1045,51 +1092,54 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } context.registerBean("transitionFlow") { transitionFlow } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlowBean("transitionFlow") { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlowBean("transitionFlow") { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1113,45 +1163,47 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlow("transitionFlow", { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - },) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow("transitionFlow", { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + }) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1175,48 +1227,51 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val transitionFlow = batch { - flow("transitionFlow") { - step("transitionStep") { + val testStep1 = + batch { + step("testStep1") { tasklet( { _, _ -> - ++transitionStepCallCount + ++testStep1CallCount RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - } + val transitionFlow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlow(transitionFlow) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow(transitionFlow) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1241,50 +1296,53 @@ internal class TransitionBuilderDslIntegrationTest { var testStep1CallCount = 0 var testDeciderCallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.UNKNOWN } - } - val testDecider = JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.UNKNOWN - } context.registerBean("testDecider") { testDecider } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToDeciderBean("testDecider") { - on("UNKNOWN") { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToDeciderBean("testDecider") { + on("UNKNOWN") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + on("*") { + fail() } - } - on("*") { - fail() } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1310,48 +1368,50 @@ internal class TransitionBuilderDslIntegrationTest { var testStep1CallCount = 0 var testDeciderCallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToDecider( - { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.UNKNOWN - }, - ) { - on("UNKNOWN") { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToDecider( + { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.UNKNOWN + }, + ) { + on("UNKNOWN") { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + on("*") { + fail() } - } - on("*") { - fail() } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1376,42 +1436,45 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.registerBean("transitionStep") { transitionStep } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToStepBean("transitionStep") + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToStepBean("transitionStep") + } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1435,36 +1498,38 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToStep("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToStep("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1488,39 +1553,42 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToStep(transitionStep) + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToStep(transitionStep) + } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1544,49 +1612,52 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } context.registerBean("transitionStep") { transitionStep } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToStepBean("transitionStep") { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToStepBean("transitionStep") { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1610,43 +1681,45 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToStep("transitionStep", { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - },) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToStep("transitionStep", { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + }) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1670,46 +1743,49 @@ internal class TransitionBuilderDslIntegrationTest { val batch = context.getBean() var testStep1CallCount = 0 var transitionStepCallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } - val transitionStep = batch { - step("transitionStep") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val transitionStep = + batch { + step("transitionStep") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToStep(transitionStep) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToStep(transitionStep) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } } } } } } - } val firstJobExecution = jobLauncher.run(job, JobParameters()) val secondJobExecution = jobLauncher.run(job, JobParameters()) val thirdJobExecution = jobLauncher.run(job, JobParameters()) @@ -1732,29 +1808,31 @@ internal class TransitionBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { contribution, _ -> - ++testStep1CallCount - contribution.exitStatus = ExitStatus.UNKNOWN - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { contribution, _ -> + ++testStep1CallCount + contribution.exitStatus = ExitStatus.UNKNOWN + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("UNKNOWN") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("UNKNOWN") { + end() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -1770,32 +1848,34 @@ internal class TransitionBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { contribution, _ -> - ++testStep1CallCount - contribution.exitStatus = ExitStatus.UNKNOWN - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { contribution, _ -> + ++testStep1CallCount + contribution.exitStatus = ExitStatus.UNKNOWN + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("UNKNOWN") { - end("TEST") - } - on("*") { - end() + val job = + batch { + job("testJob") { + step(testStep1) { + on("UNKNOWN") { + end("TEST") + } + on("*") { + end() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -1811,28 +1891,30 @@ internal class TransitionBuilderDslIntegrationTest { val jobLauncher = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when - val job = batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - fail() + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + fail() + } } } } - } val jobExecution = jobLauncher.run(job, JobParameters()) // then @@ -1846,16 +1928,17 @@ internal class TransitionBuilderDslIntegrationTest { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() - val testStep1 = batch { - step("testStep1") { - tasklet( - { _, _ -> - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } } - } // when, then assertThatThrownBy { @@ -1876,28 +1959,25 @@ internal class TransitionBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { - @Bean open fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl = BatchDsl( - beanFactory, - jobRepository, - ) + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) @Bean - open fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - open fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt index 4f79be9..2ed5f6c 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/BatchDsl.kt @@ -21,11 +21,11 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import org.springframework.batch.core.job.Job -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.BeanFactory @@ -53,7 +53,10 @@ class BatchDsl internal constructor( /** * Make a new job. */ - fun job(name: String, init: JobBuilderDsl.() -> Unit): Job { + fun job( + name: String, + init: JobBuilderDsl.() -> Unit, + ): Job { val jobRepository = this.dslContext.jobRepository val jobBuilder = JobBuilder(name, jobRepository) return JobBuilderDsl(this.dslContext, jobBuilder).apply(init).build() @@ -62,7 +65,10 @@ class BatchDsl internal constructor( /** * Make a new step. */ - fun step(name: String, init: StepBuilderDsl.() -> Step): Step { + fun step( + name: String, + init: StepBuilderDsl.() -> Step, + ): Step { val jobRepository = this.dslContext.jobRepository val stepBuilder = StepBuilder(name, jobRepository) return StepBuilderDsl(this.dslContext, stepBuilder).let(init) @@ -71,7 +77,10 @@ class BatchDsl internal constructor( /** * Make a new flow. */ - fun flow(name: String, init: FlowBuilderDsl.() -> Unit): Flow { + fun flow( + name: String, + init: FlowBuilderDsl.() -> Unit, + ): Flow { val flowBuilder = FlowBuilder(name) return ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(init).build() } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt index 871d36d..e9489c9 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.getBean import org.springframework.core.task.TaskExecutor @@ -49,7 +49,10 @@ internal class ConcreteFlowBuilderDsl internal constructor( /** * Add step. */ - override fun step(name: String, stepInit: StepBuilderDsl.() -> Step) { + override fun step( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) { val stepBuilder = StepBuilder(name, this.dslContext.jobRepository) val step = StepBuilderDsl(this.dslContext, stepBuilder).let(stepInit) step(step) @@ -59,12 +62,13 @@ internal class ConcreteFlowBuilderDsl internal constructor( * Add step. */ override fun step(step: Step) { - val baseFlowBuilder = if (!this.started) { - this.started = true - this.flowBuilder.start(step) - } else { - this.flowBuilder.next(step) - } + val baseFlowBuilder = + if (!this.started) { + this.started = true + this.flowBuilder.start(step) + } else { + this.flowBuilder.next(step) + } this.flowBuilder = baseFlowBuilder } @@ -72,7 +76,10 @@ internal class ConcreteFlowBuilderDsl internal constructor( /** * Add step by bean name with transition. */ - override fun stepBean(name: String, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { + override fun stepBean( + name: String, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { val step = this.dslContext.beanFactory.getBean(name) step(step, stepTransitionInit) } @@ -93,17 +100,22 @@ internal class ConcreteFlowBuilderDsl internal constructor( /** * Add step with transition. */ - override fun step(step: Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { - val baseFlowBuilder = if (!this.started) { - this.started = true - this.flowBuilder.start(step) - } else { - this.flowBuilder.next(step) - } - - this.flowBuilder = StepTransitionBuilderDsl(this.dslContext, step, baseFlowBuilder) - .apply(stepTransitionInit) - .build() + override fun step( + step: Step, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { + val baseFlowBuilder = + if (!this.started) { + this.started = true + this.flowBuilder.start(step) + } else { + this.flowBuilder.next(step) + } + + this.flowBuilder = + StepTransitionBuilderDsl(this.dslContext, step, baseFlowBuilder) + .apply(stepTransitionInit) + .build() } /** @@ -117,10 +129,15 @@ internal class ConcreteFlowBuilderDsl internal constructor( /** * Add flow. */ - override fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit) { + override fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() flow(flow) } @@ -128,12 +145,13 @@ internal class ConcreteFlowBuilderDsl internal constructor( * Add flow. */ override fun flow(flow: Flow) { - val baseFlowBuilder = if (!this.started) { - this.started = true - this.flowBuilder.start(flow) - } else { - this.flowBuilder.next(flow) - } + val baseFlowBuilder = + if (!this.started) { + this.started = true + this.flowBuilder.start(flow) + } else { + this.flowBuilder.next(flow) + } this.flowBuilder = baseFlowBuilder } @@ -141,7 +159,10 @@ internal class ConcreteFlowBuilderDsl internal constructor( /** * Add flow by bean name with transition. */ - override fun flowBean(name: String, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { + override fun flowBean( + name: String, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { val flow = this.dslContext.beanFactory.getBean(name) flow(flow, flowTransitionInit) } @@ -155,25 +176,32 @@ internal class ConcreteFlowBuilderDsl internal constructor( flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() flow(flow, flowTransitionInit) } /** * Add flow with transition. */ - override fun flow(flow: Flow, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { - val baseFlowBuilder = if (!this.started) { - this.started = true - this.flowBuilder.start(flow) - } else { - this.flowBuilder.next(flow) - } - - this.flowBuilder = FlowTransitionBuilderDsl(this.dslContext, flow, baseFlowBuilder) - .apply(flowTransitionInit) - .build() + override fun flow( + flow: Flow, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { + val baseFlowBuilder = + if (!this.started) { + this.started = true + this.flowBuilder.start(flow) + } else { + this.flowBuilder.next(flow) + } + + this.flowBuilder = + FlowTransitionBuilderDsl(this.dslContext, flow, baseFlowBuilder) + .apply(flowTransitionInit) + .build() } /** @@ -194,16 +222,18 @@ internal class ConcreteFlowBuilderDsl internal constructor( decider: JobExecutionDecider, deciderTransitionInit: DeciderTransitionBuilderDsl.() -> Unit, ) { - val baseUnterminatedFlowBuilder = if (!started) { - this.started = true - this.flowBuilder.start(decider) - } else { - this.flowBuilder.next(decider) - } - - this.flowBuilder = DeciderTransitionBuilderDsl(this.dslContext, decider, baseUnterminatedFlowBuilder) - .apply(deciderTransitionInit) - .build() + val baseUnterminatedFlowBuilder = + if (!started) { + this.started = true + this.flowBuilder.start(decider) + } else { + this.flowBuilder.next(decider) + } + + this.flowBuilder = + DeciderTransitionBuilderDsl(this.dslContext, decider, baseUnterminatedFlowBuilder) + .apply(deciderTransitionInit) + .build() } /** @@ -211,10 +241,15 @@ internal class ConcreteFlowBuilderDsl internal constructor( * * @see [FlowBuilder.split][org.springframework.batch.core.job.builder.FlowBuilder.split] */ - override fun split(taskExecutor: TaskExecutor, splitInit: SplitBuilderDsl.() -> Unit) { + override fun split( + taskExecutor: TaskExecutor, + splitInit: SplitBuilderDsl.() -> Unit, + ) { val splitBuilder = this.flowBuilder.split(taskExecutor) - this.flowBuilder = SplitBuilderDsl(this.dslContext, splitBuilder).apply(splitInit) - .build() + this.flowBuilder = + SplitBuilderDsl(this.dslContext, splitBuilder) + .apply(splitInit) + .build() } internal fun build(): T = this.flowBuilder.build() diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDsl.kt index 3c74f73..211351a 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDsl.kt @@ -41,23 +41,29 @@ class DeciderTransitionBuilderDsl internal constructor( * * @see [org.springframework.batch.core.job.builder.FlowBuilder.on] */ - fun on(pattern: String, init: TransitionBuilderDsl.() -> Unit) { + fun on( + pattern: String, + init: TransitionBuilderDsl.() -> Unit, + ) { val flowBuilder = this.flowBuilder - val transitionBuilder = if (flowBuilder == null) { - this.baseUnterminatedFlowBuilder.on(pattern) - } else { - flowBuilder.from(this.decider) - .on(pattern) - } + val transitionBuilder = + if (flowBuilder == null) { + this.baseUnterminatedFlowBuilder.on(pattern) + } else { + flowBuilder + .from(this.decider) + .on(pattern) + } - this.flowBuilder = TransitionBuilderDsl(this.dslContext, transitionBuilder).apply(init) - .build() + this.flowBuilder = + TransitionBuilderDsl(this.dslContext, transitionBuilder) + .apply(init) + .build() } - internal fun build(): FlowBuilder { - return checkNotNull(this.flowBuilder) { + internal fun build(): FlowBuilder = + checkNotNull(this.flowBuilder) { "should set transition for decider $decider." } - } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt index e168f51..aa7f789 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor /** @@ -32,7 +32,6 @@ import org.springframework.core.task.TaskExecutor */ @BatchDslMarker interface FlowBuilderDsl { - /** * Add step by bean name. */ @@ -41,7 +40,10 @@ interface FlowBuilderDsl { /** * Add step. */ - fun step(name: String, stepInit: StepBuilderDsl.() -> Step) + fun step( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) /** * Add step. @@ -51,7 +53,10 @@ interface FlowBuilderDsl { /** * Add step by bean name with transition. */ - fun stepBean(name: String, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) + fun stepBean( + name: String, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) /** * Add step with transition. @@ -65,7 +70,10 @@ interface FlowBuilderDsl { /** * Add step with transition. */ - fun step(step: Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) + fun step( + step: Step, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) /** * Add flow by bean name. @@ -75,7 +83,10 @@ interface FlowBuilderDsl { /** * Add flow. */ - fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit) + fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ) /** * Add flow. @@ -85,7 +96,10 @@ interface FlowBuilderDsl { /** * Add flow by bean name with transition. */ - fun flowBean(name: String, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) + fun flowBean( + name: String, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) /** * Add flow with transition. @@ -99,7 +113,10 @@ interface FlowBuilderDsl { /** * Add flow with transition. */ - fun flow(flow: Flow, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) + fun flow( + flow: Flow, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) /** * Add decider by bean name with transition. @@ -122,5 +139,8 @@ interface FlowBuilderDsl { * * @see [FlowBuilder.split][org.springframework.batch.core.job.builder.FlowBuilder.split] */ - fun split(taskExecutor: TaskExecutor, splitInit: SplitBuilderDsl.() -> Unit) + fun split( + taskExecutor: TaskExecutor, + splitInit: SplitBuilderDsl.() -> Unit, + ) } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt index bdbfc6b..30ee4cf 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt @@ -32,7 +32,8 @@ internal class FlowJobBuilderDsl internal constructor( private val dslContext: DslContext, private val delegate: ConcreteFlowBuilderDsl, ) : FlowBuilderDsl by delegate { - - internal fun build(): Job = this.delegate.build() - .build() + internal fun build(): Job = + this.delegate + .build() + .build() } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDsl.kt index dcb7259..1df4c78 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDsl.kt @@ -41,23 +41,29 @@ class FlowTransitionBuilderDsl internal constructor( * * @see [org.springframework.batch.core.job.builder.FlowBuilder.on] */ - fun on(pattern: String, init: TransitionBuilderDsl.() -> Unit) { + fun on( + pattern: String, + init: TransitionBuilderDsl.() -> Unit, + ) { val flowBuilder = this.flowBuilder - val transitionBuilder = if (flowBuilder == null) { - this.baseFlowBuilder.on(pattern) - } else { - flowBuilder.from(this.flow) - .on(pattern) - } + val transitionBuilder = + if (flowBuilder == null) { + this.baseFlowBuilder.on(pattern) + } else { + flowBuilder + .from(this.flow) + .on(pattern) + } - this.flowBuilder = TransitionBuilderDsl(this.dslContext, transitionBuilder).apply(init) - .build() + this.flowBuilder = + TransitionBuilderDsl(this.dslContext, transitionBuilder) + .apply(init) + .build() } - internal fun build(): FlowBuilder { - return checkNotNull(this.flowBuilder) { + internal fun build(): FlowBuilder = + checkNotNull(this.flowBuilder) { "should set transition for flow ${flow.name}" } - } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt index 0268368..4d6e043 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt @@ -24,10 +24,6 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigur import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry import org.springframework.batch.core.job.Job -import org.springframework.batch.core.listener.JobExecutionListener -import org.springframework.batch.core.job.parameters.JobParametersIncrementer -import org.springframework.batch.core.job.parameters.JobParametersValidator -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowJobBuilder import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.builder.JobBuilderHelper @@ -35,8 +31,12 @@ import org.springframework.batch.core.job.builder.JobFlowBuilder import org.springframework.batch.core.job.builder.SimpleJobBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.job.parameters.JobParametersIncrementer +import org.springframework.batch.core.job.parameters.JobParametersValidator +import org.springframework.batch.core.listener.JobExecutionListener import org.springframework.batch.core.observability.BatchJobObservationConvention import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor /** @@ -49,7 +49,6 @@ class JobBuilderDsl internal constructor( private val dslContext: DslContext, private val jobBuilder: JobBuilder, ) : FlowBuilderDsl { - private var lazyConfigurer = LazyConfigurer>() private var lazyFlowConfigurer = LazyConfigurer>() @@ -150,7 +149,10 @@ class JobBuilderDsl internal constructor( } } - override fun step(name: String, stepInit: StepBuilderDsl.() -> Step) { + override fun step( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) { this.lazyFlowConfigurer.add { it.step(name, stepInit) } @@ -162,7 +164,10 @@ class JobBuilderDsl internal constructor( } } - override fun stepBean(name: String, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { + override fun stepBean( + name: String, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { this.lazyFlowConfigurer.add { it.stepBean(name, stepTransitionInit) } @@ -180,7 +185,10 @@ class JobBuilderDsl internal constructor( this.isFlowJob = true } - override fun step(step: Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { + override fun step( + step: Step, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { this.lazyFlowConfigurer.add { it.step(step, stepTransitionInit) } @@ -194,7 +202,10 @@ class JobBuilderDsl internal constructor( this.isFlowJob = true } - override fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit) { + override fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ) { this.lazyFlowConfigurer.add { it.flow(name, flowInit) } @@ -208,7 +219,10 @@ class JobBuilderDsl internal constructor( this.isFlowJob = true } - override fun flowBean(name: String, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { + override fun flowBean( + name: String, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { this.lazyFlowConfigurer.add { it.flowBean(name, flowTransitionInit) } @@ -226,7 +240,10 @@ class JobBuilderDsl internal constructor( this.isFlowJob = true } - override fun flow(flow: Flow, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { + override fun flow( + flow: Flow, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { this.lazyFlowConfigurer.add { it.flow(flow, flowTransitionInit) } @@ -253,7 +270,10 @@ class JobBuilderDsl internal constructor( this.isFlowJob = true } - override fun split(taskExecutor: TaskExecutor, splitInit: SplitBuilderDsl.() -> Unit) { + override fun split( + taskExecutor: TaskExecutor, + splitInit: SplitBuilderDsl.() -> Unit, + ) { this.lazyFlowConfigurer.add { it.split(taskExecutor, splitInit) } @@ -266,13 +286,15 @@ class JobBuilderDsl internal constructor( return if (!isFlowJob) { val simpleJobBuilder = SimpleJobBuilder(this.jobBuilder) val simpleJobBuilderDsl = SimpleJobBuilderDsl(this.dslContext, simpleJobBuilder) - SimpleJobBuilderDslAdapter(simpleJobBuilderDsl).apply(this.lazyFlowConfigurer) + SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) + .apply(this.lazyFlowConfigurer) .build() } else { val flowJobBuilder = FlowJobBuilder(this.jobBuilder) val jobFlowBuilder = JobFlowBuilder(flowJobBuilder) val delegate = ConcreteFlowBuilderDsl(this.dslContext, jobFlowBuilder) - FlowJobBuilderDsl(this.dslContext, delegate).apply(this.lazyFlowConfigurer) + FlowJobBuilderDsl(this.dslContext, delegate) + .apply(this.lazyFlowConfigurer) .build() } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt index c0dbf81..181c2ff 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt @@ -21,8 +21,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import org.springframework.batch.core.job.Job -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.SimpleJobBuilder +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.getBean @@ -34,13 +34,15 @@ internal class SimpleJobBuilderDsl internal constructor( private val dslContext: DslContext, private val simpleJobBuilder: SimpleJobBuilder, ) { - fun stepBean(name: String) { val step = this.dslContext.beanFactory.getBean(name) step(step) } - fun step(name: String, stepInit: StepBuilderDsl.() -> Step) { + fun step( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) { val stepBuilder = StepBuilder(name, this.dslContext.jobRepository) val step = StepBuilderDsl(this.dslContext, stepBuilder).let(stepInit) step(step) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt index a76abd3..95d4541 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import org.springframework.batch.core.job.Job -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowJobBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor /** @@ -33,12 +33,14 @@ import org.springframework.core.task.TaskExecutor internal class SimpleJobBuilderDslAdapter internal constructor( private val simpleJobBuilderDsl: SimpleJobBuilderDsl, ) : FlowBuilderDsl { - override fun stepBean(name: String) { this.simpleJobBuilderDsl.stepBean(name) } - override fun step(name: String, stepInit: StepBuilderDsl.() -> Step) { + override fun step( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) { this.simpleJobBuilderDsl.step(name, stepInit) } @@ -46,67 +48,61 @@ internal class SimpleJobBuilderDslAdapter internal constructor( this.simpleJobBuilderDsl.step(step) } - override fun stepBean(name: String, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun stepBean( + name: String, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") override fun step( name: String, stepInit: StepBuilderDsl.() -> Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, - ) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun step(step: Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun step( + step: Step, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun flowBean(name: String) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun flowBean(name: String): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun flow(flow: Flow) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun flow(flow: Flow): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun flowBean(name: String, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun flowBean( + name: String, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") override fun flow( name: String, flowInit: FlowBuilderDsl.() -> Unit, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, - ) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun flow(flow: Flow, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun flow( + flow: Flow, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") override fun deciderBean( name: String, deciderTransitionInit: DeciderTransitionBuilderDsl.() -> Unit, - ) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") override fun decider( decider: JobExecutionDecider, deciderTransitionInit: DeciderTransitionBuilderDsl.() -> Unit, - ) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") - override fun split(taskExecutor: TaskExecutor, splitInit: SplitBuilderDsl.() -> Unit) { - throw UnsupportedOperationException("SimpleJob can't process flow.") - } + override fun split( + taskExecutor: TaskExecutor, + splitInit: SplitBuilderDsl.() -> Unit, + ): Unit = throw UnsupportedOperationException("SimpleJob can't process flow.") internal fun build(): Job = this.simpleJobBuilderDsl.build() } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDsl.kt index a721b14..dd5c079 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDsl.kt @@ -47,10 +47,15 @@ class SplitBuilderDsl internal constructor( /** * Add flow to split. */ - fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit) { + fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() flow(flow) } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index 87bdfe3..994e770 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -28,12 +28,12 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry import org.springframework.batch.core.job.Job -import org.springframework.batch.core.step.Step -import org.springframework.batch.core.listener.StepExecutionListener import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow +import org.springframework.batch.core.listener.StepExecutionListener import org.springframework.batch.core.observability.BatchStepObservationConvention import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder @@ -53,7 +53,6 @@ class StepBuilderDsl internal constructor( private val dslContext: DslContext, private val stepBuilder: StepBuilder, ) { - /** * Set for [StepBuilder.repository][org.springframework.batch.core.step.builder.StepBuilderHelper.repository]. */ @@ -125,9 +124,7 @@ class StepBuilderDsl internal constructor( message = "spring batch 5.0.0 deprecates this", replaceWith = ReplaceWith("taskletBean(name, transactionManager)"), ) - fun taskletBean(name: String): Step { - return taskletBean(name) {} - } + fun taskletBean(name: String): Step = taskletBean(name) {} /** * Set tasklet step by bean name. @@ -137,7 +134,10 @@ class StepBuilderDsl internal constructor( message = "spring batch 5.0.0 deprecates this", replaceWith = ReplaceWith("taskletBean(name, transactionManager, taskletStepInit)"), ) - fun taskletBean(name: String, taskletStepInit: TaskletStepBuilderDsl.() -> Unit): Step { + fun taskletBean( + name: String, + taskletStepInit: TaskletStepBuilderDsl.() -> Unit, + ): Step { val tasklet = this.dslContext.beanFactory.getBean(name) return tasklet(tasklet, taskletStepInit) } @@ -150,9 +150,7 @@ class StepBuilderDsl internal constructor( message = "spring batch 5.0.0 deprecates this", replaceWith = ReplaceWith("tasklet(tasklet, transactionManager)"), ) - fun tasklet(tasklet: Tasklet): Step { - return tasklet(tasklet) {} - } + fun tasklet(tasklet: Tasklet): Step = tasklet(tasklet) {} /** * Set tasklet step. @@ -162,9 +160,13 @@ class StepBuilderDsl internal constructor( message = "spring batch 5.0.0 deprecates this", replaceWith = ReplaceWith("tasklet(tasklet, transactionManager, taskletStepInit)"), ) - fun tasklet(tasklet: Tasklet, taskletStepInit: TaskletStepBuilderDsl.() -> Unit): Step { + fun tasklet( + tasklet: Tasklet, + taskletStepInit: TaskletStepBuilderDsl.() -> Unit, + ): Step { val taskletStepBuilder = this.stepBuilder.tasklet(tasklet) - return TaskletStepBuilderDsl(this.dslContext, taskletStepBuilder).apply(taskletStepInit) + return TaskletStepBuilderDsl(this.dslContext, taskletStepBuilder) + .apply(taskletStepInit) .build() } @@ -176,9 +178,13 @@ class StepBuilderDsl internal constructor( message = "spring batch 5.0.0 deprecates this", replaceWith = ReplaceWith("chunk(chunkSize, transactionManager, simpleStepInit)"), ) - fun chunk(chunkSize: Int, simpleStepInit: SimpleStepBuilderDsl.() -> Unit): Step { + fun chunk( + chunkSize: Int, + simpleStepInit: SimpleStepBuilderDsl.() -> Unit, + ): Step { val simpleStepBuilder = this.stepBuilder.chunk(chunkSize) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder).apply(simpleStepInit) + return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) + .apply(simpleStepInit) .build() } @@ -195,7 +201,8 @@ class StepBuilderDsl internal constructor( simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { val simpleStepBuilder = this.stepBuilder.chunk(completionPolicy) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder).apply(simpleStepInit) + return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) + .apply(simpleStepInit) .build() } @@ -211,7 +218,8 @@ class StepBuilderDsl internal constructor( simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { val simpleStepBuilder = SimpleStepBuilder(this.stepBuilder).chunkOperations(repeatOperations) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder).apply(simpleStepInit) + return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) + .apply(simpleStepInit) .build() } @@ -221,9 +229,7 @@ class StepBuilderDsl internal constructor( fun taskletBean( name: String, transactionManager: PlatformTransactionManager, - ): Step { - return taskletBean(name, transactionManager) {} - } + ): Step = taskletBean(name, transactionManager) {} /** * Set tasklet step by bean name. @@ -243,9 +249,7 @@ class StepBuilderDsl internal constructor( fun tasklet( tasklet: Tasklet, transactionManager: PlatformTransactionManager, - ): Step { - return tasklet(tasklet, transactionManager) {} - } + ): Step = tasklet(tasklet, transactionManager) {} /** * Set tasklet step. @@ -256,7 +260,8 @@ class StepBuilderDsl internal constructor( taskletStepInit: TaskletStepBuilderDsl.() -> Unit, ): Step { val taskletStepBuilder = this.stepBuilder.tasklet(tasklet, transactionManager) - return TaskletStepBuilderDsl(this.dslContext, taskletStepBuilder).apply(taskletStepInit) + return TaskletStepBuilderDsl(this.dslContext, taskletStepBuilder) + .apply(taskletStepInit) .build() } @@ -269,7 +274,8 @@ class StepBuilderDsl internal constructor( simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { val simpleStepBuilder = this.stepBuilder.chunk(chunkSize, transactionManager) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder).apply(simpleStepInit) + return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) + .apply(simpleStepInit) .build() } @@ -282,7 +288,8 @@ class StepBuilderDsl internal constructor( simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { val simpleStepBuilder = this.stepBuilder.chunk(completionPolicy, transactionManager) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder).apply(simpleStepInit) + return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) + .apply(simpleStepInit) .build() } @@ -294,11 +301,13 @@ class StepBuilderDsl internal constructor( transactionManager: PlatformTransactionManager, simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { - val simpleStepBuilder = SimpleStepBuilder(this.stepBuilder).apply { - transactionManager(transactionManager) - chunkOperations(repeatOperations) - } - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder).apply(simpleStepInit) + val simpleStepBuilder = + SimpleStepBuilder(this.stepBuilder).apply { + transactionManager(transactionManager) + chunkOperations(repeatOperations) + } + return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) + .apply(simpleStepInit) .build() } @@ -307,21 +316,23 @@ class StepBuilderDsl internal constructor( */ fun partitioner(partitionStepInit: PartitionStepBuilderDsl.() -> Unit): Step { val partitionStepBuilder = PartitionStepBuilder(this.stepBuilder) - return PartitionStepBuilderDsl(this.dslContext, partitionStepBuilder).apply(partitionStepInit) + return PartitionStepBuilderDsl(this.dslContext, partitionStepBuilder) + .apply(partitionStepInit) .build() } /** * Set job step by bean name. */ - fun jobBean(name: String): Step { - return jobBean(name) {} - } + fun jobBean(name: String): Step = jobBean(name) {} /** * Set job step by bean name. */ - fun jobBean(name: String, jobStepInit: JobStepBuilderDsl.() -> Unit): Step { + fun jobBean( + name: String, + jobStepInit: JobStepBuilderDsl.() -> Unit, + ): Step { val job = this.dslContext.beanFactory.getBean(name) return job(job, jobStepInit) } @@ -329,16 +340,18 @@ class StepBuilderDsl internal constructor( /** * Set job step. */ - fun job(job: Job): Step { - return job(job) {} - } + fun job(job: Job): Step = job(job) {} /** * Set job step. */ - fun job(job: Job, jobStepInit: JobStepBuilderDsl.() -> Unit): Step { + fun job( + job: Job, + jobStepInit: JobStepBuilderDsl.() -> Unit, + ): Step { val jobStepBuilder = this.stepBuilder.job(job) - return JobStepBuilderDsl(this.dslContext, jobStepBuilder).apply(jobStepInit) + return JobStepBuilderDsl(this.dslContext, jobStepBuilder) + .apply(jobStepInit) .build() } @@ -353,10 +366,15 @@ class StepBuilderDsl internal constructor( /** * Set flow step. */ - fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit): Step { + fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ): Step { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() return flow(flow) } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt index 8176168..7a7ad92 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDsl.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder +import org.springframework.batch.core.step.Step /** * A dsl for step transition. @@ -42,23 +42,29 @@ class StepTransitionBuilderDsl internal constructor( * * @see [org.springframework.batch.core.job.builder.FlowBuilder.on] */ - fun on(pattern: String, init: TransitionBuilderDsl.() -> Unit) { + fun on( + pattern: String, + init: TransitionBuilderDsl.() -> Unit, + ) { val flowBuilder = this.flowBuilder - val transitionBuilder = if (flowBuilder == null) { - this.baseFlowBuilder.on(pattern) - } else { - flowBuilder.from(this.step) - .on(pattern) - } + val transitionBuilder = + if (flowBuilder == null) { + this.baseFlowBuilder.on(pattern) + } else { + flowBuilder + .from(this.step) + .on(pattern) + } - this.flowBuilder = TransitionBuilderDsl(this.dslContext, transitionBuilder).apply(init) - .build() + this.flowBuilder = + TransitionBuilderDsl(this.dslContext, transitionBuilder) + .apply(init) + .build() } - internal fun build(): FlowBuilder { - return checkNotNull(this.flowBuilder) { + internal fun build(): FlowBuilder = + checkNotNull(this.flowBuilder) { "should set transition for step ${step.name}." } - } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt index 121e8bc..6dfdc4f 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDsl.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.getBean @@ -50,7 +50,10 @@ class TransitionBuilderDsl internal constructor( /** * Transition to step. */ - fun step(name: String, stepInit: StepBuilderDsl.() -> Step) { + fun step( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) { val stepBuilder = StepBuilder(name, this.dslContext.jobRepository) val step = StepBuilderDsl(this.dslContext, stepBuilder).let(stepInit) step(step) @@ -60,14 +63,19 @@ class TransitionBuilderDsl internal constructor( * Transition to step. */ fun step(step: Step) { - this.flowBuilder = this.baseTransitionBuilder.to(step) - .from(step) + this.flowBuilder = + this.baseTransitionBuilder + .to(step) + .from(step) } /** * Transition to step by bean name and set another transition. */ - fun stepBean(name: String, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { + fun stepBean( + name: String, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { val step = this.dslContext.beanFactory.getBean(name) step(step, stepTransitionInit) } @@ -88,11 +96,15 @@ class TransitionBuilderDsl internal constructor( /** * Transition to step and set another transition. */ - fun step(step: Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { + fun step( + step: Step, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { val baseFlowBuilder = this.baseTransitionBuilder.to(step).from(step) - this.flowBuilder = StepTransitionBuilderDsl(this.dslContext, step, baseFlowBuilder) - .apply(stepTransitionInit) - .build() + this.flowBuilder = + StepTransitionBuilderDsl(this.dslContext, step, baseFlowBuilder) + .apply(stepTransitionInit) + .build() } /** @@ -106,10 +118,15 @@ class TransitionBuilderDsl internal constructor( /** * Transition to flow. */ - fun flow(name: String, flowInit: FlowBuilderDsl.() -> Unit) { + fun flow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() flow(flow) } @@ -117,14 +134,19 @@ class TransitionBuilderDsl internal constructor( * Transition to flow. */ fun flow(flow: Flow) { - this.flowBuilder = this.baseTransitionBuilder.to(flow) - .from(flow) + this.flowBuilder = + this.baseTransitionBuilder + .to(flow) + .from(flow) } /** * Transition to flow by bean name and set another transition. */ - fun flowBean(name: String, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { + fun flowBean( + name: String, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { val flow = this.dslContext.beanFactory.getBean(name) flow(flow, flowTransitionInit) } @@ -138,20 +160,28 @@ class TransitionBuilderDsl internal constructor( flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() flow(flow, flowTransitionInit) } /** * Transition to flow and set another transition. */ - fun flow(flow: Flow, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { - val baseFlowBuilder = this.baseTransitionBuilder.to(flow) - .from(flow) - this.flowBuilder = FlowTransitionBuilderDsl(this.dslContext, flow, baseFlowBuilder) - .apply(flowTransitionInit) - .build() + fun flow( + flow: Flow, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { + val baseFlowBuilder = + this.baseTransitionBuilder + .to(flow) + .from(flow) + this.flowBuilder = + FlowTransitionBuilderDsl(this.dslContext, flow, baseFlowBuilder) + .apply(flowTransitionInit) + .build() } /** @@ -172,15 +202,17 @@ class TransitionBuilderDsl internal constructor( decider: JobExecutionDecider, deciderTransitionInit: DeciderTransitionBuilderDsl.() -> Unit, ) { - val baseUnterminatedFlowBuilder = this.baseTransitionBuilder.to(decider) - .from(decider) - this.flowBuilder = DeciderTransitionBuilderDsl( - this.dslContext, - decider, - baseUnterminatedFlowBuilder, - ) - .apply(deciderTransitionInit) - .build() + val baseUnterminatedFlowBuilder = + this.baseTransitionBuilder + .to(decider) + .from(decider) + this.flowBuilder = + DeciderTransitionBuilderDsl( + this.dslContext, + decider, + baseUnterminatedFlowBuilder, + ).apply(deciderTransitionInit) + .build() } /** @@ -201,10 +233,15 @@ class TransitionBuilderDsl internal constructor( /** * Transition to stop and restart with flow if the flow is restarted. */ - fun stopAndRestartToFlow(name: String, flowInit: FlowBuilderDsl.() -> Unit) { + fun stopAndRestartToFlow( + name: String, + flowInit: FlowBuilderDsl.() -> Unit, + ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() stopAndRestartToFlow(flow) } @@ -235,21 +272,29 @@ class TransitionBuilderDsl internal constructor( flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, ) { val flowBuilder = FlowBuilder(name) - val flow = ConcreteFlowBuilderDsl(this.dslContext, flowBuilder).apply(flowInit) - .build() + val flow = + ConcreteFlowBuilderDsl(this.dslContext, flowBuilder) + .apply(flowInit) + .build() stopAndRestartToFlow(flow, flowTransitionInit) } /** * Transition to stop and restart with flow if the flow is restarted. */ - fun stopAndRestartToFlow(flow: Flow, flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit) { - val baseFlowBuilder = this.baseTransitionBuilder.stopAndRestart(flow) - .from(flow) + fun stopAndRestartToFlow( + flow: Flow, + flowTransitionInit: FlowTransitionBuilderDsl.() -> Unit, + ) { + val baseFlowBuilder = + this.baseTransitionBuilder + .stopAndRestart(flow) + .from(flow) - this.flowBuilder = FlowTransitionBuilderDsl(this.dslContext, flow, baseFlowBuilder) - .apply(flowTransitionInit) - .build() + this.flowBuilder = + FlowTransitionBuilderDsl(this.dslContext, flow, baseFlowBuilder) + .apply(flowTransitionInit) + .build() } /** @@ -271,9 +316,10 @@ class TransitionBuilderDsl internal constructor( deciderTransitionInit: DeciderTransitionBuilderDsl.() -> Unit, ) { val baseFlowBuilder = this.baseTransitionBuilder.stopAndRestart(decider).from(decider) - this.flowBuilder = DeciderTransitionBuilderDsl(this.dslContext, decider, baseFlowBuilder) - .apply(deciderTransitionInit) - .build() + this.flowBuilder = + DeciderTransitionBuilderDsl(this.dslContext, decider, baseFlowBuilder) + .apply(deciderTransitionInit) + .build() } /** @@ -287,7 +333,10 @@ class TransitionBuilderDsl internal constructor( /** * Transition to stop and restart with step if the flow is restarted. */ - fun stopAndRestartToStep(name: String, stepInit: StepBuilderDsl.() -> Step) { + fun stopAndRestartToStep( + name: String, + stepInit: StepBuilderDsl.() -> Step, + ) { val stepBuilder = StepBuilder(name, this.dslContext.jobRepository) val step = StepBuilderDsl(this.dslContext, stepBuilder).let(stepInit) stopAndRestartToStep(step) @@ -327,13 +376,19 @@ class TransitionBuilderDsl internal constructor( /** * Transition to stop and restart with step if the flow is restarted. */ - fun stopAndRestartToStep(step: Step, stepTransitionInit: StepTransitionBuilderDsl.() -> Unit) { - val baseFlowBuilder = this.baseTransitionBuilder.stopAndRestart(step) - .from(step) + fun stopAndRestartToStep( + step: Step, + stepTransitionInit: StepTransitionBuilderDsl.() -> Unit, + ) { + val baseFlowBuilder = + this.baseTransitionBuilder + .stopAndRestart(step) + .from(step) - this.flowBuilder = StepTransitionBuilderDsl(this.dslContext, step, baseFlowBuilder) - .apply(stepTransitionInit) - .build() + this.flowBuilder = + StepTransitionBuilderDsl(this.dslContext, step, baseFlowBuilder) + .apply(stepTransitionInit) + .build() } /** @@ -357,9 +412,8 @@ class TransitionBuilderDsl internal constructor( this.flowBuilder = this.baseTransitionBuilder.fail() } - internal fun build(): FlowBuilder { - return checkNotNull(this.flowBuilder) { + internal fun build(): FlowBuilder = + checkNotNull(this.flowBuilder) { "should set transition." } - } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt index d674a2e..1d7b287 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDsl.kt @@ -37,8 +37,8 @@ class FlowStepBuilderDsl internal constructor( ) { private val lazyConfigurer = LazyConfigurer() - internal fun build(): Step { - return this.flowStepBuilder.apply(this.lazyConfigurer) + internal fun build(): Step = + this.flowStepBuilder + .apply(this.lazyConfigurer) .build() - } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt index 570864e..c261514 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt @@ -21,8 +21,8 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.step.Step import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor @@ -57,8 +57,8 @@ class JobStepBuilderDsl internal constructor( } } - internal fun build(): Step { - return this.jobStepBuilder.apply(this.lazyConfigurer) + internal fun build(): Step = + this.jobStepBuilder + .apply(this.lazyConfigurer) .build() - } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt index edab0ff..b516f6a 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt @@ -22,11 +22,11 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMark import com.navercorp.spring.batch.plus.kotlin.configuration.support.Configurer import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.step.Step import org.springframework.batch.core.partition.PartitionHandler -import org.springframework.batch.core.partition.StepExecutionSplitter import org.springframework.batch.core.partition.Partitioner import org.springframework.batch.core.partition.StepExecutionAggregator +import org.springframework.batch.core.partition.StepExecutionSplitter +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.core.task.TaskExecutor @@ -60,9 +60,10 @@ class PartitionStepBuilderDsl internal constructor( * for [PartitionHandler][org.springframework.batch.core.partition.PartitionHandler]. */ fun partitionHandler(init: TaskExecutorPartitionHandlerBuilderDsl.() -> Unit) { - val taskExecutorPartitionHandlerConfigurers = TaskExecutorPartitionHandlerBuilderDsl(this.dslContext) - .apply(init) - .build() + val taskExecutorPartitionHandlerConfigurers = + TaskExecutorPartitionHandlerBuilderDsl(this.dslContext) + .apply(init) + .build() this.lazyConfigurer.add(taskExecutorPartitionHandlerConfigurers) this.partitionHandlerSet = true } @@ -83,7 +84,10 @@ class PartitionStepBuilderDsl internal constructor( * * @see [PartitionStepBuilder.partitioner][org.springframework.batch.core.step.builder.PartitionStepBuilder.partitioner] */ - fun splitter(stepName: String, partitioner: Partitioner) { + fun splitter( + stepName: String, + partitioner: Partitioner, + ) { this.lazyConfigurer.add { it.partitioner(stepName, partitioner) } @@ -108,7 +112,8 @@ class PartitionStepBuilderDsl internal constructor( "splitter is not set." } - return this.partitionStepBuilder.apply(this.lazyConfigurer) + return this.partitionStepBuilder + .apply(this.lazyConfigurer) .build() } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt index 327d8a5..e6d8acb 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt @@ -70,9 +70,10 @@ class SimpleStepBuilderDsl internal constructor( * @see [FaultTolerantStepBuilder][org.springframework.batch.core.step.builder.FaultTolerantStepBuilder]. */ fun faultTolerant(init: FaultTolerantStepBuilderDsl.() -> Unit) { - this.faultTolerantStepConfigurer = FaultTolerantStepBuilderDsl(this.dslContext) - .apply(init) - .build() + this.faultTolerantStepConfigurer = + FaultTolerantStepBuilderDsl(this.dslContext) + .apply(init) + .build() } /** @@ -263,12 +264,14 @@ class SimpleStepBuilderDsl internal constructor( val faultTolerantStepConfigurer = this.faultTolerantStepConfigurer val simpleStepConfigurer = this.simpleStepConfigurer return if (faultTolerantStepConfigurer != null) { - this.simpleStepBuilder.faultTolerant() + this.simpleStepBuilder + .faultTolerant() .apply(faultTolerantStepConfigurer) .apply(simpleStepConfigurer) .build() } else { - this.simpleStepBuilder.apply(simpleStepConfigurer) + this.simpleStepBuilder + .apply(simpleStepConfigurer) .build() } } @@ -457,8 +460,6 @@ class SimpleStepBuilderDsl internal constructor( } } - internal fun build(): Configurer> { - return this.lazyConfigurer - } + internal fun build(): Configurer> = this.lazyConfigurer } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt index c014f30..a33ef68 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt @@ -132,7 +132,8 @@ class TaskletStepBuilderDsl internal constructor( } } - return this.taskletStepBuilder.apply(this.lazyConfigurer) + return this.taskletStepBuilder + .apply(this.lazyConfigurer) .build() } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt index 3333d83..024d508 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegates.kt @@ -35,8 +35,7 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter message = "Uses ItemStreamFluxReaderDelegate instead", replaceWith = ReplaceWith(""), ) -fun ItemStreamReaderDelegate.asItemStreamReader(): ItemStreamReader = - AdapterFactory.itemStreamReader(this) +fun ItemStreamReaderDelegate.asItemStreamReader(): ItemStreamReader = AdapterFactory.itemStreamReader(this) /** * An extensions to invoke [AdapterFactory.itemProcessor]. @@ -45,18 +44,17 @@ fun ItemStreamReaderDelegate.asItemStreamReader(): ItemStreamReader message = "Uses com.navercorp.spring.batch.plus.step.adapter.ItemProcessorDelegate instead", replaceWith = ReplaceWith(""), ) -fun ItemProcessorDelegate.asItemProcessor(): ItemProcessor = - AdapterFactory.itemProcessor(this) +fun ItemProcessorDelegate.asItemProcessor(): ItemProcessor = AdapterFactory.itemProcessor(this) /** * An extensions to invoke [AdapterFactory.itemStreamWriter]. */ @Deprecated( message = "Uses com.navercorp.spring.batch.plus.step.adapter.ItemStreamWriterDelegate instead", - replaceWith = ReplaceWith( - "AdapterFactory.itemStreamWriter(this)", - "com.navercorp.spring.batch.plus.step.adapter.AdapterFactory", - ), + replaceWith = + ReplaceWith( + "AdapterFactory.itemStreamWriter(this)", + "com.navercorp.spring.batch.plus.step.adapter.AdapterFactory", + ), ) -fun ItemStreamWriterDelegate.asItemStreamWriter(): ItemStreamWriter = - AdapterFactory.itemStreamWriter(this) +fun ItemStreamWriterDelegate.asItemStreamWriter(): ItemStreamWriter = AdapterFactory.itemStreamWriter(this) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt index 90ecf61..9f6da80 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegates.kt @@ -32,35 +32,29 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter /** * An extensions to invoke [AdapterFactory.itemStreamReader]. */ -fun ItemStreamFluxReaderDelegate.asItemStreamReader(): ItemStreamReader = - AdapterFactory.itemStreamReader(this) +fun ItemStreamFluxReaderDelegate.asItemStreamReader(): ItemStreamReader = AdapterFactory.itemStreamReader(this) /** * An extensions to invoke [AdapterFactory.itemStreamReader]. */ -fun ItemStreamIterableReaderDelegate.asItemStreamReader(): ItemStreamReader = - AdapterFactory.itemStreamReader(this) +fun ItemStreamIterableReaderDelegate.asItemStreamReader(): ItemStreamReader = AdapterFactory.itemStreamReader(this) /** * An extensions to invoke [AdapterFactory.itemStreamReader]. */ -fun ItemStreamIteratorReaderDelegate.asItemStreamReader(): ItemStreamReader = - AdapterFactory.itemStreamReader(this) +fun ItemStreamIteratorReaderDelegate.asItemStreamReader(): ItemStreamReader = AdapterFactory.itemStreamReader(this) /** * An extensions to invoke [AdapterFactory.itemStreamReader]. */ -fun ItemStreamSimpleReaderDelegate.asItemStreamReader(): ItemStreamReader = - AdapterFactory.itemStreamReader(this) +fun ItemStreamSimpleReaderDelegate.asItemStreamReader(): ItemStreamReader = AdapterFactory.itemStreamReader(this) /** * An extensions to invoke [AdapterFactory.itemProcessor]. */ -fun ItemProcessorDelegate.asItemProcessor(): ItemProcessor = - AdapterFactory.itemProcessor(this) +fun ItemProcessorDelegate.asItemProcessor(): ItemProcessor = AdapterFactory.itemProcessor(this) /** * An extensions to invoke [AdapterFactory.itemStreamWriter]. */ -fun ItemStreamWriterDelegate.asItemStreamWriter(): ItemStreamWriter = - AdapterFactory.itemStreamWriter(this) +fun ItemStreamWriterDelegate.asItemStreamWriter(): ItemStreamWriter = AdapterFactory.itemStreamWriter(this) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt index 46c7967..c83b60c 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt @@ -25,10 +25,10 @@ import io.mockk.mockk import io.mockk.spyk import io.mockk.verify import org.junit.jupiter.api.Test -import org.springframework.batch.core.listener.JobExecutionListener +import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.parameters.JobParametersIncrementer import org.springframework.batch.core.job.parameters.JobParametersValidator -import org.springframework.batch.core.job.builder.JobBuilder +import org.springframework.batch.core.listener.JobExecutionListener import org.springframework.batch.core.observability.BatchJobObservationConvention import org.springframework.batch.core.repository.JobRepository import java.util.UUID @@ -37,7 +37,6 @@ import java.util.UUID * org.springframework.batch.core.job.builder.JobBuilderHelper related tests */ internal class JobBuilderDslHelperTest { - @Test fun testValidator() { // given @@ -46,9 +45,10 @@ internal class JobBuilderDslHelperTest { // when val jobParametersValidator = mockk() - jobBuilderDsl.apply { - validator(jobParametersValidator) - }.build() + jobBuilderDsl + .apply { + validator(jobParametersValidator) + }.build() // then verify(exactly = 1) { jobBuilder.validator(jobParametersValidator) } @@ -62,9 +62,10 @@ internal class JobBuilderDslHelperTest { // when val jobParametersIncrementer = mockk() - jobBuilderDsl.apply { - incrementer(jobParametersIncrementer) - }.build() + jobBuilderDsl + .apply { + incrementer(jobParametersIncrementer) + }.build() // then verify(exactly = 1) { jobBuilder.incrementer(jobParametersIncrementer) } @@ -78,9 +79,10 @@ internal class JobBuilderDslHelperTest { // when val observationConvention = mockk() - jobBuilderDsl.apply { - observationConvention(observationConvention) - }.build() + jobBuilderDsl + .apply { + observationConvention(observationConvention) + }.build() // then verify(exactly = 1) { jobBuilder.observationConvention(observationConvention) } @@ -94,9 +96,10 @@ internal class JobBuilderDslHelperTest { // when val observationRegistry = mockk() - jobBuilderDsl.apply { - observationRegistry(observationRegistry) - }.build() + jobBuilderDsl + .apply { + observationRegistry(observationRegistry) + }.build() // then verify(exactly = 1) { jobBuilder.observationRegistry(observationRegistry) } @@ -110,9 +113,10 @@ internal class JobBuilderDslHelperTest { // when val meterRegistry = mockk() - jobBuilderDsl.apply { - meterRegistry(meterRegistry) - }.build() + jobBuilderDsl + .apply { + meterRegistry(meterRegistry) + }.build() // then verify(exactly = 1) { jobBuilder.meterRegistry(meterRegistry) } @@ -127,9 +131,10 @@ internal class JobBuilderDslHelperTest { // when val jobRepository = mockk() - jobBuilderDsl.apply { - repository(jobRepository) - }.build() + jobBuilderDsl + .apply { + repository(jobRepository) + }.build() // then verify(exactly = 1) { jobBuilder.repository(jobRepository) } @@ -145,9 +150,10 @@ internal class JobBuilderDslHelperTest { // when val testListener = TestListener() - jobBuilderDsl.apply { - listener(testListener) - }.build() + jobBuilderDsl + .apply { + listener(testListener) + }.build() // then verify(exactly = 1) { jobBuilder.listener(testListener) } @@ -161,9 +167,10 @@ internal class JobBuilderDslHelperTest { // when val jobExecutionListener = mockk() - jobBuilderDsl.apply { - listener(jobExecutionListener) - }.build() + jobBuilderDsl + .apply { + listener(jobExecutionListener) + }.build() // then verify(exactly = 1) { jobBuilder.listener(jobExecutionListener) } @@ -176,9 +183,10 @@ internal class JobBuilderDslHelperTest { val jobBuilderDsl = jobBuilderDsl(jobBuilder) // when - jobBuilderDsl.apply { - preventRestart() - }.build() + jobBuilderDsl + .apply { + preventRestart() + }.build() // then verify(exactly = 1) { jobBuilder.preventRestart() } @@ -192,20 +200,22 @@ internal class JobBuilderDslHelperTest { // when val jobParametersValidator = mockk() - jobBuilderDsl.apply { - step(mockk()) - validator(jobParametersValidator) - }.build() + jobBuilderDsl + .apply { + step(mockk()) + validator(jobParametersValidator) + }.build() // then verify(exactly = 1) { jobBuilder.validator(jobParametersValidator) } } private fun jobBuilderDsl(jobBuilder: JobBuilder): JobBuilderDsl { - val dslContext = DslContext( - beanFactory = mockk(), - jobRepository = mockk(), - ) + val dslContext = + DslContext( + beanFactory = mockk(), + jobRepository = mockk(), + ) return JobBuilderDsl(dslContext, jobBuilder) } diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt index 6aafd68..4bed7b2 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt @@ -22,13 +22,12 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import io.mockk.mockk import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test -import org.springframework.batch.core.step.Step import org.springframework.batch.core.job.flow.Flow +import org.springframework.batch.core.step.Step import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager internal class SimpleJobBuilderDslAdapterTest { - @Test fun testUnsupportedCall() { // given diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt index 9e24ceb..b5fff16 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt @@ -35,7 +35,6 @@ import java.util.concurrent.ThreadLocalRandom * org.springframework.batch.core.step.builder.StepBuilderHelper related tests */ internal class StepBuilderDslHelperTest { - @Suppress("DEPRECATION") @Test fun testRepository() { @@ -45,9 +44,10 @@ internal class StepBuilderDslHelperTest { // when val jobRepository = mockk() - stepBuilderDsl.apply { - repository(jobRepository) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + repository(jobRepository) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.repository(jobRepository) } @@ -61,9 +61,10 @@ internal class StepBuilderDslHelperTest { // when val observationConvention = mockk() - stepBuilderDsl.apply { - observationConvention(observationConvention) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + observationConvention(observationConvention) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.observationConvention(observationConvention) } @@ -77,9 +78,10 @@ internal class StepBuilderDslHelperTest { // when val observationRegistry = mockk() - stepBuilderDsl.apply { - observationRegistry(observationRegistry) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + observationRegistry(observationRegistry) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.observationRegistry(observationRegistry) } @@ -93,9 +95,10 @@ internal class StepBuilderDslHelperTest { // when val meterRegistry = mockk() - stepBuilderDsl.apply { - meterRegistry(meterRegistry) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + meterRegistry(meterRegistry) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.meterRegistry(meterRegistry) } @@ -109,9 +112,10 @@ internal class StepBuilderDslHelperTest { // when val startLimit = ThreadLocalRandom.current().nextInt() - stepBuilderDsl.apply { - startLimit(startLimit) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + startLimit(startLimit) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.startLimit(startLimit) } @@ -127,9 +131,10 @@ internal class StepBuilderDslHelperTest { // when val testListener = TestListener() - stepBuilderDsl.apply { - listener(testListener) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + listener(testListener) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.listener(testListener) } @@ -143,9 +148,10 @@ internal class StepBuilderDslHelperTest { // when val stepExecutionListener = mockk() - stepBuilderDsl.apply { - listener(stepExecutionListener) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + listener(stepExecutionListener) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.listener(stepExecutionListener) } @@ -159,19 +165,21 @@ internal class StepBuilderDslHelperTest { // when val allowStartIfComplete = ThreadLocalRandom.current().nextBoolean() - stepBuilderDsl.apply { - allowStartIfComplete(allowStartIfComplete) - }.tasklet(mockk(), mockk()) + stepBuilderDsl + .apply { + allowStartIfComplete(allowStartIfComplete) + }.tasklet(mockk(), mockk()) // then verify(exactly = 1) { stepBuilderDsl.allowStartIfComplete(allowStartIfComplete) } } private fun stepBuilderDsl(stepBuilder: StepBuilder): StepBuilderDsl { - val dslContext = DslContext( - beanFactory = mockk(), - jobRepository = mockk(), - ) + val dslContext = + DslContext( + beanFactory = mockk(), + jobRepository = mockk(), + ) return StepBuilderDsl(dslContext, stepBuilder) } diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt index b2f469d..4b15202 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt @@ -24,15 +24,15 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.annotation.OnSkipInRead import org.springframework.batch.core.job.JobExecution import org.springframework.batch.core.job.JobInstance import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.listener.SkipListener -import org.springframework.batch.core.step.Step -import org.springframework.batch.core.annotation.OnSkipInRead import org.springframework.batch.core.scope.context.ChunkContext import org.springframework.batch.core.step.FatalStepExecutionException +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy @@ -52,7 +52,6 @@ import org.springframework.transaction.interceptor.DefaultTransactionAttribute * Separated from SimpleStepBuilderDslTest since it's too big. */ internal class FaultTolerantStepBuilderDslTest { - private val jobInstance = JobInstance(0L, "testJob") private val jobParameters = JobParameters() @@ -68,41 +67,48 @@ internal class FaultTolerantStepBuilderDslTest { var onSkipInReadCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer {} + faultTolerant { + skipLimit(skipLimit) + skip() + listener( + object : SkipListener { + override fun onSkipInRead(t: Throwable) { + ++onSkipInReadCallCount + } + + override fun onSkipInProcess( + item: Number, + t: Throwable, + ) { + // no need to test. we are just testing if listener is invoked + } + + override fun onSkipInWrite( + item: Number, + t: Throwable, + ) { + // no need to test. we are just testing if listener is invoked + } + }, + ) } } - writer {} - faultTolerant { - skipLimit(skipLimit) - skip() - listener( - object : SkipListener { - override fun onSkipInRead(t: Throwable) { - ++onSkipInReadCallCount - } - - override fun onSkipInProcess(item: Number, t: Throwable) { - // no need to test. we are just testing if listener is invoked - } - - override fun onSkipInWrite(item: Number, t: Throwable) { - // no need to test. we are just testing if listener is invoked - } - }, - ) - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -124,50 +130,51 @@ internal class FaultTolerantStepBuilderDslTest { var retryOpenCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + retry() + listener( + object : RetryListener { + override fun open( + context: RetryContext?, + callback: RetryCallback?, + ): Boolean { + ++retryOpenCallCount + return true + } + + override fun close( + context: RetryContext?, + callback: RetryCallback?, + throwable: Throwable?, + ) { + // no need to test. we are just testing if listener is invoked + } + + override fun onError( + context: RetryContext?, + callback: RetryCallback?, + throwable: Throwable?, + ) { + // no need to test. we are just testing if listener is invoked + } + }, + ) } } - writer { - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - retry() - listener( - object : RetryListener { - override fun open( - context: RetryContext?, - callback: RetryCallback?, - ): Boolean { - ++retryOpenCallCount - return true - } - - override fun close( - context: RetryContext?, - callback: RetryCallback?, - throwable: Throwable?, - ) { - // no need to test. we are just testing if listener is invoked - } - - override fun onError( - context: RetryContext?, - callback: RetryCallback?, - throwable: Throwable?, - ) { - // no need to test. we are just testing if listener is invoked - } - }, - ) - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -188,27 +195,28 @@ internal class FaultTolerantStepBuilderDslTest { var keyGeneratorCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } } - } - writer { - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - retry() - keyGenerator { - ++keyGeneratorCallCount - "testkey" + writer { + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + retry() + keyGenerator { + ++keyGeneratorCallCount + "testkey" + } } } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -229,24 +237,25 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++tryCount + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + retry() } } - writer { - ++tryCount - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - retry() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -267,24 +276,25 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++tryCount + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + retry() } } - writer { - ++tryCount - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - retry() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -305,25 +315,26 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++tryCount + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + retry() + noRetry() } } - writer { - ++tryCount - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - retry() - noRetry() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -344,24 +355,25 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++tryCount + throw IllegalStateException("Error") + } + faultTolerant { + retryPolicy(SimpleRetryPolicy(retryLimit)) + retry() } } - writer { - ++tryCount - throw IllegalStateException("Error") - } - faultTolerant { - retryPolicy(SimpleRetryPolicy(retryLimit)) - retry() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -383,32 +395,33 @@ internal class FaultTolerantStepBuilderDslTest { var backoffPolicyCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++tryCount + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + backOffPolicy( + object : FixedBackOffPolicy() { + override fun doBackOff() { + ++backoffPolicyCallCount + super.doBackOff() + } + }, + ) + retry() } } - writer { - ++tryCount - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - backOffPolicy( - object : FixedBackOffPolicy() { - override fun doBackOff() { - ++backoffPolicyCallCount - super.doBackOff() - } - }, - ) - retry() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -431,32 +444,33 @@ internal class FaultTolerantStepBuilderDslTest { var retryContextCacheCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + ++tryCount + throw IllegalStateException("Error") + } + faultTolerant { + retryLimit(retryLimit) + retryContextCache( + object : MapRetryContextCache() { + override fun containsKey(key: Any?): Boolean { + ++retryContextCacheCallCount + return super.containsKey(key) + } + }, + ) + retry() } } - writer { - ++tryCount - throw IllegalStateException("Error") - } - faultTolerant { - retryLimit(retryLimit) - retryContextCache( - object : MapRetryContextCache() { - override fun containsKey(key: Any?): Boolean { - ++retryContextCacheCallCount - return super.containsKey(key) - } - }, - ) - retry() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -478,26 +492,27 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { } + faultTolerant { + skipLimit(skipLimit) + skip() } } - writer { } - faultTolerant { - skipLimit(skipLimit) - skip() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -518,26 +533,27 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { } + faultTolerant { + skipLimit(skipLimit) + skip() } } - writer { } - faultTolerant { - skipLimit(skipLimit) - skip() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -558,27 +574,28 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { } + faultTolerant { + skipLimit(skipLimit) + skip() + noSkip() } } - writer { } - faultTolerant { - skipLimit(skipLimit) - skip() - noSkip() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -599,30 +616,31 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { } + faultTolerant { + skipPolicy( + LimitCheckingItemSkipPolicy( + skipLimit, + mapOf(IllegalStateException::class.java to true), + ), + ) } } - writer { } - faultTolerant { - skipPolicy( - LimitCheckingItemSkipPolicy( - skipLimit, - mapOf(IllegalStateException::class.java to true), - ), - ) - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -641,23 +659,24 @@ internal class FaultTolerantStepBuilderDslTest { var readCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer { + // ignored when noRollback is set + throw IllegalStateException("Error") + } + faultTolerant { + noRollback() } } - writer { - // ignored when noRollback is set - throw IllegalStateException("Error") - } - faultTolerant { - noRollback() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -678,31 +697,32 @@ internal class FaultTolerantStepBuilderDslTest { var tryCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } } - } - processor { - ++processCallCount - it - } - writer { - if (tryCount < (retryLimit - 1)) { - ++tryCount - throw IllegalStateException("Error") + processor { + ++processCallCount + it + } + writer { + if (tryCount < (retryLimit - 1)) { + ++tryCount + throw IllegalStateException("Error") + } + } + faultTolerant { + retryLimit(retryLimit) + retry() + processorNonTransactional() } } - faultTolerant { - retryLimit(retryLimit) - retry() - processorNonTransactional() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -716,7 +736,6 @@ internal class FaultTolerantStepBuilderDslTest { @Nested inner class OverriddenMethodTest { - @Test fun testObjectSkipListenerNotInvokedWhenCalledBeforeFaultTolerant() { // given @@ -739,28 +758,28 @@ internal class FaultTolerantStepBuilderDslTest { } // when - val step = simpleStepBuilder - .chunk(chunkSize) - .transactionManager(ResourcelessTransactionManager()) - .listener(TestListener()) // called before faultTolerant() - .reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilder + .chunk(chunkSize) + .transactionManager(ResourcelessTransactionManager()) + .listener(TestListener()) // called before faultTolerant() + .reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - .writer {} - .faultTolerant() - .skipLimit(skipLimit) - .skip(IllegalStateException::class.java) - .build() + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + }.writer {} + .faultTolerant() + .skipLimit(skipLimit) + .skip(IllegalStateException::class.java) + .build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -794,28 +813,28 @@ internal class FaultTolerantStepBuilderDslTest { } // when - val step = simpleStepBuilder - .chunk(chunkSize) - .transactionManager(ResourcelessTransactionManager()) - .reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilder + .chunk(chunkSize) + .transactionManager(ResourcelessTransactionManager()) + .reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - .writer {} - .faultTolerant() - .skipLimit(skipLimit) - .skip(IllegalStateException::class.java) - .listener(TestListener()) // called after faultTolerant() - .build() + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + }.writer {} + .faultTolerant() + .skipLimit(skipLimit) + .skip(IllegalStateException::class.java) + .listener(TestListener()) // called after faultTolerant() + .build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -846,27 +865,28 @@ internal class FaultTolerantStepBuilderDslTest { } // when - val step = simpleStepBuilderDsl(chunkSize) { - listener(TestListener()) // called before faultTolerant - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + listener(TestListener()) // called before faultTolerant + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + } + writer {} + faultTolerant { + skipLimit(skipLimit) + skip(IllegalStateException::class) } } - writer {} - faultTolerant { - skipLimit(skipLimit) - skip(IllegalStateException::class) - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -897,27 +917,28 @@ internal class FaultTolerantStepBuilderDslTest { } // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (tryCount < skipLimit) { - ++tryCount - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (tryCount < skipLimit) { + ++tryCount + throw IllegalStateException("Error") + } - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } } + writer {} + faultTolerant { + skipLimit(skipLimit) + skip(IllegalStateException::class) + } + listener(TestListener()) // called before faultTolerant } - writer {} - faultTolerant { - skipLimit(skipLimit) - skip(IllegalStateException::class) - } - listener(TestListener()) // called before faultTolerant - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -936,28 +957,26 @@ internal class FaultTolerantStepBuilderDslTest { val simpleStepBuilder = SimpleStepBuilder(stepBuilder) // when - val step = simpleStepBuilder - .chunk(3) - .transactionManager(ResourcelessTransactionManager()) - .reader { null } - .faultTolerant() - .retryLimit(3) - .retry(RuntimeException::class.java) - .writer {} - .listener( - object : ChunkListener { - override fun beforeChunk(context: ChunkContext) { - throw IllegalStateException("Error") - } - - override fun afterChunk(context: ChunkContext) { - } - - override fun afterChunkError(context: ChunkContext) { - } - }, - ) - .build() + val step = + simpleStepBuilder + .chunk(3) + .transactionManager(ResourcelessTransactionManager()) + .reader { null } + .faultTolerant() + .retryLimit(3) + .retry(RuntimeException::class.java) + .writer {} + .listener( + object : ChunkListener { + override fun beforeChunk(context: ChunkContext): Unit = throw IllegalStateException("Error") + + override fun afterChunk(context: ChunkContext) { + } + + override fun afterChunkError(context: ChunkContext) { + } + }, + ).build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -972,27 +991,26 @@ internal class FaultTolerantStepBuilderDslTest { @Test fun testDelegateListenerIsInvokedOnDslWhenCalledBeforeFaultTolerant() { // when - val step = simpleStepBuilderDsl(3) { - reader { null } - writer {} - listener( - object : ChunkListener { - override fun beforeChunk(context: ChunkContext) { - throw IllegalStateException("Error") - } - - override fun afterChunk(context: ChunkContext) { - } - - override fun afterChunkError(context: ChunkContext) { - } - }, - ) - faultTolerant { - retryLimit(3) - retry() + val step = + simpleStepBuilderDsl(3) { + reader { null } + writer {} + listener( + object : ChunkListener { + override fun beforeChunk(context: ChunkContext): Unit = throw IllegalStateException("Error") + + override fun afterChunk(context: ChunkContext) { + } + + override fun afterChunkError(context: ChunkContext) { + } + }, + ) + faultTolerant { + retryLimit(3) + retry() + } } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1007,27 +1025,26 @@ internal class FaultTolerantStepBuilderDslTest { @Test fun testDelegateListenerIsInvokedOnDslWhenCalledAfterFaultTolerant() { // when - val step = simpleStepBuilderDsl(3) { - reader { null } - writer {} - faultTolerant { - retryLimit(3) - retry() - } - listener( - object : ChunkListener { - override fun beforeChunk(context: ChunkContext) { - throw IllegalStateException("Error") - } + val step = + simpleStepBuilderDsl(3) { + reader { null } + writer {} + faultTolerant { + retryLimit(3) + retry() + } + listener( + object : ChunkListener { + override fun beforeChunk(context: ChunkContext): Unit = throw IllegalStateException("Error") - override fun afterChunk(context: ChunkContext) { - } + override fun afterChunk(context: ChunkContext) { + } - override fun afterChunkError(context: ChunkContext) { - } - }, - ) - } + override fun afterChunkError(context: ChunkContext) { + } + }, + ) + } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1051,34 +1068,32 @@ internal class FaultTolerantStepBuilderDslTest { val simpleStepBuilder = SimpleStepBuilder(stepBuilder) // when - val step = simpleStepBuilder - .chunk(chunkSize) - .transactionManager(ResourcelessTransactionManager()) - .reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - .writer { - throw IllegalStateException("Error") - } - .faultTolerant() // use faultTolerant - .noRollback(IllegalStateException::class.java) // wrapped by making it as noRollback - .transactionAttribute( - object : DefaultTransactionAttribute() { - override fun rollbackOn(ex: Throwable): Boolean { - // make it always rollback (batch exit with failed) - // but with faultTolerant, class defined in noRollback is considered - // noRollback in transaction by wrapping transactionAttribute - ++noRollbackCallCount - return ex is IllegalStateException + val step = + simpleStepBuilder + .chunk(chunkSize) + .transactionManager(ResourcelessTransactionManager()) + .reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null } - }, - ) - .build() + }.writer { + throw IllegalStateException("Error") + }.faultTolerant() // use faultTolerant + .noRollback(IllegalStateException::class.java) // wrapped by making it as noRollback + .transactionAttribute( + object : DefaultTransactionAttribute() { + override fun rollbackOn(ex: Throwable): Boolean { + // make it always rollback (batch exit with failed) + // but with faultTolerant, class defined in noRollback is considered + // noRollback in transaction by wrapping transactionAttribute + ++noRollbackCallCount + return ex is IllegalStateException + } + }, + ).build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1098,30 +1113,31 @@ internal class FaultTolerantStepBuilderDslTest { var noRollbackCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - transactionAttribute( - object : DefaultTransactionAttribute() { - override fun rollbackOn(ex: Throwable): Boolean { - ++noRollbackCallCount - return ex is IllegalStateException + val step = + simpleStepBuilderDsl(chunkSize) { + transactionAttribute( + object : DefaultTransactionAttribute() { + override fun rollbackOn(ex: Throwable): Boolean { + ++noRollbackCallCount + return ex is IllegalStateException + } + }, + ) + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null } - }, - ) - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + } + writer { + throw IllegalStateException("Error") + } + faultTolerant { + noRollback() } } - writer { - throw IllegalStateException("Error") - } - faultTolerant { - noRollback() - } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1141,30 +1157,31 @@ internal class FaultTolerantStepBuilderDslTest { var noRollbackCallCount = 0 // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } } + writer { + throw IllegalStateException("Error") + } + faultTolerant { + noRollback() + } + transactionAttribute( + object : DefaultTransactionAttribute() { + override fun rollbackOn(ex: Throwable): Boolean { + ++noRollbackCallCount + return ex is IllegalStateException + } + }, + ) } - writer { - throw IllegalStateException("Error") - } - faultTolerant { - noRollback() - } - transactionAttribute( - object : DefaultTransactionAttribute() { - override fun rollbackOn(ex: Throwable): Boolean { - ++noRollbackCallCount - return ex is IllegalStateException - } - }, - ) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1186,10 +1203,13 @@ internal class FaultTolerantStepBuilderDslTest { val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) val simpleStepBuilder = SimpleStepBuilder(stepBuilder) - class TestStream : ItemStream, ItemReader { + class TestStream : + ItemStream, + ItemReader { override fun open(executionContext: ExecutionContext) { ++streamOpenCallCount - Throwable().stackTrace + Throwable() + .stackTrace .filter { it.className.endsWith("ChunkMonitor") } .also { assertThat(it).isNotEmpty @@ -1202,27 +1222,25 @@ internal class FaultTolerantStepBuilderDslTest { override fun close() { } - override fun read(): Int? { - return null - } + override fun read(): Int? = null } // when - val step = simpleStepBuilder - .chunk(chunkSize) - .transactionManager(ResourcelessTransactionManager()) - .reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - .writer {} - .faultTolerant() - .stream(TestStream()) - .build() + val step = + simpleStepBuilder + .chunk(chunkSize) + .transactionManager(ResourcelessTransactionManager()) + .reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + }.writer {} + .faultTolerant() + .stream(TestStream()) + .build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1241,11 +1259,14 @@ internal class FaultTolerantStepBuilderDslTest { var streamOpenCallCount = 0 var readCallCount = 0 - class TestStream : ItemStream, ItemReader { + class TestStream : + ItemStream, + ItemReader { override fun open(executionContext: ExecutionContext) { ++streamOpenCallCount Throwable().printStackTrace() - Throwable().stackTrace + Throwable() + .stackTrace .filter { it.className.endsWith("ChunkMonitor") } .also { assertThat(it).isNotEmpty @@ -1258,25 +1279,24 @@ internal class FaultTolerantStepBuilderDslTest { override fun close() { } - override fun read(): Int? { - return null - } + override fun read(): Int? = null } // when - val step = simpleStepBuilderDsl(chunkSize) { - stream(TestStream()) - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + stream(TestStream()) + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } } + writer {} + faultTolerant {} } - writer {} - faultTolerant {} - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1295,10 +1315,13 @@ internal class FaultTolerantStepBuilderDslTest { var streamOpenCallCount = 0 var readCallCount = 0 - class TestStream : ItemStream, ItemReader { + class TestStream : + ItemStream, + ItemReader { override fun open(executionContext: ExecutionContext) { ++streamOpenCallCount - Throwable().stackTrace + Throwable() + .stackTrace .filter { it.className.endsWith("ChunkMonitor") } .also { assertThat(it).isNotEmpty @@ -1311,26 +1334,25 @@ internal class FaultTolerantStepBuilderDslTest { override fun close() { } - override fun read(): Int? { - return null - } + override fun read(): Int? = null } // when - val step = simpleStepBuilderDsl(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null + val step = + simpleStepBuilderDsl(chunkSize) { + reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } } + writer {} + faultTolerant { + } + stream(TestStream()) } - writer {} - faultTolerant { - } - stream(TestStream()) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -1346,10 +1368,11 @@ internal class FaultTolerantStepBuilderDslTest { chunkSize: Int, init: SimpleStepBuilderDsl.() -> Unit, ): Step { - val dslContext = DslContext( - beanFactory = mockk(), - jobRepository = mockk(), - ) + val dslContext = + DslContext( + beanFactory = mockk(), + jobRepository = mockk(), + ) val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) val simpleStepBuilder = stepBuilder.chunk(chunkSize, ResourcelessTransactionManager()) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt index 02a2b47..519e921 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt @@ -26,14 +26,14 @@ import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.FlowStepBuilder internal class FlowStepBuilderDslTest { - @Test fun testBuild() { // given val mockStep = mockk() - val flowStepBuilder = mockk(relaxed = true) { - every { build() } returns mockStep - } + val flowStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep + } // when val actual = FlowStepBuilderDsl(mockk(), flowStepBuilder).build() diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt index cf2933c..4364030 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt @@ -23,13 +23,12 @@ import io.mockk.mockk import io.mockk.verify import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.springframework.batch.core.step.Step import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor internal class JobStepBuilderDslTest { - @Test fun testLauncher() { // given @@ -37,9 +36,10 @@ internal class JobStepBuilderDslTest { // when val jobLauncher = mockk() - JobStepBuilderDsl(mockk(), jobStepBuilder).apply { - launcher(jobLauncher) - }.build() + JobStepBuilderDsl(mockk(), jobStepBuilder) + .apply { + launcher(jobLauncher) + }.build() // then verify(exactly = 1) { jobStepBuilder.launcher(jobLauncher) } @@ -52,9 +52,10 @@ internal class JobStepBuilderDslTest { // when val jobParametersExtractor = mockk() - JobStepBuilderDsl(mockk(), jobStepBuilder).apply { - parametersExtractor(jobParametersExtractor) - }.build() + JobStepBuilderDsl(mockk(), jobStepBuilder) + .apply { + parametersExtractor(jobParametersExtractor) + }.build() // then verify(exactly = 1) { jobStepBuilder.parametersExtractor(jobParametersExtractor) } @@ -64,9 +65,10 @@ internal class JobStepBuilderDslTest { fun testBuild() { // given val mockStep = mockk() - val jobStepBuilder = mockk(relaxed = true) { - every { build() } returns mockStep - } + val jobStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep + } // when val actual = JobStepBuilderDsl(mockk(), jobStepBuilder).build() diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt index 56e227f..52c852c 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt @@ -30,24 +30,22 @@ import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.job.JobExecution import org.springframework.batch.core.job.JobInstance import org.springframework.batch.core.job.parameters.JobParameters -import org.springframework.batch.core.step.Step -import org.springframework.batch.core.step.StepExecution import org.springframework.batch.core.partition.PartitionHandler import org.springframework.batch.core.partition.StepExecutionSplitter import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.Step +import org.springframework.batch.core.step.StepExecution import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.infrastructure.item.ExecutionContext internal class PartitionStepBuilderDslTest { - private val jobInstance = JobInstance(0L, "testJob") private val jobParameters = JobParameters() @Nested inner class PartitionHandlerTest { - @Test fun testPartitionHandlerAndDummySettings() { // given @@ -57,37 +55,28 @@ internal class PartitionStepBuilderDslTest { val partitionStepBuilder = PartitionStepBuilder(stepBuilder) // when - val step = partitionStepBuilder - .partitionHandler { _, _ -> - ++partitionHandlerCallCount - listOf() - } - // dummy - .step( - object : Step { - override fun getName(): String { - throw RuntimeException("Should not be called") - } + val step = + partitionStepBuilder + .partitionHandler { _, _ -> + ++partitionHandlerCallCount + listOf() + } + // dummy + .step( + object : Step { + override fun getName(): String = throw RuntimeException("Should not be called") - override fun isAllowStartIfComplete(): Boolean { - throw RuntimeException("Should not be called") - } + override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - override fun getStartLimit(): Int { - throw RuntimeException("Should not be called") - } + override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - override fun execute(stepExecution: StepExecution) { - throw RuntimeException("Should not be called") - } - }, - ) - .taskExecutor { task -> - ++taskExecutorCallCount - task.run() - } - .gridSize(3) - .build() + override fun execute(stepExecution: StepExecution): Unit = throw RuntimeException("Should not be called") + }, + ).taskExecutor { task -> + ++taskExecutorCallCount + task.run() + }.gridSize(3) + .build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -103,33 +92,38 @@ internal class PartitionStepBuilderDslTest { // given val gridSize = 4 var partitionHandlerCallCount = 0 - val splitter = object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } } - } // when - val step = partitionStepBuilderDsl { - partitionHandler { splitter, stepExecution -> - ++partitionHandlerCallCount - splitter.split(stepExecution, gridSize) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED + val step = + partitionStepBuilderDsl { + partitionHandler { splitter, stepExecution -> + ++partitionHandlerCallCount + splitter + .split(stepExecution, gridSize) + .map { + it.apply { + exitStatus = ExitStatus.COMPLETED + status = BatchStatus.COMPLETED + } } - } + } + splitter(splitter) } - splitter(splitter) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -152,53 +146,51 @@ internal class PartitionStepBuilderDslTest { var stepExecuteCallCount = 0 var taskExecutorCallCount = 0 val gridSize = 4 - val splitter = object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } } - } // when - val step = partitionStepBuilderDsl { - partitionHandler { - step( - object : Step { - override fun getName(): String { - throw RuntimeException("Should not be called") - } + val step = + partitionStepBuilderDsl { + partitionHandler { + step( + object : Step { + override fun getName(): String = throw RuntimeException("Should not be called") - override fun isAllowStartIfComplete(): Boolean { - throw RuntimeException("Should not be called") - } + override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - override fun getStartLimit(): Int { - throw RuntimeException("Should not be called") - } + override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - override fun execute(stepExecution: StepExecution) { - ++stepExecuteCallCount - stepExecution.apply { - status = BatchStatus.COMPLETED - exitStatus = ExitStatus.COMPLETED + override fun execute(stepExecution: StepExecution) { + ++stepExecuteCallCount + stepExecution.apply { + status = BatchStatus.COMPLETED + exitStatus = ExitStatus.COMPLETED + } } - } - }, - ) - taskExecutor { task -> - ++taskExecutorCallCount - task.run() + }, + ) + taskExecutor { task -> + ++taskExecutorCallCount + task.run() + } + gridSize(gridSize) } - gridSize(gridSize) + splitter(splitter) } - splitter(splitter) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -221,49 +213,47 @@ internal class PartitionStepBuilderDslTest { // given var stepExecuteCallCount = 0 val gridSize = 4 - val splitter = object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } } - } // when - val step = partitionStepBuilderDsl { - partitionHandler { - step( - object : Step { - override fun getName(): String { - throw RuntimeException("Should not be called") - } + val step = + partitionStepBuilderDsl { + partitionHandler { + step( + object : Step { + override fun getName(): String = throw RuntimeException("Should not be called") - override fun isAllowStartIfComplete(): Boolean { - throw RuntimeException("Should not be called") - } + override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - override fun getStartLimit(): Int { - throw RuntimeException("Should not be called") - } + override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - override fun execute(stepExecution: StepExecution) { - ++stepExecuteCallCount - stepExecution.apply { - status = BatchStatus.COMPLETED - exitStatus = ExitStatus.COMPLETED + override fun execute(stepExecution: StepExecution) { + ++stepExecuteCallCount + stepExecution.apply { + status = BatchStatus.COMPLETED + exitStatus = ExitStatus.COMPLETED + } } - } - }, - ) - gridSize(gridSize) + }, + ) + gridSize(gridSize) + } + splitter(splitter) } - splitter(splitter) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -285,54 +275,52 @@ internal class PartitionStepBuilderDslTest { // given var stepExecuteCallCount = 0 var taskExecutorCallCount = 0 - val splitter = object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } } - } // org.springframework.batch.core.step.builder.PartitionStepBuilder.DEFAULT_GRID_SIZE val defaultGridSize = 6 // when - val step = partitionStepBuilderDsl { - partitionHandler { - step( - object : Step { - override fun getName(): String { - throw RuntimeException("Should not be called") - } + val step = + partitionStepBuilderDsl { + partitionHandler { + step( + object : Step { + override fun getName(): String = throw RuntimeException("Should not be called") - override fun isAllowStartIfComplete(): Boolean { - throw RuntimeException("Should not be called") - } + override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - override fun getStartLimit(): Int { - throw RuntimeException("Should not be called") - } + override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - override fun execute(stepExecution: StepExecution) { - ++stepExecuteCallCount - stepExecution.apply { - status = BatchStatus.COMPLETED - exitStatus = ExitStatus.COMPLETED + override fun execute(stepExecution: StepExecution) { + ++stepExecuteCallCount + stepExecution.apply { + status = BatchStatus.COMPLETED + exitStatus = ExitStatus.COMPLETED + } } - } - }, - ) - taskExecutor { task -> - ++taskExecutorCallCount - task.run() + }, + ) + taskExecutor { task -> + ++taskExecutorCallCount + task.run() + } } + splitter(splitter) } - splitter(splitter) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -353,18 +341,21 @@ internal class PartitionStepBuilderDslTest { @Test fun testPartitionHandlerWithTaskExecutorPartitionHandlerWithoutStep() { // given - val splitter = object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } } - } // when, then assertThatThrownBy { @@ -383,18 +374,21 @@ internal class PartitionStepBuilderDslTest { @Test fun testWithoutPartitionHandler() { // given - val splitter = object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } } - } // when, then assertThatThrownBy { @@ -407,7 +401,6 @@ internal class PartitionStepBuilderDslTest { @Nested inner class SplitterTest { - @Test fun testSplitterAndDummySettings() { // given @@ -418,28 +411,28 @@ internal class PartitionStepBuilderDslTest { val partitionStepBuilder = PartitionStepBuilder(stepBuilder) // when - val step = partitionStepBuilder - .partitionHandler { stepSplitter, stepExecution -> - stepSplitter.split(stepExecution, 1) - } - .splitter( - object : StepExecutionSplitter { - override fun getStepName(): String { - return "testStep" - } - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - ++splitterCallCount - return setOf() - } - }, - ) - // dummy - .partitioner(dummyStepName) { - ++partitionerCallCount - mapOf() - } - .build() + val step = + partitionStepBuilder + .partitionHandler { stepSplitter, stepExecution -> + stepSplitter.split(stepExecution, 1) + }.splitter( + object : StepExecutionSplitter { + override fun getStepName(): String = "testStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + ++splitterCallCount + return setOf() + } + }, + ) + // dummy + .partitioner(dummyStepName) { + ++partitionerCallCount + mapOf() + }.build() val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -456,36 +449,40 @@ internal class PartitionStepBuilderDslTest { // given var splitterCallCount = 0 val gridSize = 4 - val partitionHandler = PartitionHandler { stepSplitter, stepExecution -> - stepSplitter.split(stepExecution, gridSize) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED + val partitionHandler = + PartitionHandler { stepSplitter, stepExecution -> + stepSplitter + .split(stepExecution, gridSize) + .map { + it.apply { + exitStatus = ExitStatus.COMPLETED + status = BatchStatus.COMPLETED + } } - } - } + } // when - val step = partitionStepBuilderDsl { - partitionHandler(partitionHandler) - splitter( - - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - ++splitterCallCount - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - jobExecution.createStepExecution("${stepName}$it") - } - .toSet() - } - }, - ) - } + val step = + partitionStepBuilderDsl { + partitionHandler(partitionHandler) + splitter( + object : StepExecutionSplitter { + override fun getStepName(): String = "splitStep" + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + ++splitterCallCount + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + jobExecution.createStepExecution("${stepName}$it") + }.toSet() + } + }, + ) + } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -507,26 +504,30 @@ internal class PartitionStepBuilderDslTest { // given var partitionerCallCount = 0 val gridSize = 4 - val partitionHandler = PartitionHandler { stepSplitter, stepExecution -> - stepSplitter.split(stepExecution, gridSize) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED + val partitionHandler = + PartitionHandler { stepSplitter, stepExecution -> + stepSplitter + .split(stepExecution, gridSize) + .map { + it.apply { + exitStatus = ExitStatus.COMPLETED + status = BatchStatus.COMPLETED + } } - } - } + } // when - val step = partitionStepBuilderDsl { - partitionHandler(partitionHandler) - splitter("splitStep") { gridSize -> - ++partitionerCallCount - (0 until gridSize).map { - "$it" to ExecutionContext() - }.toMap() + val step = + partitionStepBuilderDsl { + partitionHandler(partitionHandler) + splitter("splitStep") { gridSize -> + ++partitionerCallCount + (0 until gridSize) + .map { + "$it" to ExecutionContext() + }.toMap() + } } - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -546,15 +547,17 @@ internal class PartitionStepBuilderDslTest { @Test fun testWithoutSplitter() { // given - val partitionHandler = PartitionHandler { stepSplitter, stepExecution -> - stepSplitter.split(stepExecution, 2_000_000_000) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED + val partitionHandler = + PartitionHandler { stepSplitter, stepExecution -> + stepSplitter + .split(stepExecution, 2_000_000_000) + .map { + it.apply { + exitStatus = ExitStatus.COMPLETED + status = BatchStatus.COMPLETED + } } - } - } + } // when, then assertThatThrownBy { @@ -571,13 +574,14 @@ internal class PartitionStepBuilderDslTest { var aggregatorCallCount = 0 // when - val step = partitionStepBuilderDsl { - aggregator { _, _ -> - ++aggregatorCallCount + val step = + partitionStepBuilderDsl { + aggregator { _, _ -> + ++aggregatorCallCount + } + partitionHandler(mockk(relaxed = true)) + splitter(mockk()) } - partitionHandler(mockk(relaxed = true)) - splitter(mockk()) - } val jobExecution = JobExecution(jobInstance, jobParameters) val stepExecution = jobExecution.createStepExecution(step.name) step.execute(stepExecution) @@ -588,13 +592,15 @@ internal class PartitionStepBuilderDslTest { } private fun partitionStepBuilderDsl(init: PartitionStepBuilderDsl.() -> Unit): Step { - val dslContext = DslContext( - beanFactory = mockk(), - jobRepository = mockk(), - ) - val mockk = mockk(relaxed = true) { - every { getLastStepExecution(any(), any()) } returns null - } + val dslContext = + DslContext( + beanFactory = mockk(), + jobRepository = mockk(), + ) + val mockk = + mockk(relaxed = true) { + every { getLastStepExecution(any(), any()) } returns null + } val stepBuilder = StepBuilder("testStep", mockk) return PartitionStepBuilderDsl(dslContext, PartitionStepBuilder(stepBuilder)).apply(init).build() diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index fe6900a..d5d7115 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -26,13 +26,13 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.JobInstance +import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.listener.ItemProcessListener import org.springframework.batch.core.listener.ItemReadListener import org.springframework.batch.core.listener.ItemWriteListener -import org.springframework.batch.core.job.JobExecution -import org.springframework.batch.core.job.JobInstance -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep @@ -53,7 +53,6 @@ import java.util.UUID import java.util.concurrent.ThreadLocalRandom internal class SimpleStepBuilderDslTest { - @Test fun testReader() { // given @@ -61,9 +60,10 @@ internal class SimpleStepBuilderDslTest { // when val itemReader = mockk>() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - reader(itemReader) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + reader(itemReader) + }.build() // then verify(exactly = 1) { simpleStepBuilder.reader(itemReader) } @@ -76,9 +76,10 @@ internal class SimpleStepBuilderDslTest { // when val itemProcessor = mockk>() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - processor(itemProcessor) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + processor(itemProcessor) + }.build() // then verify(exactly = 1) { simpleStepBuilder.processor(itemProcessor) } @@ -91,9 +92,10 @@ internal class SimpleStepBuilderDslTest { // when val itemWriter = mockk>() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - writer(itemWriter) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + writer(itemWriter) + }.build() // then verify(exactly = 1) { simpleStepBuilder.writer(itemWriter) } @@ -105,9 +107,10 @@ internal class SimpleStepBuilderDslTest { val simpleStepBuilder = mockk>(relaxed = true) // when - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - readerIsTransactionalQueue() - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + readerIsTransactionalQueue() + }.build() // then verify(exactly = 1) { simpleStepBuilder.readerIsTransactionalQueue() } @@ -122,9 +125,10 @@ internal class SimpleStepBuilderDslTest { // when val testListener = TestListener() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - listener(testListener) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + listener(testListener) + }.build() // then verify(exactly = 1) { simpleStepBuilder.listener(testListener) } @@ -137,9 +141,10 @@ internal class SimpleStepBuilderDslTest { // when val itemReadListener = mockk>() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - listener(itemReadListener) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + listener(itemReadListener) + }.build() // then verify(exactly = 1) { simpleStepBuilder.listener(itemReadListener) } @@ -152,9 +157,10 @@ internal class SimpleStepBuilderDslTest { // when val itemWriteListener = mockk>() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - listener(itemWriteListener) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + listener(itemWriteListener) + }.build() // then verify(exactly = 1) { simpleStepBuilder.listener(itemWriteListener) } @@ -167,9 +173,10 @@ internal class SimpleStepBuilderDslTest { // when val itemProcessListener = mockk>() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - listener(itemProcessListener) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + listener(itemProcessListener) + }.build() // then verify(exactly = 1) { simpleStepBuilder.listener(itemProcessListener) } @@ -182,9 +189,10 @@ internal class SimpleStepBuilderDslTest { // when val chunkListener = mockk() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - listener(chunkListener) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + listener(chunkListener) + }.build() // then verify(exactly = 1) { simpleStepBuilder.listener(chunkListener) } @@ -197,9 +205,10 @@ internal class SimpleStepBuilderDslTest { // when val itemStream = mockk() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - stream(itemStream) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + stream(itemStream) + }.build() // then verify(exactly = 1) { simpleStepBuilder.stream(itemStream) } @@ -212,9 +221,10 @@ internal class SimpleStepBuilderDslTest { // when val taskExecutor = mockk() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - taskExecutor(taskExecutor) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + taskExecutor(taskExecutor) + }.build() // then verify(exactly = 1) { simpleStepBuilder.taskExecutor(taskExecutor) } @@ -229,10 +239,11 @@ internal class SimpleStepBuilderDslTest { // when val taskExecutor = mockk() val limit = ThreadLocalRandom.current().nextInt() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - taskExecutor(taskExecutor) - throttleLimit(limit) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + taskExecutor(taskExecutor) + throttleLimit(limit) + }.build() // then verify(exactly = 1) { simpleStepBuilder.throttleLimit(limit) } @@ -245,9 +256,10 @@ internal class SimpleStepBuilderDslTest { // when val exceptionHandler = mockk() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - exceptionHandler(exceptionHandler) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + exceptionHandler(exceptionHandler) + }.build() // then verify(exactly = 1) { simpleStepBuilder.exceptionHandler(exceptionHandler) } @@ -260,9 +272,10 @@ internal class SimpleStepBuilderDslTest { // when val repeatOperations = mockk() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - stepOperations(repeatOperations) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + stepOperations(repeatOperations) + }.build() // then verify(exactly = 1) { simpleStepBuilder.stepOperations(repeatOperations) } @@ -275,9 +288,10 @@ internal class SimpleStepBuilderDslTest { // when val transactionAttribute = mockk() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - transactionAttribute(transactionAttribute) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + transactionAttribute(transactionAttribute) + }.build() // then verify(exactly = 1) { simpleStepBuilder.transactionAttribute(transactionAttribute) } @@ -287,9 +301,10 @@ internal class SimpleStepBuilderDslTest { fun testBuild() { // given val mockStep = mockk() - val taskletStepBuilder = mockk>(relaxed = true) { - every { build() } returns mockStep - } + val taskletStepBuilder = + mockk>(relaxed = true) { + every { build() } returns mockStep + } // when val actual = SimpleStepBuilderDsl(mockk(), taskletStepBuilder).build() @@ -305,10 +320,11 @@ internal class SimpleStepBuilderDslTest { // when, then assertThatThrownBy { - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - stepOperations(RepeatTemplate()) - taskExecutor(SyncTaskExecutor()) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + stepOperations(RepeatTemplate()) + taskExecutor(SyncTaskExecutor()) + }.build() }.hasMessageContaining("taskExecutor is redundant") } @@ -319,12 +335,13 @@ internal class SimpleStepBuilderDslTest { // when, then assertThatThrownBy { - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - stepOperations(RepeatTemplate()) - exceptionHandler { _, e -> - throw e - } - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + stepOperations(RepeatTemplate()) + exceptionHandler { _, e -> + throw e + } + }.build() }.hasMessageContaining("exceptionHandler is redundant") } @@ -336,15 +353,15 @@ internal class SimpleStepBuilderDslTest { // when, then assertThatThrownBy { - SimpleStepBuilderDsl(mockk(), simpleStepBuilder).apply { - throttleLimit(3) - }.build() + SimpleStepBuilderDsl(mockk(), simpleStepBuilder) + .apply { + throttleLimit(3) + }.build() }.hasMessageContaining("throttleLimit is redundant") } @Nested inner class RedundancyCheck { - @Test fun testStepOperationsAndRedundantSettings() { // given @@ -357,35 +374,33 @@ internal class SimpleStepBuilderDslTest { val stepBuilder = StepBuilder(UUID.randomUUID().toString(), mockk(relaxed = true)) // when - val step = stepBuilder - .chunk(chunkSize, ResourcelessTransactionManager()) - .reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - .writer { } - .stepOperations( - object : RepeatTemplate() { - override fun iterate(callback: RepeatCallback): RepeatStatus { - ++stepOperationCallCount - return super.iterate(callback) + val step = + stepBuilder + .chunk(chunkSize, ResourcelessTransactionManager()) + .reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null } - }, - ) - // redundant - .taskExecutor { task -> - ++taskExecutorCallCount - task.run() - } - .exceptionHandler { _, e -> - ++exceptionHandlerCallCount - throw e - } - .build() + }.writer { } + .stepOperations( + object : RepeatTemplate() { + override fun iterate(callback: RepeatCallback): RepeatStatus { + ++stepOperationCallCount + return super.iterate(callback) + } + }, + ) + // redundant + .taskExecutor { task -> + ++taskExecutorCallCount + task.run() + }.exceptionHandler { _, e -> + ++exceptionHandlerCallCount + throw e + }.build() val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) val jobExecution = JobExecution(jobInstance, JobParameters()) val stepExecution = jobExecution.createStepExecution(step.name) @@ -411,25 +426,23 @@ internal class SimpleStepBuilderDslTest { val stepBuilder = StepBuilder(UUID.randomUUID().toString(), mockk(relaxed = true)) // when - val step = stepBuilder - .chunk(chunkSize, ResourcelessTransactionManager()) - .reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - .processor { - ++processCallCount - it - } - .writer { - ++writeCallCount - } - .throttleLimit(100) - .build() + val step = + stepBuilder + .chunk(chunkSize, ResourcelessTransactionManager()) + .reader { + if (readCallCount < readLimit) { + ++readCallCount + 1 + } else { + null + } + }.processor { + ++processCallCount + it + }.writer { + ++writeCallCount + }.throttleLimit(100) + .build() val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) val jobExecution = JobExecution(jobInstance, JobParameters()) val stepExecution = jobExecution.createStepExecution(step.name) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index ffd6fc4..ec2f83b 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -26,10 +26,10 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.job.JobExecution import org.springframework.batch.core.job.JobInstance import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.builder.TaskletStepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep @@ -46,7 +46,6 @@ import java.util.UUID import java.util.concurrent.ThreadLocalRandom internal class TaskletStepBuilderDslTest { - @Test fun testChunkListener() { // given @@ -54,9 +53,10 @@ internal class TaskletStepBuilderDslTest { // when val chunkListener = mockk() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - listener(chunkListener) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + listener(chunkListener) + }.build() // then verify(exactly = 1) { taskletStepBuilder.listener(chunkListener) } @@ -71,9 +71,10 @@ internal class TaskletStepBuilderDslTest { // when val testListener = TestListener() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - listener(testListener) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + listener(testListener) + }.build() // then verify(exactly = 1) { taskletStepBuilder.listener(testListener) } @@ -86,9 +87,10 @@ internal class TaskletStepBuilderDslTest { // when val itemStream = mockk() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - stream(itemStream) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + stream(itemStream) + }.build() // then verify(exactly = 1) { taskletStepBuilder.stream(itemStream) } @@ -101,9 +103,10 @@ internal class TaskletStepBuilderDslTest { // when val taskExecutor = mockk() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - taskExecutor(taskExecutor) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + taskExecutor(taskExecutor) + }.build() // then verify(exactly = 1) { taskletStepBuilder.taskExecutor(taskExecutor) } @@ -116,9 +119,10 @@ internal class TaskletStepBuilderDslTest { // when val exceptionHandler = mockk() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - exceptionHandler(exceptionHandler) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + exceptionHandler(exceptionHandler) + }.build() // then verify(exactly = 1) { taskletStepBuilder.exceptionHandler(exceptionHandler) } @@ -131,9 +135,10 @@ internal class TaskletStepBuilderDslTest { // when val repeatOperations = mockk() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - stepOperations(repeatOperations) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + stepOperations(repeatOperations) + }.build() // then verify(exactly = 1) { taskletStepBuilder.stepOperations(repeatOperations) } @@ -146,9 +151,10 @@ internal class TaskletStepBuilderDslTest { // when val transactionAttribute = mockk() - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - transactionAttribute(transactionAttribute) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + transactionAttribute(transactionAttribute) + }.build() // then verify(exactly = 1) { taskletStepBuilder.transactionAttribute(transactionAttribute) } @@ -158,9 +164,10 @@ internal class TaskletStepBuilderDslTest { fun testBuild() { // given val mockStep = mockk() - val taskletStepBuilder = mockk(relaxed = true) { - every { build() } returns mockStep - } + val taskletStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep + } // when val actual = TaskletStepBuilderDsl(mockk(), taskletStepBuilder).build() @@ -178,10 +185,11 @@ internal class TaskletStepBuilderDslTest { val repeatOperations = mockk() val taskExecutor = mockk() assertThatThrownBy { - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - stepOperations(repeatOperations) - taskExecutor(taskExecutor) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + stepOperations(repeatOperations) + taskExecutor(taskExecutor) + }.build() }.hasMessageContaining("taskExecutor is redundant") } @@ -194,16 +202,16 @@ internal class TaskletStepBuilderDslTest { val repeatOperations = mockk() val exceptionHandler = mockk() assertThatThrownBy { - TaskletStepBuilderDsl(mockk(), taskletStepBuilder).apply { - stepOperations(repeatOperations) - exceptionHandler(exceptionHandler) - }.build() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + stepOperations(repeatOperations) + exceptionHandler(exceptionHandler) + }.build() }.hasMessageContaining("exceptionHandler is redundant") } @Nested inner class RedundancyCheck { - @Test fun testStepOperationsAndRedundantSettings() { // given @@ -213,26 +221,25 @@ internal class TaskletStepBuilderDslTest { val stepBuilder = StepBuilder(UUID.randomUUID().toString(), mockk(relaxed = true)) // when - val step = stepBuilder - .tasklet({ _, _ -> RepeatStatus.FINISHED }, ResourcelessTransactionManager()) - .stepOperations( - object : RepeatTemplate() { - override fun iterate(callback: RepeatCallback): RepeatStatus { - ++iterateCount - return super.iterate(callback) - } - }, - ) - // redundant - .taskExecutor { task -> - ++taskExecutorCallCount - task.run() - } - .exceptionHandler { _, e -> - ++exceptionHandlerCallCount - throw e - } - .build() + val step = + stepBuilder + .tasklet({ _, _ -> RepeatStatus.FINISHED }, ResourcelessTransactionManager()) + .stepOperations( + object : RepeatTemplate() { + override fun iterate(callback: RepeatCallback): RepeatStatus { + ++iterateCount + return super.iterate(callback) + } + }, + ) + // redundant + .taskExecutor { task -> + ++taskExecutorCallCount + task.run() + }.exceptionHandler { _, e -> + ++exceptionHandlerCallCount + throw e + }.build() val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) val jobExecution = JobExecution(jobInstance, JobParameters()) val stepExecution = jobExecution.createStepExecution(step.name) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/support/LazyConfigurerTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/support/LazyConfigurerTest.kt index 82ad9e3..893133e 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/support/LazyConfigurerTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/support/LazyConfigurerTest.kt @@ -22,7 +22,6 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test internal class LazyConfigurerTest { - @Test fun testAdd() { // given diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt index 74c4aa7..94cdc05 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/item/adapter/ItemDelegatesTest.kt @@ -31,7 +31,6 @@ import org.springframework.batch.infrastructure.item.ExecutionContext import reactor.core.publisher.Flux internal class ItemDelegatesTest { - @Test fun testExtensions() { // when @@ -47,14 +46,9 @@ internal class ItemDelegatesTest { } internal open class TestClass : ItemStreamReaderProcessorWriter { + override fun readFlux(executionContext: ExecutionContext): Flux = Flux.empty() - override fun readFlux(executionContext: ExecutionContext): Flux { - return Flux.empty() - } - - override fun process(item: Int): String { - return item.toString() - } + override fun process(item: Int): String = item.toString() override fun write(chunk: Chunk) { } diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegatesTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegatesTest.kt index 9ad59be..ed9023c 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegatesTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/step/adapter/ItemDelegatesTest.kt @@ -32,7 +32,6 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test internal class ItemDelegatesTest { - @Test fun testAsItemStreamReaderOnItemStreamFluxReaderDelegate() { // when From 0d646f9168308307fa5109d5f5b91f5ea67ab9d0 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 20 May 2026 21:07:55 +0900 Subject: [PATCH 11/45] Remove DSL methods for APIs removed in Spring Batch 6.0 Signed-off-by: Taeik Lim --- .../kotlin/configuration/JobBuilderDsl.kt | 34 ------------ .../kotlin/configuration/StepBuilderDsl.kt | 28 ---------- .../configuration/JobBuilderDslHelperTest.kt | 55 ------------------- .../configuration/StepBuilderDslHelperTest.kt | 55 ------------------- 4 files changed, 172 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt index 4d6e043..6ca2edb 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt @@ -21,7 +21,6 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.builder.FlowJobBuilder @@ -34,8 +33,6 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.job.parameters.JobParametersIncrementer import org.springframework.batch.core.job.parameters.JobParametersValidator import org.springframework.batch.core.listener.JobExecutionListener -import org.springframework.batch.core.observability.BatchJobObservationConvention -import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor @@ -73,15 +70,6 @@ class JobBuilderDsl internal constructor( } } - /** - * Set for [JobBuilder.observationConvention][org.springframework.batch.core.job.builder.JobBuilderHelper.observationConvention]. - */ - fun observationConvention(observationConvention: BatchJobObservationConvention) { - lazyConfigurer.add { - it.observationConvention(observationConvention) - } - } - /** * Set for [JobBuilder.observationRegistry][org.springframework.batch.core.job.builder.JobBuilderHelper.observationRegistry]. */ @@ -91,28 +79,6 @@ class JobBuilderDsl internal constructor( } } - /** - * Set for [JobBuilder.meterRegistry][org.springframework.batch.core.job.builder.JobBuilderHelper.meterRegistry]. - */ - fun meterRegistry(meterRegistry: MeterRegistry) { - lazyConfigurer.add { - it.meterRegistry(meterRegistry) - } - } - - /** - * Set for [JobBuilder.repository][org.springframework.batch.core.job.builder.JobBuilderHelper.repository]. - */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.1.0 deprecates this", - ) - fun repository(jobRepository: JobRepository) { - lazyConfigurer.add { - it.repository(jobRepository) - } - } - /** * Set listener processing followings. * diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index 994e770..b50e8a3 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -25,14 +25,11 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.step.SimpleStepBuild import com.navercorp.spring.batch.plus.kotlin.configuration.step.TaskletStepBuilderDsl import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.listener.StepExecutionListener -import org.springframework.batch.core.observability.BatchStepObservationConvention -import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.batch.core.step.builder.SimpleStepBuilder @@ -53,24 +50,6 @@ class StepBuilderDsl internal constructor( private val dslContext: DslContext, private val stepBuilder: StepBuilder, ) { - /** - * Set for [StepBuilder.repository][org.springframework.batch.core.step.builder.StepBuilderHelper.repository]. - */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.1.0 deprecates this", - ) - fun repository(jobRepository: JobRepository) { - this.stepBuilder.repository(jobRepository) - } - - /** - * Set for [StepBuilder.observationConvention][org.springframework.batch.core.step.builder.StepBuilderHelper.observationConvention]. - */ - fun observationConvention(observationConvention: BatchStepObservationConvention) { - this.stepBuilder.observationConvention(observationConvention) - } - /** * Set for [StepBuilder.observationRegistry][org.springframework.batch.core.step.builder.StepBuilderHelper.observationRegistry]. */ @@ -78,13 +57,6 @@ class StepBuilderDsl internal constructor( this.stepBuilder.observationRegistry(observationRegistry) } - /** - * Set for [StepBuilder.meterRegistry][org.springframework.batch.core.step.builder.StepBuilderHelper.meterRegistry]. - */ - fun meterRegistry(meterRegistry: MeterRegistry) { - this.stepBuilder.meterRegistry(meterRegistry) - } - /** * Set for [StepBuilder.startLimit][org.springframework.batch.core.step.builder.StepBuilderHelper.startLimit]. */ diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt index c83b60c..73bfe84 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt @@ -19,7 +19,6 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry import io.mockk.mockk import io.mockk.spyk @@ -29,8 +28,6 @@ import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.parameters.JobParametersIncrementer import org.springframework.batch.core.job.parameters.JobParametersValidator import org.springframework.batch.core.listener.JobExecutionListener -import org.springframework.batch.core.observability.BatchJobObservationConvention -import org.springframework.batch.core.repository.JobRepository import java.util.UUID /** @@ -71,23 +68,6 @@ internal class JobBuilderDslHelperTest { verify(exactly = 1) { jobBuilder.incrementer(jobParametersIncrementer) } } - @Test - fun testObservationConvention() { - // given - val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) - val jobBuilderDsl = jobBuilderDsl(jobBuilder) - - // when - val observationConvention = mockk() - jobBuilderDsl - .apply { - observationConvention(observationConvention) - }.build() - - // then - verify(exactly = 1) { jobBuilder.observationConvention(observationConvention) } - } - @Test fun testObservationRegistry() { // given @@ -105,41 +85,6 @@ internal class JobBuilderDslHelperTest { verify(exactly = 1) { jobBuilder.observationRegistry(observationRegistry) } } - @Test - fun testMeterRegistry() { - // given - val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) - val jobBuilderDsl = jobBuilderDsl(jobBuilder) - - // when - val meterRegistry = mockk() - jobBuilderDsl - .apply { - meterRegistry(meterRegistry) - }.build() - - // then - verify(exactly = 1) { jobBuilder.meterRegistry(meterRegistry) } - } - - @Suppress("DEPRECATION") - @Test - fun testRepository() { - // given - val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) - val jobBuilderDsl = jobBuilderDsl(jobBuilder) - - // when - val jobRepository = mockk() - jobBuilderDsl - .apply { - repository(jobRepository) - }.build() - - // then - verify(exactly = 1) { jobBuilder.repository(jobRepository) } - } - @Test fun testObjectListener() { // given diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt index b5fff16..a381278 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt @@ -19,14 +19,11 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext -import io.micrometer.core.instrument.MeterRegistry import io.micrometer.observation.ObservationRegistry import io.mockk.mockk import io.mockk.verify import org.junit.jupiter.api.Test import org.springframework.batch.core.listener.StepExecutionListener -import org.springframework.batch.core.observability.BatchStepObservationConvention -import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.transaction.PlatformTransactionManager import java.util.concurrent.ThreadLocalRandom @@ -35,41 +32,6 @@ import java.util.concurrent.ThreadLocalRandom * org.springframework.batch.core.step.builder.StepBuilderHelper related tests */ internal class StepBuilderDslHelperTest { - @Suppress("DEPRECATION") - @Test - fun testRepository() { - // given - val stepBuilder = mockk(relaxed = true) - val stepBuilderDsl = stepBuilderDsl(stepBuilder) - - // when - val jobRepository = mockk() - stepBuilderDsl - .apply { - repository(jobRepository) - }.tasklet(mockk(), mockk()) - - // then - verify(exactly = 1) { stepBuilderDsl.repository(jobRepository) } - } - - @Test - fun testObservationConvention() { - // given - val stepBuilder = mockk(relaxed = true) - val stepBuilderDsl = stepBuilderDsl(stepBuilder) - - // when - val observationConvention = mockk() - stepBuilderDsl - .apply { - observationConvention(observationConvention) - }.tasklet(mockk(), mockk()) - - // then - verify(exactly = 1) { stepBuilderDsl.observationConvention(observationConvention) } - } - @Test fun testObservationRegistry() { // given @@ -87,23 +49,6 @@ internal class StepBuilderDslHelperTest { verify(exactly = 1) { stepBuilderDsl.observationRegistry(observationRegistry) } } - @Test - fun testMeterRegistry() { - // given - val stepBuilder = mockk(relaxed = true) - val stepBuilderDsl = stepBuilderDsl(stepBuilder) - - // when - val meterRegistry = mockk() - stepBuilderDsl - .apply { - meterRegistry(meterRegistry) - }.tasklet(mockk(), mockk()) - - // then - verify(exactly = 1) { stepBuilderDsl.meterRegistry(meterRegistry) } - } - @Test fun testStartLimit() { // given From c46919e52e6f1844d71984fb3216bc9a5729c4ce Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 22 May 2026 16:44:31 +0900 Subject: [PATCH 12/45] Add Java bridge for F-bound capture in JobBuilderDsl Signed-off-by: Taeik Lim --- .../configuration/BatchBuilderBridge.java | 39 +++++++++++++++++++ .../kotlin/configuration/JobBuilderDsl.kt | 5 +-- 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java diff --git a/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java b/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java new file mode 100644 index 0000000..6c2036d --- /dev/null +++ b/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java @@ -0,0 +1,39 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration; + +import org.springframework.batch.core.job.builder.FlowJobBuilder; +import org.springframework.batch.core.job.builder.JobBuilder; +import org.springframework.batch.core.job.builder.SimpleJobBuilder; + +// Java bridge for Spring Batch builder constructors whose F-bounded wildcard +// signatures cannot be matched by the Kotlin K2 compiler. See KT-66570. +final class BatchBuilderBridge { + + static SimpleJobBuilder toSimpleJobBuilder(JobBuilder jobBuilder) { + return new SimpleJobBuilder(jobBuilder); + } + + static FlowJobBuilder toFlowJobBuilder(JobBuilder jobBuilder) { + return new FlowJobBuilder(jobBuilder); + } + + private BatchBuilderBridge() { + } +} diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt index 6ca2edb..5fdfa39 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt @@ -27,7 +27,6 @@ import org.springframework.batch.core.job.builder.FlowJobBuilder import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.job.builder.JobBuilderHelper import org.springframework.batch.core.job.builder.JobFlowBuilder -import org.springframework.batch.core.job.builder.SimpleJobBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.job.parameters.JobParametersIncrementer @@ -250,13 +249,13 @@ class JobBuilderDsl internal constructor( this.jobBuilder.apply(this.lazyConfigurer) return if (!isFlowJob) { - val simpleJobBuilder = SimpleJobBuilder(this.jobBuilder) + val simpleJobBuilder = BatchBuilderBridge.toSimpleJobBuilder(this.jobBuilder) val simpleJobBuilderDsl = SimpleJobBuilderDsl(this.dslContext, simpleJobBuilder) SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) .apply(this.lazyFlowConfigurer) .build() } else { - val flowJobBuilder = FlowJobBuilder(this.jobBuilder) + val flowJobBuilder = BatchBuilderBridge.toFlowJobBuilder(this.jobBuilder) val jobFlowBuilder = JobFlowBuilder(flowJobBuilder) val delegate = ConcreteFlowBuilderDsl(this.dslContext, jobFlowBuilder) FlowJobBuilderDsl(this.dslContext, delegate) From 95fc9301e5e60f60f30475c79c95bce0b4409486 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 22 May 2026 17:27:40 +0900 Subject: [PATCH 13/45] Route SimpleStepBuilder/PartitionStepBuilder construction through bridge Signed-off-by: Taeik Lim --- .../kotlin/configuration/BatchBuilderBridge.java | 12 ++++++++++++ .../plus/kotlin/configuration/StepBuilderDsl.kt | 13 ++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java b/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java index 6c2036d..3e00bd3 100644 --- a/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java +++ b/spring-batch-plus-kotlin/src/main/java/com/navercorp/spring/batch/plus/kotlin/configuration/BatchBuilderBridge.java @@ -21,9 +21,13 @@ import org.springframework.batch.core.job.builder.FlowJobBuilder; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.job.builder.SimpleJobBuilder; +import org.springframework.batch.core.step.builder.PartitionStepBuilder; +import org.springframework.batch.core.step.builder.SimpleStepBuilder; +import org.springframework.batch.core.step.builder.StepBuilder; // Java bridge for Spring Batch builder constructors whose F-bounded wildcard // signatures cannot be matched by the Kotlin K2 compiler. See KT-66570. +@SuppressWarnings("deprecation") final class BatchBuilderBridge { static SimpleJobBuilder toSimpleJobBuilder(JobBuilder jobBuilder) { @@ -34,6 +38,14 @@ static FlowJobBuilder toFlowJobBuilder(JobBuilder jobBuilder) { return new FlowJobBuilder(jobBuilder); } + static SimpleStepBuilder toSimpleStepBuilder(StepBuilder stepBuilder) { + return new SimpleStepBuilder<>(stepBuilder); + } + + static PartitionStepBuilder toPartitionStepBuilder(StepBuilder stepBuilder) { + return new PartitionStepBuilder(stepBuilder); + } + private BatchBuilderBridge() { } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index b50e8a3..fbe0c73 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -31,8 +31,6 @@ import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow import org.springframework.batch.core.listener.StepExecutionListener import org.springframework.batch.core.step.Step -import org.springframework.batch.core.step.builder.PartitionStepBuilder -import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.Tasklet import org.springframework.batch.infrastructure.repeat.CompletionPolicy @@ -154,7 +152,7 @@ class StepBuilderDsl internal constructor( chunkSize: Int, simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { - val simpleStepBuilder = this.stepBuilder.chunk(chunkSize) + val simpleStepBuilder = BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).chunk(chunkSize) return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) .apply(simpleStepInit) .build() @@ -172,7 +170,7 @@ class StepBuilderDsl internal constructor( completionPolicy: CompletionPolicy, simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { - val simpleStepBuilder = this.stepBuilder.chunk(completionPolicy) + val simpleStepBuilder = BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).chunk(completionPolicy) return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) .apply(simpleStepInit) .build() @@ -189,7 +187,8 @@ class StepBuilderDsl internal constructor( repeatOperations: RepeatOperations, simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { - val simpleStepBuilder = SimpleStepBuilder(this.stepBuilder).chunkOperations(repeatOperations) + val simpleStepBuilder = + BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).chunkOperations(repeatOperations) return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) .apply(simpleStepInit) .build() @@ -274,7 +273,7 @@ class StepBuilderDsl internal constructor( simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { val simpleStepBuilder = - SimpleStepBuilder(this.stepBuilder).apply { + BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).apply { transactionManager(transactionManager) chunkOperations(repeatOperations) } @@ -287,7 +286,7 @@ class StepBuilderDsl internal constructor( * Set partition step. */ fun partitioner(partitionStepInit: PartitionStepBuilderDsl.() -> Unit): Step { - val partitionStepBuilder = PartitionStepBuilder(this.stepBuilder) + val partitionStepBuilder = BatchBuilderBridge.toPartitionStepBuilder(this.stepBuilder) return PartitionStepBuilderDsl(this.dslContext, partitionStepBuilder) .apply(partitionStepInit) .build() From 36348fbaa4afafd5f04a1efc1d3c6314c34dd9d8 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 22 May 2026 17:39:55 +0900 Subject: [PATCH 14/45] Add ChunkListener generic type arguments Signed-off-by: Taeik Lim --- .../plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt | 2 +- .../plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt | 2 +- .../configuration/step/FaultTolerantStepBuilderDslTest.kt | 6 +++--- .../kotlin/configuration/step/SimpleStepBuilderDslTest.kt | 2 +- .../kotlin/configuration/step/TaskletStepBuilderDslTest.kt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt index e6d8acb..10a8437 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt @@ -172,7 +172,7 @@ class SimpleStepBuilderDsl internal constructor( /** * Set for [SimpleStepBuilder.listener][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.listener]. */ - fun listener(chunkListener: ChunkListener) { + fun listener(chunkListener: ChunkListener) { this.simpleStepConfigurer.add { it.listener(chunkListener) } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt index a33ef68..5f5c241 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt @@ -50,7 +50,7 @@ class TaskletStepBuilderDsl internal constructor( /** * Set for [TaskletStepBuilder.listener][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.listener]. */ - fun listener(chunkListener: ChunkListener) { + fun listener(chunkListener: ChunkListener<*, *>) { this.lazyConfigurer.add { it.listener(chunkListener) } diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt index 4b15202..9901583 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt @@ -967,7 +967,7 @@ internal class FaultTolerantStepBuilderDslTest { .retry(RuntimeException::class.java) .writer {} .listener( - object : ChunkListener { + object : ChunkListener { override fun beforeChunk(context: ChunkContext): Unit = throw IllegalStateException("Error") override fun afterChunk(context: ChunkContext) { @@ -996,7 +996,7 @@ internal class FaultTolerantStepBuilderDslTest { reader { null } writer {} listener( - object : ChunkListener { + object : ChunkListener { override fun beforeChunk(context: ChunkContext): Unit = throw IllegalStateException("Error") override fun afterChunk(context: ChunkContext) { @@ -1034,7 +1034,7 @@ internal class FaultTolerantStepBuilderDslTest { retry() } listener( - object : ChunkListener { + object : ChunkListener { override fun beforeChunk(context: ChunkContext): Unit = throw IllegalStateException("Error") override fun afterChunk(context: ChunkContext) { diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index d5d7115..09b8692 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -188,7 +188,7 @@ internal class SimpleStepBuilderDslTest { val simpleStepBuilder = mockk>(relaxed = true) // when - val chunkListener = mockk() + val chunkListener = mockk>() SimpleStepBuilderDsl(mockk(), simpleStepBuilder) .apply { listener(chunkListener) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index ec2f83b..c77d5d6 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -52,7 +52,7 @@ internal class TaskletStepBuilderDslTest { val taskletStepBuilder = mockk(relaxed = true) // when - val chunkListener = mockk() + val chunkListener = mockk>() TaskletStepBuilderDsl(mockk(), taskletStepBuilder) .apply { listener(chunkListener) From 321121454da1a529d1a2127b3bc77a9506045d82 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 22 May 2026 17:53:24 +0900 Subject: [PATCH 15/45] Remove throttleLimit DSL (removed in Spring Batch 6.0) Signed-off-by: Taeik Lim --- .../step/SimpleStepBuilderDsl.kt | 23 ------ .../step/SimpleStepBuilderDslTest.kt | 74 ------------------- 2 files changed, 97 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt index 10a8437..adec8e5 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt @@ -60,7 +60,6 @@ class SimpleStepBuilderDsl internal constructor( private var faultTolerantStepConfigurer: Configurer>? = null private var taskExecutorSet = false - private var throttleLimitSet = false private var exceptionHandlerSet = false private var stepOperationsSet = false @@ -198,22 +197,6 @@ class SimpleStepBuilderDsl internal constructor( this.taskExecutorSet = true } - /** - * Set for [SimpleStepBuilder.throttleLimit][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.throttleLimit]. - * If not present, set as default value of [AbstractTaskletStepBuilder][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder]. - * It can't be used when no [taskExecutor] is set. - */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - ) - fun throttleLimit(throttleLimit: Int) { - this.simpleStepConfigurer.add { - it.throttleLimit(throttleLimit) - } - this.throttleLimitSet = true - } - /** * Set for [SimpleStepBuilder.exceptionHandler][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.exceptionHandler]. * It can't be used when [stepOperations] is set. @@ -255,12 +238,6 @@ class SimpleStepBuilderDsl internal constructor( } } - if (!this.taskExecutorSet) { - check(!this.throttleLimitSet) { - "throttleLimit is redundant when no taskExecutor is set." - } - } - val faultTolerantStepConfigurer = this.faultTolerantStepConfigurer val simpleStepConfigurer = this.simpleStepConfigurer return if (faultTolerantStepConfigurer != null) { diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index 09b8692..c8c7b47 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -231,24 +231,6 @@ internal class SimpleStepBuilderDslTest { } @Suppress("DEPRECATION") - @Test - fun testThrottleLimit() { - // given - val simpleStepBuilder = mockk>(relaxed = true) - - // when - val taskExecutor = mockk() - val limit = ThreadLocalRandom.current().nextInt() - SimpleStepBuilderDsl(mockk(), simpleStepBuilder) - .apply { - taskExecutor(taskExecutor) - throttleLimit(limit) - }.build() - - // then - verify(exactly = 1) { simpleStepBuilder.throttleLimit(limit) } - } - @Test fun testExceptionHandler() { // given @@ -345,21 +327,6 @@ internal class SimpleStepBuilderDslTest { }.hasMessageContaining("exceptionHandler is redundant") } - @Suppress("DEPRECATION") - @Test - fun testBuildWithSettingThrottleLimitWhenNoTaskExecutor() { - // given - val simpleStepBuilder = mockk>(relaxed = true) - - // when, then - assertThatThrownBy { - SimpleStepBuilderDsl(mockk(), simpleStepBuilder) - .apply { - throttleLimit(3) - }.build() - }.hasMessageContaining("throttleLimit is redundant") - } - @Nested inner class RedundancyCheck { @Test @@ -414,46 +381,5 @@ internal class SimpleStepBuilderDslTest { assertThat(exceptionHandlerCallCount).isEqualTo(0) } - @Suppress("DEPRECATION") - @Test - fun testThrottleLimitAndRedundantSettings() { - // given - val readLimit = 10000 - val chunkSize = 1 - var readCallCount = 0 - var processCallCount = 0 - var writeCallCount = 0 - val stepBuilder = StepBuilder(UUID.randomUUID().toString(), mockk(relaxed = true)) - - // when - val step = - stepBuilder - .chunk(chunkSize, ResourcelessTransactionManager()) - .reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - }.processor { - ++processCallCount - it - }.writer { - ++writeCallCount - }.throttleLimit(100) - .build() - val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) - val jobExecution = JobExecution(jobInstance, JobParameters()) - val stepExecution = jobExecution.createStepExecution(step.name) - step.execute(stepExecution) - - // then - assertThat(stepExecution.status).isEqualTo(BatchStatus.COMPLETED) - // if throttleLimit is applied to executor, it should be different by race condition - assertThat(readCallCount).isEqualTo(readLimit) - assertThat(processCallCount).isEqualTo(readLimit) - assertThat(writeCallCount).isEqualTo(10000) - } } } From 13300cf480b234b8b2f54e59e4ca5f49a2f5b412 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 22 May 2026 18:00:37 +0900 Subject: [PATCH 16/45] Replace JobStepBuilder.launcher with operator (Spring Batch 6.0) Signed-off-by: Taeik Lim --- .../kotlin/configuration/step/JobStepBuilderDsl.kt | 8 ++++---- .../kotlin/configuration/step/JobStepBuilderDslTest.kt | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt index c261514..9a73a7a 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDsl.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor @@ -40,11 +40,11 @@ class JobStepBuilderDsl internal constructor( private val lazyConfigurer = LazyConfigurer() /** - * Set for [JobStepBuilder.jobLauncher][org.springframework.batch.core.step.builder.JobStepBuilder.jobLauncher]. + * Set for [JobStepBuilder.operator][org.springframework.batch.core.step.builder.JobStepBuilder.operator]. */ - fun launcher(jobLauncher: JobLauncher) { + fun operator(jobOperator: JobOperator) { this.lazyConfigurer.add { - it.launcher(jobLauncher) + it.operator(jobOperator) } } diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt index 4364030..8e3c8f2 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt @@ -23,26 +23,26 @@ import io.mockk.mockk import io.mockk.verify import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor internal class JobStepBuilderDslTest { @Test - fun testLauncher() { + fun testOperator() { // given val jobStepBuilder = mockk(relaxed = true) // when - val jobLauncher = mockk() + val jobOperator = mockk() JobStepBuilderDsl(mockk(), jobStepBuilder) .apply { - launcher(jobLauncher) + operator(jobOperator) }.build() // then - verify(exactly = 1) { jobStepBuilder.launcher(jobLauncher) } + verify(exactly = 1) { jobStepBuilder.operator(jobOperator) } } @Test From 76ab7472101f18eda5d9bcf0361795353195f3cd Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 22 May 2026 18:59:12 +0900 Subject: [PATCH 17/45] Migrate Kotlin tests to Spring Batch 6 JobExecution/StepExecution APIs Signed-off-by: Taeik Lim --- .../configuration/step/TestBuilderBridge.java | 40 ++++++ .../step/FaultTolerantStepBuilderDslTest.kt | 123 +++++++++--------- .../step/PartitionStepBuilderDslTest.kt | 56 ++++---- .../step/SimpleStepBuilderDslTest.kt | 5 +- .../step/TaskletStepBuilderDslTest.kt | 5 +- 5 files changed, 136 insertions(+), 93 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/test/java/com/navercorp/spring/batch/plus/kotlin/configuration/step/TestBuilderBridge.java diff --git a/spring-batch-plus-kotlin/src/test/java/com/navercorp/spring/batch/plus/kotlin/configuration/step/TestBuilderBridge.java b/spring-batch-plus-kotlin/src/test/java/com/navercorp/spring/batch/plus/kotlin/configuration/step/TestBuilderBridge.java new file mode 100644 index 0000000..aefb4fb --- /dev/null +++ b/spring-batch-plus-kotlin/src/test/java/com/navercorp/spring/batch/plus/kotlin/configuration/step/TestBuilderBridge.java @@ -0,0 +1,40 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration.step; + +import org.springframework.batch.core.step.builder.PartitionStepBuilder; +import org.springframework.batch.core.step.builder.SimpleStepBuilder; +import org.springframework.batch.core.step.builder.StepBuilder; + +// Test-only Java bridge for Spring Batch builder constructors whose F-bounded wildcard +// signatures cannot be matched by the Kotlin K2 compiler. See KT-66570. +@SuppressWarnings("deprecation") +final class TestBuilderBridge { + + static SimpleStepBuilder simpleStepBuilder(StepBuilder stepBuilder) { + return new SimpleStepBuilder<>(stepBuilder); + } + + static PartitionStepBuilder partitionStepBuilder(StepBuilder stepBuilder) { + return new PartitionStepBuilder(stepBuilder); + } + + private TestBuilderBridge() { + } +} diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt index 9901583..8da2e2a 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt @@ -33,6 +33,7 @@ import org.springframework.batch.core.listener.SkipListener import org.springframework.batch.core.scope.context.ChunkContext import org.springframework.batch.core.step.FatalStepExecutionException import org.springframework.batch.core.step.Step +import org.springframework.batch.core.step.StepExecution import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy @@ -109,8 +110,8 @@ internal class FaultTolerantStepBuilderDslTest { ) } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -175,8 +176,8 @@ internal class FaultTolerantStepBuilderDslTest { ) } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -217,8 +218,8 @@ internal class FaultTolerantStepBuilderDslTest { } } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -256,8 +257,8 @@ internal class FaultTolerantStepBuilderDslTest { retry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -295,8 +296,8 @@ internal class FaultTolerantStepBuilderDslTest { retry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -335,8 +336,8 @@ internal class FaultTolerantStepBuilderDslTest { noRetry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -374,8 +375,8 @@ internal class FaultTolerantStepBuilderDslTest { retry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -422,8 +423,8 @@ internal class FaultTolerantStepBuilderDslTest { retry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -471,8 +472,8 @@ internal class FaultTolerantStepBuilderDslTest { retry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -513,8 +514,8 @@ internal class FaultTolerantStepBuilderDslTest { skip() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -554,8 +555,8 @@ internal class FaultTolerantStepBuilderDslTest { skip() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -596,8 +597,8 @@ internal class FaultTolerantStepBuilderDslTest { noSkip() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -641,8 +642,8 @@ internal class FaultTolerantStepBuilderDslTest { ) } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -677,8 +678,8 @@ internal class FaultTolerantStepBuilderDslTest { noRollback() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -723,8 +724,8 @@ internal class FaultTolerantStepBuilderDslTest { processorNonTransactional() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -747,7 +748,7 @@ internal class FaultTolerantStepBuilderDslTest { var onSkipInReadCallCount = 0 val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val simpleStepBuilder = SimpleStepBuilder(stepBuilder) + val simpleStepBuilder = TestBuilderBridge.simpleStepBuilder(stepBuilder) class TestListener { @Suppress("unused") @@ -780,8 +781,8 @@ internal class FaultTolerantStepBuilderDslTest { .skipLimit(skipLimit) .skip(IllegalStateException::class.java) .build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -802,7 +803,7 @@ internal class FaultTolerantStepBuilderDslTest { var onSkipInReadCallCount = 0 val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val simpleStepBuilder = SimpleStepBuilder(stepBuilder) + val simpleStepBuilder = TestBuilderBridge.simpleStepBuilder(stepBuilder) class TestListener { @Suppress("unused") @@ -835,8 +836,8 @@ internal class FaultTolerantStepBuilderDslTest { .skip(IllegalStateException::class.java) .listener(TestListener()) // called after faultTolerant() .build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -887,8 +888,8 @@ internal class FaultTolerantStepBuilderDslTest { skip(IllegalStateException::class) } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -939,8 +940,8 @@ internal class FaultTolerantStepBuilderDslTest { } listener(TestListener()) // called before faultTolerant } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -954,7 +955,7 @@ internal class FaultTolerantStepBuilderDslTest { fun testDelegateListenerIsInvokedWhenCalledWithFaultTolerant() { // given val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val simpleStepBuilder = SimpleStepBuilder(stepBuilder) + val simpleStepBuilder = TestBuilderBridge.simpleStepBuilder(stepBuilder) // when val step = @@ -977,8 +978,8 @@ internal class FaultTolerantStepBuilderDslTest { } }, ).build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1011,8 +1012,8 @@ internal class FaultTolerantStepBuilderDslTest { retry() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1045,8 +1046,8 @@ internal class FaultTolerantStepBuilderDslTest { }, ) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1065,7 +1066,7 @@ internal class FaultTolerantStepBuilderDslTest { var noRollbackCallCount = 0 val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val simpleStepBuilder = SimpleStepBuilder(stepBuilder) + val simpleStepBuilder = TestBuilderBridge.simpleStepBuilder(stepBuilder) // when val step = @@ -1094,8 +1095,8 @@ internal class FaultTolerantStepBuilderDslTest { } }, ).build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1138,8 +1139,8 @@ internal class FaultTolerantStepBuilderDslTest { noRollback() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1182,8 +1183,8 @@ internal class FaultTolerantStepBuilderDslTest { }, ) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1201,7 +1202,7 @@ internal class FaultTolerantStepBuilderDslTest { var readCallCount = 0 val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val simpleStepBuilder = SimpleStepBuilder(stepBuilder) + val simpleStepBuilder = TestBuilderBridge.simpleStepBuilder(stepBuilder) class TestStream : ItemStream, @@ -1241,8 +1242,8 @@ internal class FaultTolerantStepBuilderDslTest { .faultTolerant() .stream(TestStream()) .build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1297,8 +1298,8 @@ internal class FaultTolerantStepBuilderDslTest { writer {} faultTolerant {} } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -1353,8 +1354,8 @@ internal class FaultTolerantStepBuilderDslTest { } stream(TestStream()) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt index 52c852c..1b8f9ec 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt @@ -52,7 +52,7 @@ internal class PartitionStepBuilderDslTest { var partitionHandlerCallCount = 0 var taskExecutorCallCount = 0 val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val partitionStepBuilder = PartitionStepBuilder(stepBuilder) + val partitionStepBuilder = TestBuilderBridge.partitionStepBuilder(stepBuilder) // when val step = @@ -77,8 +77,8 @@ internal class PartitionStepBuilderDslTest { task.run() }.gridSize(3) .build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -103,7 +103,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } } @@ -124,8 +124,8 @@ internal class PartitionStepBuilderDslTest { } splitter(splitter) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -157,7 +157,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } } @@ -191,8 +191,8 @@ internal class PartitionStepBuilderDslTest { } splitter(splitter) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -224,7 +224,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } } @@ -254,8 +254,8 @@ internal class PartitionStepBuilderDslTest { } splitter(splitter) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -286,7 +286,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } } @@ -321,8 +321,8 @@ internal class PartitionStepBuilderDslTest { } splitter(splitter) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -352,7 +352,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } } @@ -385,7 +385,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } } @@ -408,7 +408,7 @@ internal class PartitionStepBuilderDslTest { val dummyStepName = "dummyStepName" var partitionerCallCount = 0 val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val partitionStepBuilder = PartitionStepBuilder(stepBuilder) + val partitionStepBuilder = TestBuilderBridge.partitionStepBuilder(stepBuilder) // when val step = @@ -433,8 +433,8 @@ internal class PartitionStepBuilderDslTest { ++partitionerCallCount mapOf() }.build() - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -477,14 +477,14 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - jobExecution.createStepExecution("${stepName}$it") + StepExecution("${stepName}$it", jobExecution) }.toSet() } }, ) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -528,8 +528,8 @@ internal class PartitionStepBuilderDslTest { }.toMap() } } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -582,8 +582,8 @@ internal class PartitionStepBuilderDslTest { partitionHandler(mockk(relaxed = true)) splitter(mockk()) } - val jobExecution = JobExecution(jobInstance, jobParameters) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, jobParameters) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then @@ -603,6 +603,6 @@ internal class PartitionStepBuilderDslTest { } val stepBuilder = StepBuilder("testStep", mockk) - return PartitionStepBuilderDsl(dslContext, PartitionStepBuilder(stepBuilder)).apply(init).build() + return PartitionStepBuilderDsl(dslContext, TestBuilderBridge.partitionStepBuilder(stepBuilder)).apply(init).build() } } diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index c8c7b47..f2bcc47 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -33,6 +33,7 @@ import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.listener.ItemProcessListener import org.springframework.batch.core.listener.ItemReadListener import org.springframework.batch.core.listener.ItemWriteListener +import org.springframework.batch.core.step.StepExecution import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep @@ -369,8 +370,8 @@ internal class SimpleStepBuilderDslTest { throw e }.build() val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) - val jobExecution = JobExecution(jobInstance, JobParameters()) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, JobParameters()) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index c77d5d6..66f0422 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -30,6 +30,7 @@ import org.springframework.batch.core.job.JobExecution import org.springframework.batch.core.job.JobInstance import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.listener.ChunkListener +import org.springframework.batch.core.step.StepExecution import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.builder.TaskletStepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep @@ -241,8 +242,8 @@ internal class TaskletStepBuilderDslTest { throw e }.build() val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) - val jobExecution = JobExecution(jobInstance, JobParameters()) - val stepExecution = jobExecution.createStepExecution(step.name) + val jobExecution = JobExecution(0L, jobInstance, JobParameters()) + val stepExecution = StepExecution(step.name, jobExecution) step.execute(stepExecution) // then From 377b209623e4cc2d493987d74905c8be49a003af Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Tue, 26 May 2026 11:05:08 +0900 Subject: [PATCH 18/45] Split @EnableJdbcJobRepository from @EnableBatchProcessing (Spring Batch 6.0) Signed-off-by: Taeik Lim --- .../configuration/ConcreteFlowBuilderDslIntegrationTest.kt | 4 +++- .../DeciderTransitionBuilderDslIntegrationTest.kt | 4 +++- .../kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt | 4 +++- .../configuration/FlowTransitionBuilderDslIntegrationTest.kt | 4 +++- .../configuration/SimpleJobBuilderDslIntegrationTest.kt | 4 +++- .../kotlin/configuration/SplitBuilderDslIntegrationTest.kt | 4 +++- .../kotlin/configuration/StepBuilderDslIntegrationTest.kt | 4 +++- .../configuration/StepTransitionBuilderDslIntegrationTest.kt | 4 +++- .../configuration/TransitionBuilderDslIntegrationTest.kt | 4 +++- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt index 01bc155..cf3dc7e 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.job.parameters.JobParameters @@ -1185,7 +1186,8 @@ internal class ConcreteFlowBuilderDslIntegrationTest { } @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt index 7734198..e1aa1a6 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.job.parameters.JobParameters @@ -124,7 +125,8 @@ internal class DeciderTransitionBuilderDslIntegrationTest { ).random() @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt index 1fca2a3..1903154 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.job.parameters.JobParameters @@ -934,7 +935,8 @@ internal class FlowJobBuilderDslIntegrationTest { } @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt index 4837904..f78e33f 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository @@ -139,7 +140,8 @@ internal class FlowTransitionBuilderDslIntegrationTest { ).random() @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt index 36c1025..f9fae3d 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt @@ -22,6 +22,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository @@ -190,7 +191,8 @@ internal class SimpleJobBuilderDslIntegrationTest { } @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt index b330ab8..1ae1bbd 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository @@ -269,7 +270,8 @@ internal class SplitBuilderDslIntegrationTest { } @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 09b5918..bf35c8e 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -23,6 +23,7 @@ import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository @@ -867,7 +868,8 @@ internal class StepBuilderDslIntegrationTest { } @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt index 8a539ac..b3d5145 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository @@ -135,7 +136,8 @@ internal class StepTransitionBuilderDslIntegrationTest { ).random() @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt index bcaf9c7..56da0b7 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.ExitStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider import org.springframework.batch.core.job.parameters.JobParameters @@ -1954,7 +1955,8 @@ internal class TransitionBuilderDslIntegrationTest { } @Configuration - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) From 3089a6574f9ce466b032ec0648b2373b7b910995 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Tue, 26 May 2026 11:05:51 +0900 Subject: [PATCH 19/45] Register StepExecutions with JobExecution explicitly (Spring Batch 6.0) Signed-off-by: Taeik Lim --- .../step/PartitionStepBuilderDslTest.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt index 1b8f9ec..f0dafaf 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt @@ -35,7 +35,6 @@ import org.springframework.batch.core.partition.StepExecutionSplitter import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.StepExecution -import org.springframework.batch.core.step.builder.PartitionStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.infrastructure.item.ExecutionContext @@ -79,6 +78,7 @@ internal class PartitionStepBuilderDslTest { .build() val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -104,6 +104,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } } @@ -126,6 +127,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -158,6 +160,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } } @@ -193,6 +196,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -225,6 +229,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } } @@ -256,6 +261,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -287,6 +293,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } } @@ -323,6 +330,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -353,6 +361,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } } @@ -386,6 +395,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } } @@ -435,6 +445,7 @@ internal class PartitionStepBuilderDslTest { }.build() val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -478,6 +489,7 @@ internal class PartitionStepBuilderDslTest { return (0 until gridSize) .map { StepExecution("${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } }.toSet() } }, @@ -485,6 +497,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -530,6 +543,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -584,6 +598,7 @@ internal class PartitionStepBuilderDslTest { } val jobExecution = JobExecution(0L, jobInstance, jobParameters) val stepExecution = StepExecution(step.name, jobExecution) + jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) // then @@ -600,6 +615,11 @@ internal class PartitionStepBuilderDslTest { val mockk = mockk(relaxed = true) { every { getLastStepExecution(any(), any()) } returns null + every { createStepExecution(any(), any()) } answers { + val name = firstArg() + val jobExecution = secondArg() + StepExecution(name, jobExecution).also { jobExecution.addStepExecution(it) } + } } val stepBuilder = StepBuilder("testStep", mockk) From 8b76c0c52774306f886c46b5a7dbc4b638b1ab86 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Tue, 26 May 2026 11:06:27 +0900 Subject: [PATCH 20/45] Format Kotlin tests with ktlint Signed-off-by: Taeik Lim --- .../kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt | 1 - .../plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt index 8da2e2a..4e00a05 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt @@ -34,7 +34,6 @@ import org.springframework.batch.core.scope.context.ChunkContext import org.springframework.batch.core.step.FatalStepExecutionException import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.StepExecution -import org.springframework.batch.core.step.builder.SimpleStepBuilder import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy import org.springframework.batch.infrastructure.item.ExecutionContext diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index f2bcc47..e43a143 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -381,6 +381,5 @@ internal class SimpleStepBuilderDslTest { assertThat(taskExecutorCallCount).isEqualTo(0) assertThat(exceptionHandlerCallCount).isEqualTo(0) } - } } From 55aaf51fb0e0a7d389a2d888309a0f7a048748fc Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 27 May 2026 17:33:20 +0900 Subject: [PATCH 21/45] Propagate Spring Batch 6.0 deprecations to Kotlin DSL Signed-off-by: Taeik Lim --- .../kotlin/configuration/StepBuilderDsl.kt | 13 +++++++ .../step/SimpleStepBuilderDsl.kt | 8 +++++ .../step/TaskletStepBuilderDsl.kt | 4 +++ .../step/FaultTolerantStepBuilderDslTest.kt | 2 ++ .../step/PartitionStepBuilderDslTest.kt | 34 +++++++++---------- .../step/SimpleStepBuilderDslTest.kt | 2 ++ .../step/TaskletStepBuilderDslTest.kt | 5 ++- 7 files changed, 50 insertions(+), 18 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index fbe0c73..2f0d512 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -179,6 +179,7 @@ class StepBuilderDsl internal constructor( /** * Set chunk-based step with a repeat operations. */ + @Suppress("DEPRECATION") @Deprecated( message = "spring batch 5.0.0 deprecates this", replaceWith = ReplaceWith("chunk(repeatOperations, transactionManager, simpleStepInit)"), @@ -239,6 +240,10 @@ class StepBuilderDsl internal constructor( /** * Set chunk-based step with a chunk size. */ + @Suppress("DEPRECATION") + @Deprecated( + message = "Spring Batch 6.0 deprecates this.", + ) fun chunk( chunkSize: Int, transactionManager: PlatformTransactionManager, @@ -253,6 +258,10 @@ class StepBuilderDsl internal constructor( /** * Set chunk-based step with a completion policy. */ + @Suppress("DEPRECATION") + @Deprecated( + message = "Spring Batch 6.0 deprecates this.", + ) fun chunk( completionPolicy: CompletionPolicy, transactionManager: PlatformTransactionManager, @@ -267,6 +276,10 @@ class StepBuilderDsl internal constructor( /** * Set chunk-based step with a repeat operations. */ + @Suppress("DEPRECATION") + @Deprecated( + message = "Spring Batch 6.0 deprecates this.", + ) fun chunk( repeatOperations: RepeatOperations, transactionManager: PlatformTransactionManager, diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt index adec8e5..35ad286 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDsl.kt @@ -16,6 +16,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker @@ -52,6 +54,9 @@ import kotlin.reflect.KClass * @since 0.1.0 */ @BatchDslMarker +@Deprecated( + message = "Spring Batch 6.0 deprecates SimpleStepBuilder, FaultTolerantStepBuilder.", +) class SimpleStepBuilderDsl internal constructor( private val dslContext: DslContext, private val simpleStepBuilder: SimpleStepBuilder, @@ -259,6 +264,9 @@ class SimpleStepBuilderDsl internal constructor( * @since 0.1.0 */ @BatchDslMarker + @Deprecated( + message = "Spring Batch 6.0 deprecates FaultTolerantStepBuilder.", + ) class FaultTolerantStepBuilderDsl internal constructor( @Suppress("unused") private val dslContext: DslContext, diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt index 5f5c241..aae2ba2 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt @@ -82,6 +82,10 @@ class TaskletStepBuilderDsl internal constructor( * Set for [TaskletStepBuilder.taskExecutor][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.taskExecutor]. * It can't be used when [stepOperations] is set. */ + @Suppress("DEPRECATION") + @Deprecated( + message = "Spring Batch 6.0 deprecates this.", + ) fun taskExecutor(taskExecutor: TaskExecutor) { this.lazyConfigurer.add { it.taskExecutor(taskExecutor) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt index 4e00a05..0af43cc 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FaultTolerantStepBuilderDslTest.kt @@ -16,6 +16,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION", "OVERRIDE_DEPRECATION") + package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt index f0dafaf..eecb10d 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt @@ -77,7 +77,7 @@ internal class PartitionStepBuilderDslTest { }.gridSize(3) .build() val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -103,7 +103,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -126,7 +126,7 @@ internal class PartitionStepBuilderDslTest { splitter(splitter) } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -159,7 +159,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -195,7 +195,7 @@ internal class PartitionStepBuilderDslTest { splitter(splitter) } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -228,7 +228,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -260,7 +260,7 @@ internal class PartitionStepBuilderDslTest { splitter(splitter) } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -292,7 +292,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -329,7 +329,7 @@ internal class PartitionStepBuilderDslTest { splitter(splitter) } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -360,7 +360,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -394,7 +394,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -444,7 +444,7 @@ internal class PartitionStepBuilderDslTest { mapOf() }.build() val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -488,7 +488,7 @@ internal class PartitionStepBuilderDslTest { val jobExecution = stepExecution.jobExecution return (0 until gridSize) .map { - StepExecution("${stepName}$it", jobExecution) + StepExecution(0L, "${stepName}$it", jobExecution) .also { jobExecution.addStepExecution(it) } }.toSet() } @@ -496,7 +496,7 @@ internal class PartitionStepBuilderDslTest { ) } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -542,7 +542,7 @@ internal class PartitionStepBuilderDslTest { } } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -597,7 +597,7 @@ internal class PartitionStepBuilderDslTest { splitter(mockk()) } val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) jobExecution.addStepExecution(stepExecution) step.execute(stepExecution) @@ -618,7 +618,7 @@ internal class PartitionStepBuilderDslTest { every { createStepExecution(any(), any()) } answers { val name = firstArg() val jobExecution = secondArg() - StepExecution(name, jobExecution).also { jobExecution.addStepExecution(it) } + StepExecution(0L, name, jobExecution).also { jobExecution.addStepExecution(it) } } } val stepBuilder = StepBuilder("testStep", mockk) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index e43a143..77e80c4 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -16,6 +16,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.navercorp.spring.batch.plus.kotlin.configuration.step import io.mockk.every diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index 66f0422..5181aef 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -97,6 +97,7 @@ internal class TaskletStepBuilderDslTest { verify(exactly = 1) { taskletStepBuilder.stream(itemStream) } } + @Suppress("DEPRECATION") @Test fun testTaskExecutor() { // given @@ -177,6 +178,7 @@ internal class TaskletStepBuilderDslTest { assertThat(actual).isEqualTo(mockStep) } + @Suppress("DEPRECATION") @Test fun testBuildWithSettingStepOperationsAndTaskExecutor() { // given @@ -213,6 +215,7 @@ internal class TaskletStepBuilderDslTest { @Nested inner class RedundancyCheck { + @Suppress("DEPRECATION") @Test fun testStepOperationsAndRedundantSettings() { // given @@ -243,7 +246,7 @@ internal class TaskletStepBuilderDslTest { }.build() val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) val jobExecution = JobExecution(0L, jobInstance, JobParameters()) - val stepExecution = StepExecution(step.name, jobExecution) + val stepExecution = StepExecution(0L, step.name, jobExecution) step.execute(stepExecution) // then From bdbc9f1a2660f7393b6f2009fe210d374fdb7f7f Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 1 Jun 2026 20:49:25 +0900 Subject: [PATCH 22/45] Drop stale @Deprecated on tasklet DSL methods (un-deprecated in Spring Batch 6.0) Signed-off-by: Taeik Lim --- .../kotlin/configuration/StepBuilderDsl.kt | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index 2f0d512..aa9aac1 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -89,21 +89,11 @@ class StepBuilderDsl internal constructor( /** * Set tasklet step by bean name. */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("taskletBean(name, transactionManager)"), - ) fun taskletBean(name: String): Step = taskletBean(name) {} /** * Set tasklet step by bean name. */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("taskletBean(name, transactionManager, taskletStepInit)"), - ) fun taskletBean( name: String, taskletStepInit: TaskletStepBuilderDsl.() -> Unit, @@ -115,21 +105,11 @@ class StepBuilderDsl internal constructor( /** * Set tasklet step. */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("tasklet(tasklet, transactionManager)"), - ) fun tasklet(tasklet: Tasklet): Step = tasklet(tasklet) {} /** * Set tasklet step. */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("tasklet(tasklet, transactionManager, taskletStepInit)"), - ) fun tasklet( tasklet: Tasklet, taskletStepInit: TaskletStepBuilderDsl.() -> Unit, From 1477a43a269366cf484dcdde1f5de036bece69c7 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Tue, 2 Jun 2026 12:12:18 +0900 Subject: [PATCH 23/45] Add ChunkOrientedStepBuilderDsl Signed-off-by: Taeik Lim --- .../StepBuilderDslIntegrationTest.kt | 120 +---- .../kotlin/configuration/StepBuilderDsl.kt | 86 +--- .../step/ChunkOrientedStepBuilderDsl.kt | 275 ++++++++++++ .../step/ChunkOrientedStepBuilderDslTest.kt | 409 ++++++++++++++++++ 4 files changed, 702 insertions(+), 188 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDsl.kt create mode 100644 spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslTest.kt diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index bf35c8e..98f9bdd 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -30,7 +30,6 @@ import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.tasklet.Tasklet import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy -import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean @@ -158,112 +157,6 @@ internal class StepBuilderDslIntegrationTest { } } - @Test - fun testDeprecatedChunkWithCount() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val readLimit = 20 - val chunkSize = 3 - var readCallCount = 0 - var writeCallCount = 0 - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - chunk(chunkSize) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - writer { - ++writeCallCount - } - } - } - } - } - } - } - - @Test - fun testDeprecatedChunkWithCompletionPolicy() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val readLimit = 20 - val chunkSize = 3 - var readCallCount = 0 - var writeCallCount = 0 - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - chunk(SimpleCompletionPolicy(chunkSize)) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - writer { - ++writeCallCount - } - } - } - } - } - } - } - - @Test - fun testDeprecatedChunkWithRepeatOperations() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val readLimit = 20 - val chunkSize = 3 - var readCallCount = 0 - var writeCallCount = 0 - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - chunk( - RepeatTemplate().apply { - setCompletionPolicy(SimpleCompletionPolicy(chunkSize)) - }, - ) { - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - writer { - ++writeCallCount - } - } - } - } - } - } - } - @Test fun testTaskletBean() { // given @@ -483,7 +376,7 @@ internal class StepBuilderDslIntegrationTest { } @Test - fun testChunkWithRepeatOperations() { + fun testChunkOriented() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobLauncher = context.getBean() @@ -498,12 +391,8 @@ internal class StepBuilderDslIntegrationTest { batch { job("testJob") { step("testStep") { - chunk( - RepeatTemplate().apply { - setCompletionPolicy(SimpleCompletionPolicy(chunkSize)) - }, - ResourcelessTransactionManager(), - ) { + chunk(chunkSize) { + transactionManager(ResourcelessTransactionManager()) reader { if (readCallCount < readLimit) { ++readCallCount @@ -515,6 +404,9 @@ internal class StepBuilderDslIntegrationTest { writer { ++writeCallCount } + faultTolerant() + skip() + skipLimit(1L) } } } diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt index aa9aac1..216d4a7 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDsl.kt @@ -18,6 +18,7 @@ package com.navercorp.spring.batch.plus.kotlin.configuration +import com.navercorp.spring.batch.plus.kotlin.configuration.step.ChunkOrientedStepBuilderDsl import com.navercorp.spring.batch.plus.kotlin.configuration.step.FlowStepBuilderDsl import com.navercorp.spring.batch.plus.kotlin.configuration.step.JobStepBuilderDsl import com.navercorp.spring.batch.plus.kotlin.configuration.step.PartitionStepBuilderDsl @@ -34,7 +35,6 @@ import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.Tasklet import org.springframework.batch.infrastructure.repeat.CompletionPolicy -import org.springframework.batch.infrastructure.repeat.RepeatOperations import org.springframework.beans.factory.getBean import org.springframework.transaction.PlatformTransactionManager @@ -120,61 +120,6 @@ class StepBuilderDsl internal constructor( .build() } - /** - * Set chunk-based step with a chunk size. - */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("chunk(chunkSize, transactionManager, simpleStepInit)"), - ) - fun chunk( - chunkSize: Int, - simpleStepInit: SimpleStepBuilderDsl.() -> Unit, - ): Step { - val simpleStepBuilder = BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).chunk(chunkSize) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) - .apply(simpleStepInit) - .build() - } - - /** - * Set chunk-based step with a completion policy. - */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("chunk(completionPolicy, transactionManager, simpleStepInit)"), - ) - fun chunk( - completionPolicy: CompletionPolicy, - simpleStepInit: SimpleStepBuilderDsl.() -> Unit, - ): Step { - val simpleStepBuilder = BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).chunk(completionPolicy) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) - .apply(simpleStepInit) - .build() - } - - /** - * Set chunk-based step with a repeat operations. - */ - @Suppress("DEPRECATION") - @Deprecated( - message = "spring batch 5.0.0 deprecates this", - replaceWith = ReplaceWith("chunk(repeatOperations, transactionManager, simpleStepInit)"), - ) - fun chunk( - repeatOperations: RepeatOperations, - simpleStepInit: SimpleStepBuilderDsl.() -> Unit, - ): Step { - val simpleStepBuilder = - BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).chunkOperations(repeatOperations) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) - .apply(simpleStepInit) - .build() - } - /** * Set tasklet step by bean name. */ @@ -236,40 +181,33 @@ class StepBuilderDsl internal constructor( } /** - * Set chunk-based step with a completion policy. + * Set chunk-oriented step with a chunk size. + * + * @since 2.0.0 */ - @Suppress("DEPRECATION") - @Deprecated( - message = "Spring Batch 6.0 deprecates this.", - ) fun chunk( - completionPolicy: CompletionPolicy, - transactionManager: PlatformTransactionManager, - simpleStepInit: SimpleStepBuilderDsl.() -> Unit, + chunkSize: Int, + chunkOrientedStepInit: ChunkOrientedStepBuilderDsl.() -> Unit, ): Step { - val simpleStepBuilder = this.stepBuilder.chunk(completionPolicy, transactionManager) - return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) - .apply(simpleStepInit) + val chunkOrientedStepBuilder = this.stepBuilder.chunk(chunkSize) + return ChunkOrientedStepBuilderDsl(this.dslContext, chunkOrientedStepBuilder) + .apply(chunkOrientedStepInit) .build() } /** - * Set chunk-based step with a repeat operations. + * Set chunk-based step with a completion policy. */ @Suppress("DEPRECATION") @Deprecated( message = "Spring Batch 6.0 deprecates this.", ) fun chunk( - repeatOperations: RepeatOperations, + completionPolicy: CompletionPolicy, transactionManager: PlatformTransactionManager, simpleStepInit: SimpleStepBuilderDsl.() -> Unit, ): Step { - val simpleStepBuilder = - BatchBuilderBridge.toSimpleStepBuilder(this.stepBuilder).apply { - transactionManager(transactionManager) - chunkOperations(repeatOperations) - } + val simpleStepBuilder = this.stepBuilder.chunk(completionPolicy, transactionManager) return SimpleStepBuilderDsl(this.dslContext, simpleStepBuilder) .apply(simpleStepInit) .build() diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDsl.kt new file mode 100644 index 0000000..9c9b970 --- /dev/null +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDsl.kt @@ -0,0 +1,275 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration.step + +import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker +import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext +import com.navercorp.spring.batch.plus.kotlin.configuration.support.LazyConfigurer +import io.micrometer.observation.ObservationRegistry +import org.springframework.batch.core.listener.SkipListener +import org.springframework.batch.core.listener.StepListener +import org.springframework.batch.core.step.Step +import org.springframework.batch.core.step.StepInterruptionPolicy +import org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder +import org.springframework.batch.core.step.skip.SkipPolicy +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.core.retry.RetryListener +import org.springframework.core.retry.RetryPolicy +import org.springframework.core.task.AsyncTaskExecutor +import org.springframework.transaction.PlatformTransactionManager +import org.springframework.transaction.interceptor.TransactionAttribute +import kotlin.reflect.KClass + +/** + * A dsl for [ChunkOrientedStepBuilder][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder]. + * + * Only methods defined on `ChunkOrientedStepBuilder` itself are exposed here. Step-level lifecycle + * members inherited from `StepBuilderHelper` are configured on + * the outer [com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl] before `chunk()` * is called. + * Method order matches the upstream source. + * + * @since 2.0.0 + */ +@BatchDslMarker +class ChunkOrientedStepBuilderDsl internal constructor( + @Suppress("unused") + private val dslContext: DslContext, + private val chunkOrientedStepBuilder: ChunkOrientedStepBuilder, +) { + private val lazyConfigurer = LazyConfigurer>() + + /** + * Set for [ChunkOrientedStepBuilder.reader][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.reader]. + */ + fun reader(reader: ItemReader) { + this.lazyConfigurer.add { + it.reader(reader) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.processor][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.processor]. + */ + fun processor(processor: ItemProcessor) { + this.lazyConfigurer.add { + it.processor(processor) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.writer][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.writer]. + */ + fun writer(writer: ItemWriter) { + this.lazyConfigurer.add { + it.writer(writer) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.transactionManager][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.transactionManager]. + */ + fun transactionManager(transactionManager: PlatformTransactionManager) { + this.lazyConfigurer.add { + it.transactionManager(transactionManager) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.transactionAttribute][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.transactionAttribute]. + */ + fun transactionAttribute(transactionAttribute: TransactionAttribute) { + this.lazyConfigurer.add { + it.transactionAttribute(transactionAttribute) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.stream][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.stream]. + */ + fun stream(stream: ItemStream) { + this.lazyConfigurer.add { + it.stream(stream) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.listener][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.listener]. + */ + fun listener(listener: StepListener) { + this.lazyConfigurer.add { + it.listener(listener) + } + } + + /** + * Set listener processing followings. + * + * - [org.springframework.batch.core.annotation.BeforeStep] + * - [org.springframework.batch.core.annotation.AfterStep] + * - [org.springframework.batch.core.annotation.BeforeChunk] + * - [org.springframework.batch.core.annotation.AfterChunk] + * - [org.springframework.batch.core.annotation.OnChunkError] + * - [org.springframework.batch.core.annotation.BeforeRead] + * - [org.springframework.batch.core.annotation.AfterRead] + * - [org.springframework.batch.core.annotation.OnReadError] + * - [org.springframework.batch.core.annotation.BeforeProcess] + * - [org.springframework.batch.core.annotation.AfterProcess] + * - [org.springframework.batch.core.annotation.OnProcessError] + * - [org.springframework.batch.core.annotation.BeforeWrite] + * - [org.springframework.batch.core.annotation.AfterWrite] + * - [org.springframework.batch.core.annotation.OnWriteError] + */ + fun listener(listener: Any) { + this.lazyConfigurer.add { + it.listener(listener) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.interruptionPolicy][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.interruptionPolicy]. + */ + fun interruptionPolicy(interruptionPolicy: StepInterruptionPolicy) { + this.lazyConfigurer.add { + it.interruptionPolicy(interruptionPolicy) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.faultTolerant][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.faultTolerant]. + * + * Must be called before any retry/skip configuration takes effect. + */ + fun faultTolerant() { + this.lazyConfigurer.add { + it.faultTolerant() + } + } + + /** + * Set for [ChunkOrientedStepBuilder.retryPolicy][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.retryPolicy]. + */ + fun retryPolicy(policy: RetryPolicy) { + this.lazyConfigurer.add { + it.retryPolicy(policy) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.retryListener][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.retryListener]. + */ + fun retryListener(listener: RetryListener) { + this.lazyConfigurer.add { + it.retryListener(listener) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.retry][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.retry]. + */ + inline fun retry() { + retry(T::class) + } + + /** + * Set for [ChunkOrientedStepBuilder.retry][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.retry]. + */ + fun retry(exceptionClass: KClass) { + this.lazyConfigurer.add { + it.retry(exceptionClass.java) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.retryLimit][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.retryLimit]. + */ + fun retryLimit(retryLimit: Long) { + this.lazyConfigurer.add { + it.retryLimit(retryLimit) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.skipPolicy][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.skipPolicy]. + */ + fun skipPolicy(skipPolicy: SkipPolicy) { + this.lazyConfigurer.add { + it.skipPolicy(skipPolicy) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.skipListener][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.skipListener]. + */ + fun skipListener(skipListener: SkipListener) { + this.lazyConfigurer.add { + it.skipListener(skipListener) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.skip][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.skip]. + */ + inline fun skip() { + skip(T::class) + } + + /** + * Set for [ChunkOrientedStepBuilder.skip][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.skip]. + */ + fun skip(exceptionClass: KClass) { + this.lazyConfigurer.add { + it.skip(exceptionClass.java) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.skipLimit][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.skipLimit]. + */ + fun skipLimit(skipLimit: Long) { + this.lazyConfigurer.add { + it.skipLimit(skipLimit) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.taskExecutor][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.taskExecutor]. + */ + fun taskExecutor(asyncTaskExecutor: AsyncTaskExecutor) { + this.lazyConfigurer.add { + it.taskExecutor(asyncTaskExecutor) + } + } + + /** + * Set for [ChunkOrientedStepBuilder.observationRegistry][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.observationRegistry]. + */ + fun observationRegistry(observationRegistry: ObservationRegistry) { + this.lazyConfigurer.add { + it.observationRegistry(observationRegistry) + } + } + + internal fun build(): Step = + this.chunkOrientedStepBuilder + .apply(this.lazyConfigurer) + .build() +} diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslTest.kt new file mode 100644 index 0000000..c2c6f02 --- /dev/null +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslTest.kt @@ -0,0 +1,409 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration.step + +import io.micrometer.observation.ObservationRegistry +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.springframework.batch.core.listener.SkipListener +import org.springframework.batch.core.listener.StepListener +import org.springframework.batch.core.step.StepInterruptionPolicy +import org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder +import org.springframework.batch.core.step.item.ChunkOrientedStep +import org.springframework.batch.core.step.skip.SkipPolicy +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.core.retry.RetryListener +import org.springframework.core.retry.RetryPolicy +import org.springframework.core.task.AsyncTaskExecutor +import org.springframework.transaction.PlatformTransactionManager +import org.springframework.transaction.interceptor.TransactionAttribute +import java.util.concurrent.ThreadLocalRandom + +internal class ChunkOrientedStepBuilderDslTest { + @Test + fun testReader() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val itemReader = mockk>() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + reader(itemReader) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.reader(itemReader) } + } + + @Test + fun testProcessor() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val itemProcessor = mockk>() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + processor(itemProcessor) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.processor(itemProcessor) } + } + + @Test + fun testWriter() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val itemWriter = mockk>() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + writer(itemWriter) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.writer(itemWriter) } + } + + @Test + fun testTransactionManager() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val transactionManager = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + transactionManager(transactionManager) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.transactionManager(transactionManager) } + } + + @Test + fun testTransactionAttribute() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val transactionAttribute = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + transactionAttribute(transactionAttribute) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.transactionAttribute(transactionAttribute) } + } + + @Test + fun testStream() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val itemStream = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + stream(itemStream) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.stream(itemStream) } + } + + @Test + fun testStepListener() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val stepListener = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + listener(stepListener) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.listener(stepListener) } + } + + @Test + fun testObjectListener() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + class TestListener + + // when + val testListener = TestListener() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + listener(testListener) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.listener(testListener) } + } + + @Test + fun testInterruptionPolicy() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val interruptionPolicy = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + interruptionPolicy(interruptionPolicy) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.interruptionPolicy(interruptionPolicy) } + } + + @Test + fun testFaultTolerant() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + faultTolerant() + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.faultTolerant() } + } + + @Test + fun testRetryPolicy() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val retryPolicy = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + retryPolicy(retryPolicy) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.retryPolicy(retryPolicy) } + } + + @Test + fun testRetryListener() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val retryListener = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + retryListener(retryListener) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.retryListener(retryListener) } + } + + @Test + fun testRetryWithReified() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + retry() + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.retry(RuntimeException::class.java) } + } + + @Test + fun testRetryWithKClass() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + retry(RuntimeException::class) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.retry(RuntimeException::class.java) } + } + + @Test + fun testRetryLimit() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val retryLimit = ThreadLocalRandom.current().nextLong() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + retryLimit(retryLimit) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.retryLimit(retryLimit) } + } + + @Test + fun testSkipPolicy() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val skipPolicy = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + skipPolicy(skipPolicy) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.skipPolicy(skipPolicy) } + } + + @Test + fun testSkipListener() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val skipListener = mockk>() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + skipListener(skipListener) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.skipListener(skipListener) } + } + + @Test + fun testSkipWithReified() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + skip() + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.skip(RuntimeException::class.java) } + } + + @Test + fun testSkipWithKClass() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + skip(RuntimeException::class) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.skip(RuntimeException::class.java) } + } + + @Test + fun testSkipLimit() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val skipLimit = ThreadLocalRandom.current().nextLong() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + skipLimit(skipLimit) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.skipLimit(skipLimit) } + } + + @Test + fun testTaskExecutor() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val taskExecutor = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + taskExecutor(taskExecutor) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.taskExecutor(taskExecutor) } + } + + @Test + fun testObservationRegistry() { + // given + val chunkOrientedStepBuilder = mockk>(relaxed = true) + + // when + val observationRegistry = mockk() + ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder) + .apply { + observationRegistry(observationRegistry) + }.build() + + // then + verify(exactly = 1) { chunkOrientedStepBuilder.observationRegistry(observationRegistry) } + } + + @Test + fun testBuild() { + // given + val mockStep = mockk>() + val chunkOrientedStepBuilder = + mockk>(relaxed = true) { + every { build() } returns mockStep + } + + // when + val actual = ChunkOrientedStepBuilderDsl(mockk(), chunkOrientedStepBuilder).build() + + // then + assertThat(actual).isEqualTo(mockStep) + } +} From 5d9cd64d202c9a396c2224dec7245edb4d63c0ab Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 5 Jun 2026 14:09:50 +0900 Subject: [PATCH 24/45] Bump Spring Batch to 6.0.4 Signed-off-by: Taeik Lim --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a3e9318..fd1847b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] spring-boot = "4.0.5" -spring-batch = "6.0.3" +spring-batch = "6.0.4" # spring-jdbc version should follow minor version described in 'spring-framework.version' # https://github.com/spring-projects/spring-batch/blob/main/pom.xml spring-jdbc = "7.0.6" From d71fe2ec5a72a1f7fd6bcaac2c101aae05aed3f2 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 8 Jun 2026 18:04:35 +0900 Subject: [PATCH 25/45] Document PartitionStepBuilderDsl scoping design with KDoc Signed-off-by: Taeik Lim --- .../step/PartitionStepBuilderDsl.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt index b516f6a..95bfe78 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDsl.kt @@ -33,6 +33,12 @@ import org.springframework.core.task.TaskExecutor /** * A dsl for [PartitionStepBuilder][org.springframework.batch.core.step.builder.PartitionStepBuilder]. * + * Most methods wrap `PartitionStepBuilder` directly. The `step`, `taskExecutor`, and `gridSize` + * options apply only when a custom `PartitionHandler` is not provided. They configure the default + * `TaskExecutorPartitionHandler` built internally by `PartitionStepBuilder`. To make that dependency + * explicit, these three are exposed via the inner [TaskExecutorPartitionHandlerBuilderDsl] block + * inside `partitionHandler { ... }`, not at the top level. + * * @since 0.1.0 */ @BatchDslMarker @@ -56,8 +62,8 @@ class PartitionStepBuilderDsl internal constructor( } /** - * Build [TaskExecutorPartitionHandler][org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler] - * for [PartitionHandler][org.springframework.batch.core.partition.PartitionHandler]. + * Build the default [TaskExecutorPartitionHandler][org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler] + * via [TaskExecutorPartitionHandlerBuilderDsl]. See class KDoc for the scoping rationale. */ fun partitionHandler(init: TaskExecutorPartitionHandlerBuilderDsl.() -> Unit) { val taskExecutorPartitionHandlerConfigurers = @@ -79,10 +85,10 @@ class PartitionStepBuilderDsl internal constructor( } /** - * Build [SimpleStepExecutionSplitter][org.springframework.batch.core.partition.support.SimpleStepExecutionSplitter] - * for [StepExecutionSplitter][org.springframework.batch.core.partition.StepExecutionSplitter]. - * - * @see [PartitionStepBuilder.partitioner][org.springframework.batch.core.step.builder.PartitionStepBuilder.partitioner] + * Build a [SimpleStepExecutionSplitter][org.springframework.batch.core.partition.support.SimpleStepExecutionSplitter] + * from a worker step name and [Partitioner]. Maps to + * [PartitionStepBuilder.partitioner][org.springframework.batch.core.step.builder.PartitionStepBuilder.partitioner], + * which internally constructs the splitter and sets it. */ fun splitter( stepName: String, @@ -118,7 +124,8 @@ class PartitionStepBuilderDsl internal constructor( } /** - * A dsl for building [TaskExecutorPartitionHandler][org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler]. + * A dsl for building the default [TaskExecutorPartitionHandler][org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler]. + * See [PartitionStepBuilderDsl] KDoc for the scoping rationale. * * @since 0.1.0 */ From 40b1b38e3d9d891ca8fe8e6a3611278a6c994228 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 12 Jun 2026 14:51:46 +0900 Subject: [PATCH 26/45] Bump Spring Boot to 4.0.7 Signed-off-by: Taeik Lim --- gradle/libs.versions.toml | 2 +- .../clear-run-id-incrementer-sample/build.gradle.kts | 2 +- .../delete-meta-data-job-sample/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fd1847b..8234dac 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -spring-boot = "4.0.5" +spring-boot = "4.0.7" spring-batch = "6.0.4" # spring-jdbc version should follow minor version described in 'spring-framework.version' # https://github.com/spring-projects/spring-batch/blob/main/pom.xml diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts b/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts index 18dec13..5f86928 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/build.gradle.kts @@ -27,7 +27,7 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.5") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts b/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts index 18dec13..5f86928 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts +++ b/spring-batch-plus-sample/delete-meta-data-job-sample/build.gradle.kts @@ -27,7 +27,7 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.5") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts index 3ed49be..19d1efb 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/build.gradle.kts @@ -27,7 +27,7 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.5") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } From 5dbd80412f833a06698d7ed8c21a1a08ee579ae6 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 12 Jun 2026 15:39:28 +0900 Subject: [PATCH 27/45] Bump Gradle wrapper to 9.5.1 Signed-off-by: Taeik Lim --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37f853b..5dd3c01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 1a64a34d57bf3ae7d2953faee1f465c2a99ba8a3 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 12 Jun 2026 16:06:37 +0900 Subject: [PATCH 28/45] Migrate Kotlin autoconfigure to Spring Boot 4 Signed-off-by: Taeik Lim --- gradle/libs.versions.toml | 7 ++ .../build.gradle.kts | 3 + .../kotlin/BatchPlusAutoConfigurationIT.kt | 81 +++++++++++++------ .../plus/kotlin/BatchPlusAutoConfiguration.kt | 10 +-- 4 files changed, 72 insertions(+), 29 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8234dac..fd7d5b0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,6 +4,10 @@ spring-batch = "6.0.4" # spring-jdbc version should follow minor version described in 'spring-framework.version' # https://github.com/spring-projects/spring-batch/blob/main/pom.xml spring-jdbc = "7.0.6" +# spring-data-mongodb / mongodb-driver versions should follow what 'spring-batch.version' pins +# https://github.com/spring-projects/spring-batch/blob/main/pom.xml +spring-data-mongodb = "5.0.6" +mongodb-driver = "5.6.5" slf4j = "2.0.17" reactor-core = "3.8.4" findbugs-jsr305 = "3.0.2" @@ -19,6 +23,9 @@ log4j = "2.25.+" [libraries] spring-boot-autoconfigure = { module = "org.springframework.boot:spring-boot-autoconfigure", version.ref = "spring-boot" } +spring-boot-batch-jdbc = { module = "org.springframework.boot:spring-boot-batch-jdbc", version.ref = "spring-boot" } +spring-data-mongodb = { module = "org.springframework.data:spring-data-mongodb", version.ref = "spring-data-mongodb" } +mongodb-driver-sync = { module = "org.mongodb:mongodb-driver-sync", version.ref = "mongodb-driver" } spring-batch-core = { module = "org.springframework.batch:spring-batch-core", version.ref = "spring-batch" } spring-jdbc = { module = "org.springframework:spring-jdbc", version.ref = "spring-jdbc" } slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } diff --git a/spring-boot-autoconfigure-batch-plus-kotlin/build.gradle.kts b/spring-boot-autoconfigure-batch-plus-kotlin/build.gradle.kts index 1e80546..120bf06 100644 --- a/spring-boot-autoconfigure-batch-plus-kotlin/build.gradle.kts +++ b/spring-boot-autoconfigure-batch-plus-kotlin/build.gradle.kts @@ -8,6 +8,7 @@ dependencies { compileOnly(project(":spring-batch-plus-kotlin")) compileOnly(libs.spring.boot.autoconfigure) + compileOnly(libs.spring.boot.batch.jdbc) compileOnly(libs.spring.batch.core) testImplementation(project(":spring-batch-plus-kotlin")) @@ -16,6 +17,8 @@ dependencies { testImplementation(libs.spring.boot.test) testImplementation(libs.spring.batch.core) testImplementation(libs.spring.jdbc) + testImplementation(libs.spring.data.mongodb) testRuntimeOnly(libs.h2) + testRuntimeOnly(libs.mongodb.driver.sync) } diff --git a/spring-boot-autoconfigure-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfigurationIT.kt b/spring-boot-autoconfigure-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfigurationIT.kt index 8979f78..d5efbf1 100644 --- a/spring-boot-autoconfigure-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfigurationIT.kt +++ b/spring-boot-autoconfigure-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfigurationIT.kt @@ -23,6 +23,8 @@ import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.configuration.annotation.EnableMongoJobRepository import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean @@ -30,41 +32,76 @@ import org.springframework.boot.autoconfigure.AutoConfigurations import org.springframework.boot.test.context.assertj.AssertableApplicationContext import org.springframework.boot.test.context.runner.ApplicationContextRunner import org.springframework.context.annotation.Bean +import org.springframework.data.mongodb.MongoDatabaseFactory +import org.springframework.data.mongodb.MongoTransactionManager +import org.springframework.data.mongodb.core.MongoOperations import org.springframework.jdbc.datasource.DataSourceTransactionManager import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager +import java.lang.reflect.Proxy import javax.sql.DataSource private class BatchPlusAutoConfigurationIT { - - private val contextRunner = ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(BatchPlusAutoConfiguration::class.java)) + private val contextRunner = + ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(BatchPlusAutoConfiguration::class.java)) @Test - fun autoConfigure() { - @EnableBatchProcessing( + fun autoConfigureWithJdbcJobRepository() { + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) class BatchConfiguration { - @Bean - fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() + } + + contextRunner + .withUserConfiguration(BatchConfiguration::class.java) + .run { context: AssertableApplicationContext -> + assertThat(context).hasSingleBean(BatchDsl::class.java) + } + } + + @Test + fun autoConfigureWithMongoJobRepository() { + @EnableBatchProcessing + @EnableMongoJobRepository( + mongoOperationsRef = "metadataMongoOperations", + transactionManagerRef = "metadataMongoTransactionManager", + ) + class BatchConfiguration { + @Bean + fun metadataMongoOperations(): MongoOperations = + Proxy.newProxyInstance( + MongoOperations::class.java.classLoader, + arrayOf(MongoOperations::class.java), + ) { _, _, _ -> null } as MongoOperations + + @Bean + fun metadataMongoTransactionManager(): MongoTransactionManager { + val factory = + Proxy.newProxyInstance( + MongoDatabaseFactory::class.java.classLoader, + arrayOf(MongoDatabaseFactory::class.java), + ) { _, _, _ -> null } as MongoDatabaseFactory + return MongoTransactionManager(factory) } } - contextRunner.withUserConfiguration(BatchConfiguration::class.java) + contextRunner + .withUserConfiguration(BatchConfiguration::class.java) .run { context: AssertableApplicationContext -> assertThat(context).hasSingleBean(BatchDsl::class.java) } @@ -72,7 +109,8 @@ private class BatchPlusAutoConfigurationIT { @Test fun autoConfigureShouldNotRegisterWhenAlreadyRegisteredOneExists() { - @EnableBatchProcessing( + @EnableBatchProcessing + @EnableJdbcJobRepository( dataSourceRef = "metadataDataSource", transactionManagerRef = "metadataTransactionManager", ) @@ -81,29 +119,26 @@ private class BatchPlusAutoConfigurationIT { fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl { - return BatchDsl( + ): BatchDsl = + BatchDsl( beanFactory, jobRepository, ) - } @Bean - fun metadataTransactionManager(): TransactionManager { - return DataSourceTransactionManager(metadataDataSource()) - } + fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) @Bean - fun metadataDataSource(): DataSource { - return EmbeddedDatabaseBuilder() + fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("/org/springframework/batch/core/schema-h2.sql") .generateUniqueName(true) .build() - } } - contextRunner.withUserConfiguration(BatchConfiguration::class.java) + contextRunner + .withUserConfiguration(BatchConfiguration::class.java) .run { context: AssertableApplicationContext -> assertThat(context).hasSingleBean(BatchDsl::class.java) } diff --git a/spring-boot-autoconfigure-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfiguration.kt b/spring-boot-autoconfigure-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfiguration.kt index 4ba4056..8ddd9a2 100644 --- a/spring-boot-autoconfigure-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfiguration.kt +++ b/spring-boot-autoconfigure-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/boot/autoconfigure/batch/plus/kotlin/BatchPlusAutoConfiguration.kt @@ -22,9 +22,9 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.BeanFactory import org.springframework.boot.autoconfigure.AutoConfiguration -import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration import org.springframework.boot.autoconfigure.condition.ConditionalOnBean import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean +import org.springframework.boot.batch.jdbc.autoconfigure.BatchJdbcAutoConfiguration import org.springframework.context.annotation.Bean /** @@ -32,19 +32,17 @@ import org.springframework.context.annotation.Bean * * @since 0.1.0 */ -@AutoConfiguration(after = [BatchAutoConfiguration::class]) +@AutoConfiguration(after = [BatchJdbcAutoConfiguration::class]) class BatchPlusAutoConfiguration { - @Bean @ConditionalOnMissingBean @ConditionalOnBean(value = [JobRepository::class]) fun batchDsl( beanFactory: BeanFactory, jobRepository: JobRepository, - ): BatchDsl { - return BatchDsl( + ): BatchDsl = + BatchDsl( beanFactory, jobRepository, ) - } } From de7d0d273080d1e812ae5b907adb4e7e585a3229 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 15 Jun 2026 10:57:42 +0900 Subject: [PATCH 29/45] Migrate Kotlin samples to Spring Boot 4 + Spring Batch 6 imports Signed-off-by: Taeik Lim --- .../build.gradle.kts | 15 ++-- .../sample/clear/SampleApplicationTest.kt | 21 ++--- .../batch/plus/sample/clear/TestJobConfig.kt | 24 ++--- .../clearwithid/SampleApplicationTest.kt | 21 ++--- .../plus/sample/clearwithid/TestJobConfig.kt | 24 ++--- .../build.gradle.kts | 15 ++-- .../deletemedadata/customdryrun/JdbcConfig.kt | 8 +- .../customdryrun/SampleApplicationTest.kt | 32 +++---- .../customdryrun/TestJobConfig.kt | 29 +++---- .../deletemedadata/dryrun/JdbcConfig.kt | 8 +- .../dryrun/SampleApplicationTest.kt | 32 +++---- .../deletemedadata/dryrun/TestJobConfig.kt | 29 +++---- .../deletemedadata/formatter/JdbcConfig.kt | 8 +- .../formatter/SampleApplicationTest.kt | 30 ++++--- .../deletemedadata/formatter/TestJobConfig.kt | 29 +++---- .../deletemedadata/jobname/JdbcConfig.kt | 8 +- .../jobname/SampleApplicationTest.kt | 30 ++++--- .../deletemedadata/jobname/TestJobConfig.kt | 29 +++---- .../parametername/JdbcConfig.kt | 8 +- .../parametername/SampleApplicationTest.kt | 30 ++++--- .../parametername/TestJobConfig.kt | 29 +++---- .../sample/deletemedadata/plain/JdbcConfig.kt | 8 +- .../plain/SampleApplicationTest.kt | 30 ++++--- .../deletemedadata/plain/TestJobConfig.kt | 29 +++---- .../deletemedadata/prefix/JdbcConfig.kt | 8 +- .../prefix/SampleApplicationTest.kt | 42 +++++---- .../deletemedadata/prefix/TestJobConfig.kt | 29 +++---- .../prefixfromvariable/JdbcConfig.kt | 8 +- .../SampleApplicationTest.kt | 42 +++++---- .../prefixfromvariable/TestJobConfig.kt | 30 +++---- .../test/resources/sql/schema-h2-custom.sql | 2 +- .../kotlin-dsl-sample/build.gradle.kts | 15 ++-- .../comparison/after/SampleApplicationTest.kt | 15 ++-- .../sample/comparison/after/TestJobConfig.kt | 57 ++++++------ .../before/SampleApplicationTest.kt | 15 ++-- .../sample/comparison/before/TestJobConfig.kt | 36 ++++---- .../flow/creation/SampleApplicationTest.kt | 15 ++-- .../sample/flow/creation/TestJobConfig.kt | 44 +++++----- .../incrementer/SampleApplicationTest.kt | 20 ++--- .../incrementer/TestJobConfig.kt | 54 ++++++------ .../SampleApplicationTest.kt | 15 ++-- .../listenerannotation/TestJobConfig.kt | 18 ++-- .../listenerobject/SampleApplicationTest.kt | 15 ++-- .../listenerobject/TestJobConfig.kt | 40 ++++----- .../meterregistry/SampleApplicationTest.kt | 15 ++-- .../meterregistry/TestJobConfig.kt | 18 ++-- .../SampleApplicationTest.kt | 15 ++-- .../observationconvention/TestJobConfig.kt | 18 ++-- .../SampleApplicationTest.kt | 15 ++-- .../observationregistry/TestJobConfig.kt | 18 ++-- .../preventrestart/SampleApplicationTest.kt | 17 ++-- .../preventrestart/TestJobConfig.kt | 38 ++++---- .../validator/SampleApplicationTest.kt | 17 ++-- .../configuration/validator/TestJobConfig.kt | 50 +++++------ .../job/creation/SampleApplicationTest.kt | 15 ++-- .../plus/sample/job/creation/TestJobConfig.kt | 22 ++--- .../decider/bean/SampleApplicationTest.kt | 15 ++-- .../job/flow/decider/bean/TestDecider.kt | 11 +-- .../job/flow/decider/bean/TestJobConfig.kt | 32 +++---- .../decider/variable/SampleApplicationTest.kt | 15 ++-- .../flow/decider/variable/TestJobConfig.kt | 39 +++++---- .../flow/plain/bean/SampleApplicationTest.kt | 15 ++-- .../job/flow/flow/plain/bean/TestJobConfig.kt | 44 +++++----- .../flow/plain/init/SampleApplicationTest.kt | 15 ++-- .../job/flow/flow/plain/init/TestJobConfig.kt | 32 +++---- .../plain/variable/SampleApplicationTest.kt | 15 ++-- .../flow/flow/plain/variable/TestJobConfig.kt | 59 +++++++------ .../transition/bean/SampleApplicationTest.kt | 15 ++-- .../flow/transition/bean/TestJobConfig.kt | 49 ++++++----- .../transition/init/SampleApplicationTest.kt | 15 ++-- .../flow/transition/init/TestJobConfig.kt | 50 +++++------ .../variable/SampleApplicationTest.kt | 15 ++-- .../flow/transition/variable/TestJobConfig.kt | 49 ++++++----- .../comparison/after/SampleApplicationTest.kt | 15 ++-- .../step/comparison/after/TestJobConfig.kt | 62 ++++++------- .../before/SampleApplicationTest.kt | 15 ++-- .../step/comparison/before/TestJobConfig.kt | 42 ++++----- .../step/plain/bean/SampleApplicationTest.kt | 15 ++-- .../job/flow/step/plain/bean/TestJobConfig.kt | 47 +++++----- .../step/plain/init/SampleApplicationTest.kt | 15 ++-- .../job/flow/step/plain/init/TestJobConfig.kt | 28 +++--- .../plain/variable/SampleApplicationTest.kt | 15 ++-- .../flow/step/plain/variable/TestJobConfig.kt | 49 ++++++----- .../transition/bean/SampleApplicationTest.kt | 15 ++-- .../step/transition/bean/TestJobConfig.kt | 49 ++++++----- .../transition/init/SampleApplicationTest.kt | 15 ++-- .../step/transition/init/TestJobConfig.kt | 48 +++++----- .../variable/SampleApplicationTest.kt | 15 ++-- .../step/transition/variable/TestJobConfig.kt | 49 ++++++----- .../decider/bean/SampleApplicationTest.kt | 15 ++-- .../transition/decider/bean/TestJobConfig.kt | 79 +++++++++-------- .../decider/variable/SampleApplicationTest.kt | 15 ++-- .../decider/variable/TestJobConfig.kt | 79 +++++++++-------- .../finish/end/SampleApplicationTest.kt | 15 ++-- .../transition/finish/end/TestJobConfig.kt | 45 +++++----- .../finish/fail/SampleApplicationTest.kt | 15 ++-- .../transition/finish/fail/TestJobConfig.kt | 35 ++++---- .../finish/stop/SampleApplicationTest.kt | 15 ++-- .../transition/finish/stop/TestJobConfig.kt | 35 ++++---- .../flow/bean/SampleApplicationTest.kt | 15 ++-- .../transition/flow/bean/TestJobConfig.kt | 58 +++++++------ .../flow/init/SampleApplicationTest.kt | 15 ++-- .../transition/flow/init/TestJobConfig.kt | 51 +++++------ .../flow/nested/SampleApplicationTest.kt | 15 ++-- .../transition/flow/nested/TestJobConfig.kt | 76 ++++++++-------- .../flow/variable/SampleApplicationTest.kt | 15 ++-- .../transition/flow/variable/TestJobConfig.kt | 58 +++++++------ .../step/bean/SampleApplicationTest.kt | 15 ++-- .../transition/step/bean/TestJobConfig.kt | 56 ++++++------ .../step/init/SampleApplicationTest.kt | 15 ++-- .../transition/step/init/TestJobConfig.kt | 49 ++++++----- .../step/nested/SampleApplicationTest.kt | 15 ++-- .../transition/step/nested/TestJobConfig.kt | 74 ++++++++-------- .../step/variable/SampleApplicationTest.kt | 15 ++-- .../transition/step/variable/TestJobConfig.kt | 56 ++++++------ .../decider/SampleApplicationTest.kt | 17 ++-- .../stopandrestart/decider/TestJobConfig.kt | 58 +++++++------ .../flow/SampleApplicationTest.kt | 17 ++-- .../stopandrestart/flow/TestJobConfig.kt | 41 ++++----- .../step/SampleApplicationTest.kt | 17 ++-- .../stopandrestart/step/TestJobConfig.kt | 37 ++++---- .../job/split/bean/SampleApplicationTest.kt | 15 ++-- .../sample/job/split/bean/TestJobConfig.kt | 53 +++++------ .../job/split/init/SampleApplicationTest.kt | 15 ++-- .../sample/job/split/init/TestJobConfig.kt | 36 ++++---- .../split/variable/SampleApplicationTest.kt | 15 ++-- .../job/split/variable/TestJobConfig.kt | 53 +++++------ .../chunkpolicy/SampleApplicationTest.kt | 15 ++-- .../chunkpolicy/TestJobConfig.kt | 48 +++++----- .../chunksize/SampleApplicationTest.kt | 15 ++-- .../chunksize/TestJobConfig.kt | 46 +++++----- .../chunklistener/SampleApplicationTest.kt | 15 ++-- .../chunklistener/TestJobConfig.kt | 48 +++++----- .../mixed/SampleApplicationTest.kt | 15 ++-- .../annotationlistener/mixed/TestJobConfig.kt | 55 ++++++------ .../SampleApplicationTest.kt | 15 ++-- .../processorlistener/TestJobConfig.kt | 58 +++++++------ .../readerlistener/SampleApplicationTest.kt | 15 ++-- .../readerlistener/TestJobConfig.kt | 48 +++++----- .../writerlistener/SampleApplicationTest.kt | 15 ++-- .../writerlistener/TestJobConfig.kt | 55 ++++++------ .../chunklistener/SampleApplicationTest.kt | 15 ++-- .../config/chunklistener/TestJobConfig.kt | 72 ++++++++------- .../exceptionhandler/SampleApplicationTest.kt | 15 ++-- .../config/exceptionhandler/TestJobConfig.kt | 56 ++++++------ .../config/executor/SampleApplicationTest.kt | 15 ++-- .../config/executor/TestJobConfig.kt | 43 ++++----- .../SampleApplicationTest.kt | 15 ++-- .../config/processorlistener/TestJobConfig.kt | 78 +++++++++-------- .../readerlistener/SampleApplicationTest.kt | 15 ++-- .../config/readerlistener/TestJobConfig.kt | 72 ++++++++------- .../stepoperation/SampleApplicationTest.kt | 15 ++-- .../config/stepoperation/TestJobConfig.kt | 63 +++++++------- .../config/stream/SampleApplicationTest.kt | 15 ++-- .../config/stream/TestJobConfig.kt | 76 ++++++++-------- .../SampleApplicationTest.kt | 15 ++-- .../transactionattribute/TestJobConfig.kt | 47 +++++----- .../writerlistener/SampleApplicationTest.kt | 15 ++-- .../config/writerlistener/TestJobConfig.kt | 77 ++++++++-------- .../backoffpolicy/SampleApplicationTest.kt | 15 ++-- .../backoffpolicy/TestJobConfig.kt | 55 ++++++------ .../keygenerator/SampleApplicationTest.kt | 15 ++-- .../keygenerator/TestJobConfig.kt | 61 +++++++------ .../noretry/SampleApplicationTest.kt | 15 ++-- .../faulttolerant/noretry/TestJobConfig.kt | 39 ++++----- .../noskip/SampleApplicationTest.kt | 15 ++-- .../faulttolerant/noskip/TestJobConfig.kt | 44 +++++----- .../processornontx/SampleApplicationTest.kt | 15 ++-- .../processornontx/TestJobConfig.kt | 39 ++++----- .../retry/SampleApplicationTest.kt | 15 ++-- .../faulttolerant/retry/TestJobConfig.kt | 37 ++++---- .../SampleApplicationTest.kt | 15 ++-- .../retrycontextcache/TestJobConfig.kt | 53 ++++++----- .../retrylistener/SampleApplicationTest.kt | 15 ++-- .../retrylistener/TestJobConfig.kt | 87 +++++++++---------- .../retrypolicy/SampleApplicationTest.kt | 15 ++-- .../retrypolicy/TestJobConfig.kt | 37 ++++---- .../rollback/SampleApplicationTest.kt | 15 ++-- .../faulttolerant/rollback/TestJobConfig.kt | 40 ++++----- .../skip/SampleApplicationTest.kt | 15 ++-- .../faulttolerant/skip/TestJobConfig.kt | 42 +++++---- .../skiplistener/SampleApplicationTest.kt | 15 ++-- .../skiplistener/TestJobConfig.kt | 72 +++++++-------- .../SampleApplicationTest.kt | 15 ++-- .../skiplistenerannotation/TestJobConfig.kt | 55 ++++++------ .../skippolicy/SampleApplicationTest.kt | 15 ++-- .../faulttolerant/skippolicy/TestJobConfig.kt | 50 +++++------ .../repeatoperation/SampleApplicationTest.kt | 15 ++-- .../repeatoperation/TestJobConfig.kt | 57 ++++++------ .../SampleApplicationTest.kt | 19 ++-- .../allowstartifcomplete/TestJobConfig.kt | 46 +++++----- .../SampleApplicationTest.kt | 15 ++-- .../listenerannotation/TestJobConfig.kt | 18 ++-- .../listenerobject/SampleApplicationTest.kt | 15 ++-- .../listenerobject/TestJobConfig.kt | 42 ++++----- .../meterregistry/SampleApplicationTest.kt | 15 ++-- .../meterregistry/TestJobConfig.kt | 18 ++-- .../SampleApplicationTest.kt | 15 ++-- .../observationconvention/TestJobConfig.kt | 18 ++-- .../SampleApplicationTest.kt | 15 ++-- .../observationregistry/TestJobConfig.kt | 18 ++-- .../startlimit/SampleApplicationTest.kt | 19 ++-- .../configuration/startlimit/TestJobConfig.kt | 34 ++++---- .../step/creation/SampleApplicationTest.kt | 15 ++-- .../sample/step/creation/TestJobConfig.kt | 56 ++++++------ .../flowstep/bean/SampleApplicationTest.kt | 15 ++-- .../step/flowstep/bean/TestJobConfig.kt | 27 +++--- .../flowstep/init/SampleApplicationTest.kt | 15 ++-- .../step/flowstep/init/TestJobConfig.kt | 20 ++--- .../variable/SampleApplicationTest.kt | 15 ++-- .../step/flowstep/variable/TestJobConfig.kt | 27 +++--- .../jobstep/bean/SampleApplicationTest.kt | 15 ++-- .../sample/step/jobstep/bean/TestJobConfig.kt | 27 +++--- .../config/extractor/SampleApplicationTest.kt | 17 ++-- .../jobstep/config/extractor/TestJobConfig.kt | 57 ++++++------ .../config/launcher/SampleApplicationTest.kt | 15 ++-- .../jobstep/config/launcher/TestJobConfig.kt | 54 ++++++------ .../jobstep/variable/SampleApplicationTest.kt | 15 ++-- .../step/jobstep/variable/TestJobConfig.kt | 27 +++--- .../aggregator/SampleApplicationTest.kt | 15 ++-- .../partitionstep/aggregator/TestJobConfig.kt | 59 ++++++------- .../direct/SampleApplicationTest.kt | 15 ++-- .../partitionhandler/direct/TestJobConfig.kt | 61 ++++++------- .../inner/SampleApplicationTest.kt | 15 ++-- .../partitionhandler/inner/TestJobConfig.kt | 59 ++++++------- .../splitter/direct/SampleApplicationTest.kt | 15 ++-- .../splitter/direct/TestJobConfig.kt | 81 +++++++++-------- .../splitter/inner/SampleApplicationTest.kt | 15 ++-- .../splitter/inner/TestJobConfig.kt | 59 ++++++------- .../taskletstep/bean/SampleApplicationTest.kt | 17 ++-- .../step/taskletstep/bean/TestJobConfig.kt | 25 +++--- .../exceptionhandler/SampleApplicationTest.kt | 15 ++-- .../config/exceptionhandler/TestJobConfig.kt | 45 +++++----- .../config/executor/SampleApplicationTest.kt | 15 ++-- .../config/executor/TestJobConfig.kt | 32 +++---- .../SampleApplicationTest.kt | 15 ++-- .../listenerannotation/TestJobConfig.kt | 27 +++--- .../listenerobject/SampleApplicationTest.kt | 15 ++-- .../config/listenerobject/TestJobConfig.kt | 51 +++++------ .../stepoperation/SampleApplicationTest.kt | 15 ++-- .../config/stepoperation/TestJobConfig.kt | 49 ++++++----- .../config/stream/SampleApplicationTest.kt | 15 ++-- .../config/stream/TestJobConfig.kt | 55 ++++++------ .../SampleApplicationTest.kt | 15 ++-- .../transactionattribute/TestJobConfig.kt | 39 +++++---- .../variable/SampleApplicationTest.kt | 15 ++-- .../taskletstep/variable/TestJobConfig.kt | 25 +++--- .../build.gradle.kts | 15 ++-- .../flux/callback/SampleApplicationTest.kt | 17 ++-- .../sample/flux/callback/SampleTasklet.kt | 8 +- .../sample/flux/callback/TestJobConfig.kt | 22 +++-- .../readerprocessor/SampleApplicationTest.kt | 17 ++-- .../flux/readerprocessor/SampleTasklet.kt | 6 +- .../flux/readerprocessor/TestJobConfig.kt | 21 +++-- .../SampleApplicationTest.kt | 17 ++-- .../readerprocessorwriter/SampleTasklet.kt | 8 +- .../readerprocessorwriter/TestJobConfig.kt | 21 +++-- .../readerwriter/SampleApplicationTest.kt | 17 ++-- .../sample/flux/readerwriter/SampleTasklet.kt | 4 +- .../sample/flux/readerwriter/TestJobConfig.kt | 20 ++--- .../callback/SampleApplicationTest.kt | 17 ++-- .../sample/iterable/callback/SampleTasklet.kt | 16 ++-- .../sample/iterable/callback/TestJobConfig.kt | 22 +++-- .../readerprocessor/SampleApplicationTest.kt | 17 ++-- .../iterable/readerprocessor/SampleTasklet.kt | 14 +-- .../iterable/readerprocessor/TestJobConfig.kt | 21 +++-- .../SampleApplicationTest.kt | 17 ++-- .../readerprocessorwriter/SampleTasklet.kt | 16 ++-- .../readerprocessorwriter/TestJobConfig.kt | 21 +++-- .../readerwriter/SampleApplicationTest.kt | 17 ++-- .../iterable/readerwriter/SampleTasklet.kt | 12 +-- .../iterable/readerwriter/TestJobConfig.kt | 20 ++--- .../callback/SampleApplicationTest.kt | 17 ++-- .../sample/iterator/callback/SampleTasklet.kt | 16 ++-- .../sample/iterator/callback/TestJobConfig.kt | 22 +++-- .../readerprocessor/SampleApplicationTest.kt | 17 ++-- .../iterator/readerprocessor/SampleTasklet.kt | 14 +-- .../iterator/readerprocessor/TestJobConfig.kt | 21 +++-- .../SampleApplicationTest.kt | 17 ++-- .../readerprocessorwriter/SampleTasklet.kt | 16 ++-- .../readerprocessorwriter/TestJobConfig.kt | 21 +++-- .../readerwriter/SampleApplicationTest.kt | 17 ++-- .../iterator/readerwriter/SampleTasklet.kt | 12 +-- .../iterator/readerwriter/TestJobConfig.kt | 20 ++--- .../simple/callback/SampleApplicationTest.kt | 17 ++-- .../sample/simple/callback/SampleTasklet.kt | 13 ++- .../sample/simple/callback/TestJobConfig.kt | 22 +++-- .../readerprocessor/SampleApplicationTest.kt | 17 ++-- .../simple/readerprocessor/SampleTasklet.kt | 9 +- .../simple/readerprocessor/TestJobConfig.kt | 21 +++-- .../SampleApplicationTest.kt | 17 ++-- .../readerprocessorwriter/SampleTasklet.kt | 11 +-- .../readerprocessorwriter/TestJobConfig.kt | 21 +++-- .../readerwriter/SampleApplicationTest.kt | 17 ++-- .../simple/readerwriter/SampleTasklet.kt | 7 +- .../simple/readerwriter/TestJobConfig.kt | 20 ++--- 296 files changed, 4104 insertions(+), 4082 deletions(-) diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/build.gradle.kts b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/build.gradle.kts index db01bfa..6a4c7cb 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/build.gradle.kts +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + buildscript { repositories { gradlePluginPortal() // give accees to gradle community plugins @@ -17,12 +19,9 @@ repositories { kotlin { jvmToolchain(17) -} - -tasks.withType { - kotlinOptions { + compilerOptions { freeCompilerArgs = listOf("-Xjsr305=strict") // enable jsr305 null-safety in kotlin - jvmTarget = "17" + jvmTarget = JvmTarget.JVM_17 } } @@ -33,14 +32,14 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus-kotlin")) - runtimeOnly("com.h2database:h2:2.1.214") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.kt b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.kt index a49002c..3c30b57 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/SampleApplicationTest.kt @@ -20,10 +20,8 @@ package com.navercorp.spring.batch.plus.sample.clear import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.explore.JobExplorer -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -33,20 +31,11 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() - - val jobExplorer = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val firstJobParameters = JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters() - val firstJobExecution = jobLauncher.run(job, firstJobParameters) - - val secondJobParameters = JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters() - val secondJobExecution = jobLauncher.run(job, secondJobParameters) + val firstJobExecution = jobOperator.startNextInstance(job) + val secondJobExecution = jobOperator.startNextInstance(job) // first assert(BatchStatus.COMPLETED.equals(firstJobExecution.status)) diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.kt b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.kt index 23801c2..b69c55e 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.kt +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/TestJobConfig.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.clear import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,17 +31,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - incrementer(ClearRunIdIncrementer.create()) - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + incrementer(ClearRunIdIncrementer.create()) + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.kt b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.kt index 95f52c3..699191c 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/SampleApplicationTest.kt @@ -20,10 +20,8 @@ package com.navercorp.spring.batch.plus.sample.clearwithid import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.explore.JobExplorer -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -33,20 +31,11 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() - - val jobExplorer = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val firstJobParameters = JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters() - val firstJobExecution = jobLauncher.run(job, firstJobParameters) - - val secondJobParameters = JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters() - val secondJobExecution = jobLauncher.run(job, secondJobParameters) + val firstJobExecution = jobOperator.startNextInstance(job) + val secondJobExecution = jobOperator.startNextInstance(job) // first assert(BatchStatus.COMPLETED.equals(firstJobExecution.status)) diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.kt b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.kt index b82c442..d5c3863 100644 --- a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.kt +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/TestJobConfig.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.clearwithid import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,17 +31,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - incrementer(ClearRunIdIncrementer.create("testId")) - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + incrementer(ClearRunIdIncrementer.create("testId")) + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/build.gradle.kts b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/build.gradle.kts index db01bfa..6a4c7cb 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/build.gradle.kts +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + buildscript { repositories { gradlePluginPortal() // give accees to gradle community plugins @@ -17,12 +19,9 @@ repositories { kotlin { jvmToolchain(17) -} - -tasks.withType { - kotlinOptions { + compilerOptions { freeCompilerArgs = listOf("-Xjsr305=strict") // enable jsr305 null-safety in kotlin - jvmTarget = "17" + jvmTarget = JvmTarget.JVM_17 } } @@ -33,14 +32,14 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus-kotlin")) - runtimeOnly("com.h2database:h2:2.1.214") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/JdbcConfig.kt index 50256cd..5792a67 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.customdryrun -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,14 +27,12 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/SampleApplicationTest.kt index 0e49f00..46f766e 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.customdryrun import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication @@ -34,19 +34,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -55,11 +56,12 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .addString("customDryRunParam", "true") // set dryRun to 'true' - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .addString("customDryRunParam", "true") // set dryRun to 'true' + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances should not be removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/TestJobConfig.kt index 4017317..58ff219 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/customdryrun/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.customdryrun import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,27 +34,26 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .dryRunParameterName("customDryRunParam") .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/JdbcConfig.kt index ee15401..46f857b 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.dryrun -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,14 +27,12 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/SampleApplicationTest.kt index db49965..3fe97dd 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.dryrun import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication @@ -34,19 +34,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -55,11 +56,12 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .addString("dryRun", "true") // set dryRun to 'true' - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .addString("dryRun", "true") // set dryRun to 'true' + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances should not be removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/TestJobConfig.kt index dbb0cb2..9fa19ed 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/dryrun/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.dryrun import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,26 +34,25 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/JdbcConfig.kt index 1cdb3fc..dce2c00 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.formatter -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,14 +27,12 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/SampleApplicationTest.kt index 777c205..79bade0 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.formatter import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication @@ -34,19 +34,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -55,10 +56,11 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances are removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/TestJobConfig.kt index 80071b5..adfc0e8 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/formatter/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.formatter import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,27 +35,26 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .baseDateFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd")) .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/JdbcConfig.kt index b7e582b..b49491c 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.jobname -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,14 +27,12 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/SampleApplicationTest.kt index 0a57c76..1740566 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.jobname import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication @@ -34,19 +34,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -55,10 +56,11 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances are removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/TestJobConfig.kt index 6734b7f..f176548 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/jobname/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.jobname import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,26 +34,25 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/JdbcConfig.kt index 159bd66..624cef2 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.parametername -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,14 +27,12 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/SampleApplicationTest.kt index 235483b..303dcf1 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.parametername import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication @@ -34,19 +34,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -55,10 +56,11 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("base", now.format(formatter)) // custom naming - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("base", now.format(formatter)) // custom naming + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances are removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/TestJobConfig.kt index 2d5309f..8f62c86 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/parametername/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.parametername import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,27 +34,26 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .baseDateParameterName("base") .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/JdbcConfig.kt index dae6622..d5d92d5 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.plain -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,14 +27,12 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/SampleApplicationTest.kt index 6eeda43..270151f 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.plain import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication @@ -34,19 +34,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -55,10 +56,11 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("deleteMetadataJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances are removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/TestJobConfig.kt index a21c0f7..cf95dea 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/plain/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.plain import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,25 +34,24 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun deleteMetadataJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/JdbcConfig.kt index 8442778..0188302 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.prefix -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -27,15 +27,13 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("classpath:sql/schema-h2-custom.sql") .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/SampleApplicationTest.kt index 9de7b78..617dd67 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.prefix import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.SpringApplication @@ -35,26 +35,29 @@ open class SampleApplicationTest { @Test fun run() { // launch with custom prefix - val application = SpringApplication(SampleApplicationTest::class.java).apply { - val properties = Properties().apply { - this["spring.batch.jdbc.table-prefix"] = "CUSTOM_" + val application = + SpringApplication(SampleApplicationTest::class.java).apply { + val properties = + Properties().apply { + this["spring.batch.jdbc.table-prefix"] = "CUSTOM_" + } + setDefaultProperties(properties) } - setDefaultProperties(properties) - } val applicationContext = application.run() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -63,10 +66,11 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances are removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/TestJobConfig.kt index 23a9530..395fc31 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefix/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.prefix import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,27 +34,26 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - ): Job { - return DeleteMetadataJobBuilder(jobRepository, dataSource) + ): Job = + DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .tablePrefix("CUSTOM_") .build() - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/JdbcConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/JdbcConfig.kt index b08910a..f091ae0 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/JdbcConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/JdbcConfig.kt @@ -18,7 +18,7 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.prefixfromvariable -import org.springframework.boot.autoconfigure.batch.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder @@ -28,16 +28,14 @@ import javax.sql.DataSource @Configuration open class JdbcConfig { - @BatchDataSource @Bean - open fun dataSource(): DataSource { - return EmbeddedDatabaseBuilder() + open fun dataSource(): DataSource = + EmbeddedDatabaseBuilder() .setName(UUID.randomUUID().toString()) .setType(EmbeddedDatabaseType.H2) .addScript("classpath:sql/schema-h2-custom.sql") .ignoreFailedDrops(true) .generateUniqueName(true) .build() - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/SampleApplicationTest.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/SampleApplicationTest.kt index 3d65d62..545e67d 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.prefixfromvariable import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.getBean import org.springframework.boot.SpringApplication @@ -35,26 +35,29 @@ open class SampleApplicationTest { @Test fun run() { // launch with custom prefix - val application = SpringApplication(SampleApplicationTest::class.java).apply { - val properties = Properties().apply { - this["spring.batch.jdbc.table-prefix"] = "CUSTOM_" + val application = + SpringApplication(SampleApplicationTest::class.java).apply { + val properties = + Properties().apply { + this["spring.batch.jdbc.table-prefix"] = "CUSTOM_" + } + setDefaultProperties(properties) } - setDefaultProperties(properties) - } val applicationContext = application.run() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val jobRepository = applicationContext.getBean() // prepare job instances val testJob = applicationContext.getBean("testJob") - val testJobParameterList = (0L..250L).map { - JobParametersBuilder() - .addLong("longValue", it) - .toJobParameters() - } + val testJobParameterList = + (0L..250L).map { + JobParametersBuilder() + .addLong("longValue", it) + .toJobParameters() + } for (testJobParameters in testJobParameterList) { // change create time date for test - val jobExecution = jobLauncher.run(testJob, testJobParameters) + val jobExecution = jobOperator.start(testJob, testJobParameters) jobExecution.createTime = jobExecution.createTime.minusDays(1) jobRepository.update(jobExecution) } @@ -63,10 +66,11 @@ open class SampleApplicationTest { val removeJob = applicationContext.getBean("removeJob") val now = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd") - val jobParameters = JobParametersBuilder() - .addString("baseDate", now.format(formatter)) - .toJobParameters() - jobLauncher.run(removeJob, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("baseDate", now.format(formatter)) + .toJobParameters() + jobOperator.start(removeJob, jobParameters) // all instances are removed for (testJobParameters in testJobParameterList) { diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/TestJobConfig.kt b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/TestJobConfig.kt index d2e40ac..ccfe048 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/TestJobConfig.kt +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/deletemedadata/prefixfromvariable/TestJobConfig.kt @@ -20,11 +20,11 @@ package com.navercorp.spring.batch.plus.sample.deletemedadata.prefixfromvariable import com.navercorp.spring.batch.plus.job.metadata.DeleteMetadataJobBuilder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.boot.autoconfigure.batch.BatchDataSource -import org.springframework.boot.autoconfigure.batch.BatchProperties +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource +import org.springframework.boot.batch.jdbc.autoconfigure.BatchJdbcProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,14 +35,13 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun removeJob( @BatchDataSource dataSource: DataSource, jobRepository: JobRepository, - properties: BatchProperties, + properties: BatchJdbcProperties, ): Job { - val tablePrefix = properties.jdbc.tablePrefix + val tablePrefix = properties.tablePrefix!! return DeleteMetadataJobBuilder(jobRepository, dataSource) .name("removeJob") .tablePrefix(tablePrefix) @@ -50,14 +49,15 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/resources/sql/schema-h2-custom.sql b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/resources/sql/schema-h2-custom.sql index 718302f..a65cc0f 100644 --- a/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/resources/sql/schema-h2-custom.sql +++ b/spring-batch-plus-sample/delete-meta-data-job-kotlin-sample/src/test/resources/sql/schema-h2-custom.sql @@ -73,4 +73,4 @@ CREATE TABLE CUSTOM_JOB_EXECUTION_CONTEXT ( CREATE SEQUENCE CUSTOM_STEP_EXECUTION_SEQ; CREATE SEQUENCE CUSTOM_JOB_EXECUTION_SEQ; -CREATE SEQUENCE CUSTOM_JOB_SEQ; +CREATE SEQUENCE CUSTOM_JOB_INSTANCE_SEQ; diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/build.gradle.kts b/spring-batch-plus-sample/kotlin-dsl-sample/build.gradle.kts index db01bfa..6a4c7cb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/build.gradle.kts +++ b/spring-batch-plus-sample/kotlin-dsl-sample/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + buildscript { repositories { gradlePluginPortal() // give accees to gradle community plugins @@ -17,12 +19,9 @@ repositories { kotlin { jvmToolchain(17) -} - -tasks.withType { - kotlinOptions { + compilerOptions { freeCompilerArgs = listOf("-Xjsr305=strict") // enable jsr305 null-safety in kotlin - jvmTarget = "17" + jvmTarget = JvmTarget.JVM_17 } } @@ -33,14 +32,14 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus-kotlin")) - runtimeOnly("com.h2database:h2:2.1.214") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/SampleApplicationTest.kt index 645cc00..d14d781 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.comparison.after import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/TestJobConfig.kt index 947e21b..bb8f911 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/after/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.comparison.after import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,42 +31,45 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step(testStep2()) { - on("COMPLETED") { - step(testStep3()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) } - on("FAILED") { - step(testStep4()) + step(testStep2()) { + on("COMPLETED") { + step(testStep3()) + } + on("FAILED") { + step(testStep4()) + } } } } - } @Bean - open fun testStep2(): Step = batch { - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep2(): Step = + batch { + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testStep3(): Step = batch { - step("testStep3") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep3(): Step = + batch { + step("testStep3") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testStep4(): Step = batch { - step("testStep4") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep4(): Step = + batch { + step("testStep4") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/SampleApplicationTest.kt index dc31d53..499d97b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.comparison.before import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/TestJobConfig.kt index 2335002..a8a8fb2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/comparison/before/TestJobConfig.kt @@ -18,12 +18,12 @@ package com.navercorp.spring.batch.plus.sample.comparison.before -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,41 +33,37 @@ open class TestJobConfig( private val jobRepository: JobRepository, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job { - return JobBuilder("testJob", jobRepository) + open fun testJob(): Job = + JobBuilder("testJob", jobRepository) .start( StepBuilder("testStep1", jobRepository) .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) .build(), - ) - .next(testStep2()) - .on("COMPLETED").to(testStep3()) + ).next(testStep2()) + .on("COMPLETED") + .to(testStep3()) .from(testStep2()) - .on("FAILED").to(testStep4()) + .on("FAILED") + .to(testStep4()) .end() .build() - } @Bean - open fun testStep2(): Step { - return StepBuilder("testStep2", jobRepository) + open fun testStep2(): Step = + StepBuilder("testStep2", jobRepository) .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) .build() - } @Bean - open fun testStep3(): Step { - return StepBuilder("testStep3", jobRepository) + open fun testStep3(): Step = + StepBuilder("testStep3", jobRepository) .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) .build() - } @Bean - open fun testStep4(): Step { - return StepBuilder("testStep4", jobRepository) + open fun testStep4(): Step = + StepBuilder("testStep4", jobRepository) .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) .build() - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/SampleApplicationTest.kt index e6355d9..6eebbd6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.flow.creation import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.STOPPED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/TestJobConfig.kt index 17f8933..3d3ae5a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flow/creation/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.flow.creation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,32 +32,34 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - flow(testFlow()) + open fun testJob(): Job = + batch { + job("testJob") { + flow(testFlow()) + } } - } @Bean - open fun testFlow(): Flow = batch { - flow("testFlow") { - step(testStep()) { - on("COMPLETED") { - stop() - } - on("*") { - fail() + open fun testFlow(): Flow = + batch { + flow("testFlow") { + step(testStep()) { + on("COMPLETED") { + stop() + } + on("*") { + fail() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/SampleApplicationTest.kt index 33c6682..3abb271 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/SampleApplicationTest.kt @@ -20,10 +20,8 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.incrementer import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.explore.JobExplorer -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -33,19 +31,11 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() - val jobExplorer = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val firstJobParameters = JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters() - val firstJobExecution = jobLauncher.run(job, firstJobParameters) - - val secondJobParameters = JobParametersBuilder(jobExplorer) - .getNextJobParameters(job) - .toJobParameters() - val secondJobExecution = jobLauncher.run(job, secondJobParameters) + val firstJobExecution = jobOperator.startNextInstance(job) + val secondJobExecution = jobOperator.startNextInstance(job) // first assert(BatchStatus.COMPLETED == firstJobExecution.status) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/TestJobConfig.kt index 6d743ab..9cb0bd0 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/incrementer/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.incrementer import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParameters -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,30 +32,30 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - incrementer { - val nextValue = it?.getLong("param")?.plus(1L) ?: 0L - JobParametersBuilder(it ?: JobParameters()) - .addLong("param", nextValue) - .toJobParameters() - } - // same as - // incrementer( - // object : JobParametersIncrementer { - // override fun getNext(parameters: JobParameters?): JobParameters { - // val nextValue = parameters?.getLong("param")?.plus(1L) ?: 0L - // return JobParametersBuilder(parameters ?: JobParameters()) - // .addLong("param", nextValue) - // .toJobParameters() - // } - // } - // ) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + incrementer { + val nextValue = it?.getLong("param")?.plus(1L) ?: 0L + JobParametersBuilder(it ?: JobParameters()) + .addLong("param", nextValue) + .toJobParameters() + } + // same as + // incrementer( + // object : JobParametersIncrementer { + // override fun getNext(parameters: JobParameters?): JobParameters { + // val nextValue = parameters?.getLong("param")?.plus(1L) ?: 0L + // return JobParametersBuilder(parameters ?: JobParameters()) + // .addLong("param", nextValue) + // .toJobParameters() + // } + // } + // ) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/SampleApplicationTest.kt index b63fa7e..fb73261 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.listenerannotat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/TestJobConfig.kt index 08d8b47..0a87797 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerannotation/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.listenerannotation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterJob import org.springframework.batch.core.annotation.BeforeJob -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,7 +32,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeJob fun beforeJob() { @@ -46,12 +45,13 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - listener(TestListener()) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + listener(TestListener()) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/SampleApplicationTest.kt index 0e11df6..aff90f5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.listenerobject import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/TestJobConfig.kt index 1fb1565..2099e31 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/listenerobject/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.listenerobject import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobExecution -import org.springframework.batch.core.JobExecutionListener -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.listener.JobExecutionListener +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,24 +32,24 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - listener( - object : JobExecutionListener { - override fun beforeJob(jobExecution: JobExecution) { - println("before $jobExecution") - } + open fun testJob(): Job = + batch { + job("testJob") { + listener( + object : JobExecutionListener { + override fun beforeJob(jobExecution: JobExecution) { + println("before $jobExecution") + } - override fun afterJob(jobExecution: JobExecution) { - println("after $jobExecution") - } - }, - ) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + override fun afterJob(jobExecution: JobExecution) { + println("after $jobExecution") + } + }, + ) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt index 1446989..7a89075 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.meterregistry import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt index 1ba0a0a..b8e47c5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.meterregistry import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import io.micrometer.core.instrument.simple.SimpleMeterRegistry -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,14 +31,14 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - meterRegistry(SimpleMeterRegistry()) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + meterRegistry(SimpleMeterRegistry()) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt index c0ea049..d2d385f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.observationconv import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt index 6696a3d..4fe8da1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.observationconvention import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.observability.DefaultBatchJobObservationConvention -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,14 +31,14 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - observationConvention(DefaultBatchJobObservationConvention()) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + observationConvention(DefaultBatchJobObservationConvention()) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/SampleApplicationTest.kt index 9c00453..3a3fd6e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.observationregi import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/TestJobConfig.kt index 63f1646..585b1e9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationregistry/TestJobConfig.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.observationregi import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import io.micrometer.observation.ObservationRegistry -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,14 +31,14 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - observationRegistry(ObservationRegistry.create()) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + observationRegistry(ObservationRegistry.create()) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/SampleApplicationTest.kt index 3c17ec5..1f50138 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.preventrestart import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,19 +32,20 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .toJobParameters() - val firstJobExecution = jobLauncher.run(job, jobParameters) + val firstJobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == firstJobExecution.status) println(firstJobExecution) try { - jobLauncher.run(job, jobParameters) + jobOperator.start(job, jobParameters) assert(false) { "It must throw exception" } } catch (e: Exception) { // JobInstance already exists and is not restartable diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/TestJobConfig.kt index b9d1231..e23ddb4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/preventrestart/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.preventrestart import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,25 +30,25 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - var isFirst = true + open fun testJob(): Job = + batch { + var isFirst = true - job("testJob") { - preventRestart() - step("testStep") { - tasklet( - { _, _ -> - if (isFirst) { - isFirst = false - throw RuntimeException("First try should be failed") - } - RepeatStatus.FINISHED - }, - transactionManager, - ) + job("testJob") { + preventRestart() + step("testStep") { + tasklet( + { _, _ -> + if (isFirst) { + isFirst = false + throw RuntimeException("First try should be failed") + } + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/SampleApplicationTest.kt index 2899a55..c699664 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/SampleApplicationTest.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.validator import org.junit.jupiter.api.Test -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -31,14 +31,15 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .addLong("param", -1L) - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .addLong("param", -1L) + .toJobParameters() try { - jobLauncher.run(job, jobParameters) + jobOperator.start(job, jobParameters) assert(false) { "It must throw exception" } } catch (e: Exception) { // param is null or less than 0 diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/TestJobConfig.kt index e66f545..0e423f1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/validator/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.configuration.validator import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersInvalidException -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.InvalidJobParametersException +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,30 +31,30 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - validator { - val value = it?.getLong("param") - if (value == null || value < 0L) { - throw JobParametersInvalidException("param is null or less than 0") + open fun testJob(): Job = + batch { + job("testJob") { + validator { + val value = it?.getLong("param") + if (value == null || value < 0L) { + throw InvalidJobParametersException("param is null or less than 0") + } + } + // same as + // validator( + // object : JobParametersValidator { + // override fun validate(parameters: JobParameters?) { + // val value = parameters?.getLong("param") + // if (value == null || value < 0L) { + // throw InvalidJobParametersException("param is < 0") + // } + // } + // } + // ) + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) } - } - // same as - // validator( - // object : JobParametersValidator { - // override fun validate(parameters: JobParameters?) { - // val value = parameters?.getLong("param") - // if (value == null || value < 0L) { - // throw JobParametersInvalidException("param is < 0") - // } - // } - // } - // ) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/SampleApplicationTest.kt index 2864460..31ee7e1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.creation import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/TestJobConfig.kt index 035a22c..f41bc3b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.creation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,16 +30,16 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/SampleApplicationTest.kt index 461bca2..a61aa92 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.decider.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestDecider.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestDecider.kt index e980431..c292a51 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestDecider.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestDecider.kt @@ -18,15 +18,16 @@ package com.navercorp.spring.batch.plus.sample.job.flow.decider.bean -import org.springframework.batch.core.JobExecution -import org.springframework.batch.core.StepExecution +import org.springframework.batch.core.job.JobExecution import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider +import org.springframework.batch.core.step.StepExecution import org.springframework.stereotype.Component @Component class TestDecider : JobExecutionDecider { - override fun decide(jobExecution: JobExecution, stepExecution: StepExecution?): FlowExecutionStatus { - return FlowExecutionStatus.FAILED - } + override fun decide( + jobExecution: JobExecution, + stepExecution: StepExecution?, + ): FlowExecutionStatus = FlowExecutionStatus.FAILED } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestJobConfig.kt index eff902e..03e5820 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.flow.decider.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,23 +30,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - deciderBean("testDecider") { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + deciderBean("testDecider") { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/SampleApplicationTest.kt index d6f7acc..4147309 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.decider.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/TestJobConfig.kt index 15ecf0a..a9d73dd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.flow.decider.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,28 +32,29 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - decider(testDecider()) { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + decider(testDecider()) { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testDecider(): JobExecutionDecider = JobExecutionDecider { _, _ -> - FlowExecutionStatus.FAILED - } + open fun testDecider(): JobExecutionDecider = + JobExecutionDecider { _, _ -> + FlowExecutionStatus.FAILED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/SampleApplicationTest.kt index 6e9c8a8..c3a4669 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/TestJobConfig.kt index 82ba6fa..d278262 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,33 +31,35 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - flowBean("testFlow1") - flowBean("testFlow2") + open fun testJob(): Job = + batch { + job("testJob") { + flowBean("testFlow1") + flowBean("testFlow2") + } } - } @Bean - open fun testFlow1(): Flow = batch { - flow("testFlow1") { - step("testFlow1Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("testFlow1Step2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow1(): Flow = + batch { + flow("testFlow1") { + step("testFlow1Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testFlow1Step2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } @Bean - open fun testFlow2(): Flow = batch { - flow("testFlow2") { - step("testFlow2Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow2(): Flow = + batch { + flow("testFlow2") { + step("testFlow2Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/SampleApplicationTest.kt index e3b9102..4407cc3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/TestJobConfig.kt index 01a62f2..59a5e32 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,23 +30,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - flow("testFlow1") { - step("testFlow1Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("testFlow1Step2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + flow("testFlow1") { + step("testFlow1Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testFlow1Step2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } - flow("testFlow2") { - step("testFlow2Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + flow("testFlow2") { + step("testFlow2Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/SampleApplicationTest.kt index daaf1e9..b0fd60e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/TestJobConfig.kt index 3c0e495..1780aa2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,42 +31,45 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - val testFlow3 = batch { - flow("testFlow3") { - step("testFlow3Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + val testFlow3 = + batch { + flow("testFlow3") { + step("testFlow3Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } } - } - } - flow(testFlow1()) - flow(testFlow2()) - flow(testFlow3) + flow(testFlow1()) + flow(testFlow2()) + flow(testFlow3) + } } - } @Bean - open fun testFlow1(): Flow = batch { - flow("testFlow1") { - step("testFlow1Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("testFlow1Step2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow1(): Flow = + batch { + flow("testFlow1") { + step("testFlow1Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testFlow1Step2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } @Bean - open fun testFlow2(): Flow = batch { - flow("testFlow2") { - step("testFlow2Step1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow2(): Flow = + batch { + flow("testFlow2") { + step("testFlow2Step1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/SampleApplicationTest.kt index a66d16b..94cfd86 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/TestJobConfig.kt index f56c224..72d1692 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,35 +31,36 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - flowBean("testFlow") { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + flowBean("testFlow") { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testFlow(): Flow = batch { - flow("testFlow") { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testFlow(): Flow = + batch { + flow("testFlow") { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/SampleApplicationTest.kt index bf8c185..b40f2ca 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/TestJobConfig.kt index cef15d4..93129cb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,33 +30,33 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - flow( - "testFlow", - { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + flow( + "testFlow", + { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } + }, + ) { + on("COMPLETED") { + end() } - }, - ) { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/SampleApplicationTest.kt index 1a3ecdf..6f0fee5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/TestJobConfig.kt index cd17918..d230abe 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,35 +31,36 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - flow(testFlow()) { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + flow(testFlow()) { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testFlow(): Flow = batch { - flow("testFlow") { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testFlow(): Flow = + batch { + flow("testFlow") { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/SampleApplicationTest.kt index afbcf54..36281e0 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.comparison.after import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/TestJobConfig.kt index 98c3c5a..41c8320 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.comparison.after import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,42 +31,44 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep1()) { - on("COMPLETED") { - step(successStep()) - } - on("FAILED") { - step("failureStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep1()) { + on("COMPLETED") { + step(successStep()) + } + on("FAILED") { + step("failureStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testStep1(): Step = batch { - step("testStep1") { - tasklet( - { _, _ -> - throw IllegalStateException("step failed") - }, - transactionManager, - ) + open fun testStep1(): Step = + batch { + step("testStep1") { + tasklet( + { _, _ -> + throw IllegalStateException("step failed") + }, + transactionManager, + ) + } } - } @Bean - open fun successStep(): Step = batch { - step("successStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun successStep(): Step = + batch { + step("successStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/SampleApplicationTest.kt index 79e0b15..6ee7069 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.comparison.before import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/TestJobConfig.kt index f3f4531..ca3a8d7 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/TestJobConfig.kt @@ -18,12 +18,12 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.comparison.before -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.builder.JobBuilder import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.StepBuilder -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,40 +33,40 @@ open class TestJobConfig( private val jobRepository: JobRepository, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job { - return JobBuilder("testJob", jobRepository) - .start(testStep1()).on("COMPLETED").to(successStep()) - .from(testStep1()).on("FAILED").to(failureStep()) - .from(testStep1()).on("*").stop() + open fun testJob(): Job = + JobBuilder("testJob", jobRepository) + .start(testStep1()) + .on("COMPLETED") + .to(successStep()) + .from(testStep1()) + .on("FAILED") + .to(failureStep()) + .from(testStep1()) + .on("*") + .stop() .build() .build() - } @Bean - open fun testStep1(): Step { - return StepBuilder("testStep1", jobRepository) + open fun testStep1(): Step = + StepBuilder("testStep1", jobRepository) .tasklet( { _, _ -> throw IllegalStateException("step failed") }, transactionManager, - ) - .build() - } + ).build() @Bean - open fun successStep(): Step { - return StepBuilder("successStep", jobRepository) + open fun successStep(): Step = + StepBuilder("successStep", jobRepository) .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) .build() - } @Bean - open fun failureStep(): Step { - return StepBuilder("failureStep", jobRepository) + open fun failureStep(): Step = + StepBuilder("failureStep", jobRepository) .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) .build() - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/SampleApplicationTest.kt index 259dbe6..60f200b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/TestJobConfig.kt index 601b655..8ee9ff3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,34 +31,37 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - stepBean("testStep1") - stepBean("testStep2") - stepBean("testStep3") + open fun testJob(): Job = + batch { + job("testJob") { + stepBean("testStep1") + stepBean("testStep2") + stepBean("testStep3") + } } - } @Bean - open fun testStep1(): Step = batch { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep1(): Step = + batch { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testStep2(): Step = batch { - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep2(): Step = + batch { + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testStep3(): Step = batch { - step("testStep3") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep3(): Step = + batch { + step("testStep3") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/SampleApplicationTest.kt index b91d81d..613af7c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/TestJobConfig.kt index 0bf11a2..5304a42 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,19 +30,19 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("testStep3") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testStep3") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/SampleApplicationTest.kt index 49bc22e..ad792e0 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/TestJobConfig.kt index 14273e9..6e5bab3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,33 +31,36 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - val testStep3 = batch { - step("testStep3") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - } + open fun testJob(): Job = + batch { + job("testJob") { + val testStep3 = + batch { + step("testStep3") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } - step(testStep1()) - step(testStep2()) - step(testStep3) + step(testStep1()) + step(testStep2()) + step(testStep3) + } } - } @Bean - open fun testStep1(): Step = batch { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep1(): Step = + batch { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testStep2(): Step = batch { - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep2(): Step = + batch { + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/SampleApplicationTest.kt index 554bb28..163ce2b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/TestJobConfig.kt index 28ab531..f3c3aac 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,33 +31,34 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - stepBean("testStep") { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + stepBean("testStep") { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/SampleApplicationTest.kt index 8253c1f..6d0180b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/TestJobConfig.kt index 8e1fbbc..812393c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,31 +30,31 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step( - "testStep", - { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) - }, - ) { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step( + "testStep", + { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + }, + ) { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/SampleApplicationTest.kt index 65ccb82..e7e34cd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/TestJobConfig.kt index 81dbaf9..df6c323 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,33 +31,34 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/SampleApplicationTest.kt index 2f0f9aa..00a676f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.decider.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/TestJobConfig.kt index 3316179..f2c8311 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.decider.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,53 +33,56 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - deciderBean("testDecider") { - on("COMPLETED") { - stop() - } - on("BATCH TEST") { - step(transitionStep()) - } - on("*") { - fail() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + deciderBean("testDecider") { + on("COMPLETED") { + stop() + } + on("BATCH TEST") { + step(transitionStep()) + } + on("*") { + fail() + } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun testDecider(): JobExecutionDecider = JobExecutionDecider { _, _ -> - FlowExecutionStatus("BATCH TEST") - } + open fun testDecider(): JobExecutionDecider = + JobExecutionDecider { _, _ -> + FlowExecutionStatus("BATCH TEST") + } @Bean - open fun transitionStep(): Step = batch { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun transitionStep(): Step = + batch { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/SampleApplicationTest.kt index d639b16..1bd1d7f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.decider.varia import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/TestJobConfig.kt index d060e56..0d05b9f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.decider.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,53 +33,56 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - decider(testDecider()) { - on("COMPLETED") { - stop() - } - on("BATCH TEST") { - step(transitionStep()) - } - on("*") { - fail() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + decider(testDecider()) { + on("COMPLETED") { + stop() + } + on("BATCH TEST") { + step(transitionStep()) + } + on("*") { + fail() + } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun testDecider(): JobExecutionDecider = JobExecutionDecider { _, _ -> - FlowExecutionStatus("BATCH TEST") - } + open fun testDecider(): JobExecutionDecider = + JobExecutionDecider { _, _ -> + FlowExecutionStatus("BATCH TEST") + } @Bean - open fun transitionStep(): Step = batch { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun transitionStep(): Step = + batch { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/SampleApplicationTest.kt index 5a40c11..479039c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.end import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/TestJobConfig.kt index 02971cf..3388eed 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.end import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,31 +30,32 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - stop() - } - on("FAILED") { - end("SKIPPED") - } - on("*") { - stop() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stop() + } + on("FAILED") { + end("SKIPPED") + } + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/SampleApplicationTest.kt index 7d247d0..f93b0a3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.fail import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/TestJobConfig.kt index 16df90c..8ae66ae 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.fail import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,25 +31,26 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - fail() - } - on("*") { - stop() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + fail() + } + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/SampleApplicationTest.kt index c742f0d..0570e6e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.stop import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.STOPPED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/TestJobConfig.kt index 6afb31a..a829bdf 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.stop import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,25 +31,26 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - stop() - } - on("*") { - end() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stop() + } + on("*") { + end() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/SampleApplicationTest.kt index a31b983..c60d7de 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/TestJobConfig.kt index b7ef99e..01460c4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,40 +32,42 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - flowBean("transitionFlow") - } - on("*") { - stop() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + flowBean("transitionFlow") + } + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun transitionFlow(): Flow = batch { - flow("transitionFlow") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun transitionFlow(): Flow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/SampleApplicationTest.kt index cdc91e1..cbab7f2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/TestJobConfig.kt index f313010..7b24b9a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,35 +31,36 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - flow("transitionFlow") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + flow("transitionFlow") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/SampleApplicationTest.kt index c88f62b..1f57f61 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/TestJobConfig.kt index 72d240d..d8e49eb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.nested import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,52 +32,54 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - flow(transitionFlow()) { - on("COMPLETED") { - fail() - } - on("*") { - step("nestedStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + flow(transitionFlow()) { + on("COMPLETED") { + fail() + } + on("*") { + step("nestedStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) - } - } - - @Bean - open fun transitionFlow(): Flow = batch { - flow("transitionFlow") { - step("transitionStep") { + open fun testStep(): Step = + batch { + step("testStep") { tasklet( - { _, _ -> throw IllegalStateException("transitionStep failed") }, + { _, _ -> throw IllegalStateException("testStep failed") }, transactionManager, ) } } - } + + @Bean + open fun transitionFlow(): Flow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet( + { _, _ -> throw IllegalStateException("transitionStep failed") }, + transactionManager, + ) + } + } + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/SampleApplicationTest.kt index 6d4e132..b1e3eef 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/TestJobConfig.kt index 70068ba..4719f0b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,40 +32,42 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - flow(transitionFlow()) - } - on("*") { - stop() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + flow(transitionFlow()) + } + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun transitionFlow(): Flow = batch { - flow("transitionFlow") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun transitionFlow(): Flow = + batch { + flow("transitionFlow") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/SampleApplicationTest.kt index 5977d06..87268c3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/TestJobConfig.kt index a7b7052..60286bd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,38 +31,40 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - stepBean("transitionStep") - } - on("*") { - stop() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + stepBean("transitionStep") + } + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun transitionStep(): Step = batch { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun transitionStep(): Step = + batch { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/SampleApplicationTest.kt index 0a8a4a4..37f3775 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/TestJobConfig.kt index 8fe8274..08e2f25 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,33 +31,34 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/SampleApplicationTest.kt index 71b81d0..2c1a577 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/TestJobConfig.kt index 451b00e..fbb7055 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.nested import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,50 +31,52 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - step(transitionStep()) { - on("COMPLETED") { - fail() - } - on("*") { - step("nestedStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + step(transitionStep()) { + on("COMPLETED") { + fail() + } + on("*") { + step("nestedStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun transitionStep(): Step = batch { - step("transitionStep") { - tasklet( - { _, _ -> throw IllegalStateException("transitionStep failed") }, - transactionManager, - ) + open fun transitionStep(): Step = + batch { + step("transitionStep") { + tasklet( + { _, _ -> throw IllegalStateException("transitionStep failed") }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/SampleApplicationTest.kt index b5d2f7f..e8a78b4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/TestJobConfig.kt index c31baba..daa975e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,38 +31,40 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - end() - } - on("FAILED") { - step(transitionStep()) - } - on("*") { - stop() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + end() + } + on("FAILED") { + step(transitionStep()) + } + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet( - { _, _ -> throw IllegalStateException("testStep failed") }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet( + { _, _ -> throw IllegalStateException("testStep failed") }, + transactionManager, + ) + } } - } @Bean - open fun transitionStep(): Step = batch { - step("transitionStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun transitionStep(): Step = + batch { + step("transitionStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/SampleApplicationTest.kt index 4be9287..2e8c384 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestar import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,14 +32,15 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .toJobParameters() - val firstJobExecution = jobLauncher.run(job, jobParameters) - val secondJobExecution = jobLauncher.run(job, jobParameters) + val firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.STOPPED == firstJobExecution.status) println("firstJobExecution: $firstJobExecution") diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/TestJobConfig.kt index 1f70e8f..038911b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.decider import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.FlowExecutionStatus import org.springframework.batch.core.job.flow.JobExecutionDecider -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,40 +33,42 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - stopAndRestartToDecider(testDecider()) { - on("COMPLETED") { - end() - } - on("BATCH TEST") { - fail() - } - on("*") { - end() + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stopAndRestartToDecider(testDecider()) { + on("COMPLETED") { + end() + } + on("BATCH TEST") { + fail() + } + on("*") { + end() + } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testDecider(): JobExecutionDecider = JobExecutionDecider { _, _ -> - FlowExecutionStatus("BATCH TEST") - } + open fun testDecider(): JobExecutionDecider = + JobExecutionDecider { _, _ -> + FlowExecutionStatus("BATCH TEST") + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/SampleApplicationTest.kt index 96de180..76cd9ba 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestar import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,14 +32,15 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .toJobParameters() - val firstJobExecution = jobLauncher.run(job, jobParameters) - val secondJobExecution = jobLauncher.run(job, jobParameters) + val firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.STOPPED == firstJobExecution.status) println("firstJobExecution: $firstJobExecution") diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/TestJobConfig.kt index 6fcd16d..2d036a4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.flow import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,31 +31,32 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - stopAndRestartToFlow("restartFlow") { - flow("restartFlow") { - step("restartStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stopAndRestartToFlow("restartFlow") { + flow("restartFlow") { + step("restartStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } } - } - on("*") { - stop() + on("*") { + stop() + } } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/SampleApplicationTest.kt index c064cec..05ba670 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestar import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,14 +32,15 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .toJobParameters() - val firstJobExecution = jobLauncher.run(job, jobParameters) - val secondJobExecution = jobLauncher.run(job, jobParameters) + val firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.STOPPED == firstJobExecution.status) println("firstJobExecution: $firstJobExecution") diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/TestJobConfig.kt index 6b65fe3..879f1e9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.step import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,27 +31,28 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step(testStep()) { - on("COMPLETED") { - stopAndRestartToStep("restartStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stopAndRestartToStep("restartStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + on("*") { + stop() } - } - on("*") { - stop() } } } - } @Bean - open fun testStep(): Step = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/SampleApplicationTest.kt index 570aa59..d5bda71 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.split.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/TestJobConfig.kt index 4b514c5..d8c848d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.split.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -32,42 +32,45 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - split(SimpleAsyncTaskExecutor()) { - flowBean("testFlow1") - flowBean("testFlow2") - flowBean("testFlow3") + open fun testJob(): Job = + batch { + job("testJob") { + split(SimpleAsyncTaskExecutor()) { + flowBean("testFlow1") + flowBean("testFlow2") + flowBean("testFlow3") + } } } - } @Bean - open fun testFlow1(): Flow = batch { - flow("testFlow1") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow1(): Flow = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } @Bean - open fun testFlow2(): Flow = batch { - flow("testFlow2") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow2(): Flow = + batch { + flow("testFlow2") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } @Bean - open fun testFlow3(): Flow = batch { - flow("testFlow3") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow3(): Flow = + batch { + flow("testFlow3") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/SampleApplicationTest.kt index e4f9483..46de6d5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.split.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/TestJobConfig.kt index 2e85b6d..183060c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/init/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.job.split.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -31,27 +31,27 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - split(SimpleAsyncTaskExecutor()) { - flow("testFlow1") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + split(SimpleAsyncTaskExecutor()) { + flow("testFlow1") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } - flow("testFlow2") { - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + flow("testFlow2") { + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } - flow("testFlow3") { - step("testStep3") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + flow("testFlow3") { + step("testStep3") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/SampleApplicationTest.kt index fd4a7de..4e79f18 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.job.split.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/TestJobConfig.kt index e031be3..9ebf592 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.job.split.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -32,40 +32,43 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - val testFlow3 = batch { - flow("testFlow3") { - step("testStep3") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + val testFlow3 = + batch { + flow("testFlow3") { + step("testStep3") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } } + split(SimpleAsyncTaskExecutor()) { + flow(testFlow1()) + flow(testFlow2()) + flow(testFlow3) } } - split(SimpleAsyncTaskExecutor()) { - flow(testFlow1()) - flow(testFlow2()) - flow(testFlow3) - } } - } @Bean - open fun testFlow1(): Flow = batch { - flow("testFlow1") { - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow1(): Flow = + batch { + flow("testFlow1") { + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } @Bean - open fun testFlow2(): Flow = batch { - flow("testFlow2") { - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow2(): Flow = + batch { + flow("testFlow2") { + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt index 89c138d..1416b79 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunkpolic import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt index 3837a27..706faab 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunkpolicy import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter -import org.springframework.batch.repeat.policy.SimpleCompletionPolicy +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,46 +33,42 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(SimpleCompletionPolicy(3), transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(SimpleCompletionPolicy(3), transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/SampleApplicationTest.kt index 8d56623..aafa99e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunksize import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt index 8d3cfb9..b5a4227 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunksize import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,46 +32,42 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/SampleApplicationTest.kt index 0d83282..5b424c4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.ann import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt index 3fffe04..a05e088 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt @@ -19,14 +19,14 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.chunklistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterChunk import org.springframework.batch.core.annotation.AfterChunkError import org.springframework.batch.core.annotation.BeforeChunk +import org.springframework.batch.core.job.Job import org.springframework.batch.core.scope.context.ChunkContext -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -36,7 +36,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeChunk fun beforeChunk(context: ChunkContext) { @@ -54,45 +53,42 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/SampleApplicationTest.kt index 3201e74..443f764 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.ann import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt index 562fe8c..9066e26 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt @@ -19,14 +19,14 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.mixed import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterProcess import org.springframework.batch.core.annotation.AfterRead import org.springframework.batch.core.annotation.BeforeWrite -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -36,7 +36,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @AfterRead fun afterRead(item: Any) { @@ -44,7 +43,10 @@ open class TestJobConfig( } @AfterProcess - fun afterProcess(item: Any, result: Any?) { + fun afterProcess( + item: Any, + result: Any?, + ) { println("afterProcess: $item, result: $result") } @@ -55,45 +57,42 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("[${Thread.currentThread().name}] write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/SampleApplicationTest.kt index 3879510..1148cb8 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.ann import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt index 1b56569..8fe6e61 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt @@ -19,13 +19,13 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.processorlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterProcess import org.springframework.batch.core.annotation.BeforeProcess import org.springframework.batch.core.annotation.OnProcessError -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,7 +35,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeProcess fun beforeProcess(item: Any) { @@ -43,56 +42,59 @@ open class TestJobConfig( } @AfterProcess - fun afterProcess(item: Any, result: Any?) { + fun afterProcess( + item: Any, + result: Any?, + ) { println("afterProcess: $item, result: $result") } @OnProcessError - fun onProcessError(item: Any, e: Exception) { + fun onProcessError( + item: Any, + e: Exception, + ) { println("onProcessError: $item, exception: $e") } } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("[${Thread.currentThread().name}] write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/SampleApplicationTest.kt index 20eeba7..c1530d9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.ann import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt index 09412cf..8553968 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt @@ -19,13 +19,13 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.readerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterRead import org.springframework.batch.core.annotation.BeforeRead import org.springframework.batch.core.annotation.OnReadError -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,7 +35,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeRead fun beforeRead() { @@ -54,45 +53,42 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/SampleApplicationTest.kt index 9c7d1c4..59ed053 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.ann import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt index 75dd347..6f704c1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt @@ -19,14 +19,14 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.writerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterWrite import org.springframework.batch.core.annotation.BeforeWrite import org.springframework.batch.core.annotation.OnWriteError -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -36,7 +36,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeWrite fun beforeWrite(chunk: Chunk) { @@ -49,51 +48,51 @@ open class TestJobConfig( } @OnWriteError - fun onWriteError(exception: Exception, chunk: Chunk) { + fun onWriteError( + exception: Exception, + chunk: Chunk, + ) { println("afterWrite: ${chunk.items}, exception: $exception") } } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/SampleApplicationTest.kt index 853a627..18a811b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.chu import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt index f96878c..6589696 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt @@ -19,12 +19,12 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.chunklistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.scope.context.ChunkContext -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,60 +34,56 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener( - object : ChunkListener { - override fun beforeChunk(context: ChunkContext) { - println("beforeChunk: $context") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener( + object : ChunkListener { + override fun beforeChunk(context: ChunkContext) { + println("beforeChunk: $context") + } - override fun afterChunk(context: ChunkContext) { - println("afterChunk: $context") - } + override fun afterChunk(context: ChunkContext) { + println("afterChunk: $context") + } - override fun afterChunkError(context: ChunkContext) { - } - }, - ) + override fun afterChunkError(context: ChunkContext) { + } + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("[${Thread.currentThread().name}] write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt index 071bee7..3b7bbfa 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.exc import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt index 2473c6b..aff196c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.exceptionhandler import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,43 +31,41 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - writer(testItemWriter()) - exceptionHandler { _, throwable -> - println("handle exception ${throwable.message}") - throw throwable + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + writer(testItemWriter()) + exceptionHandler { _, throwable -> + println("handle exception ${throwable.message}") + throw throwable + } + // same as + // exceptionHandler( + // object : ExceptionHandler { + // override fun handleException(context: RepeatContext, throwable: Throwable) { + // println("handle exception ${throwable.message}") + // throw throwable + // } + // } + // ) } - // same as - // exceptionHandler( - // object : ExceptionHandler { - // override fun handleException(context: RepeatContext, throwable: Throwable) { - // println("handle exception ${throwable.message}") - // throw throwable - // } - // } - // ) } } } - } @Bean - open fun testItemReader(): ItemReader { - return ItemReader { + open fun testItemReader(): ItemReader = + ItemReader { throw IllegalStateException("Error in read") } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/SampleApplicationTest.kt index 81e5854..2ed6567 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.exe import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt index 38b0d4b..bc39031 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.executor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -33,44 +33,39 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun customExecutor(): TaskExecutor { - return SimpleAsyncTaskExecutor() - } + open fun customExecutor(): TaskExecutor = SimpleAsyncTaskExecutor() @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - writer(testItemWriter()) - taskExecutor(customExecutor()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + writer(testItemWriter()) + taskExecutor(customExecutor()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 20) { + override fun read(): Int? = + if (count < 20) { count++ } else { null } - } } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("[${Thread.currentThread().name}] write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/SampleApplicationTest.kt index 8791d4d..7ce736c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.pro import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt index bb3f05c..2afd988 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.processorlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.ItemProcessListener -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.ItemProcessListener +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,60 +33,62 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener( - object : ItemProcessListener { - override fun beforeProcess(item: Int) { - println("beforeProcess: $item") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener( + object : ItemProcessListener { + override fun beforeProcess(item: Int) { + println("beforeProcess: $item") + } - override fun afterProcess(item: Int, result: String?) { - println("afterProcess: $item, result: $result") - } + override fun afterProcess( + item: Int, + result: String?, + ) { + println("afterProcess: $item, result: $result") + } - override fun onProcessError(item: Int, e: Exception) { - } - }, - ) + override fun onProcessError( + item: Int, + e: Exception, + ) { + } + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/SampleApplicationTest.kt index 3d6f1fd..c8f4378 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.rea import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt index 2ef278c..1a20e7f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.readerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.ItemReadListener -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.ItemReadListener +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,60 +33,56 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener( - object : ItemReadListener { - override fun beforeRead() { - println("beforeRead") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener( + object : ItemReadListener { + override fun beforeRead() { + println("beforeRead") + } - override fun onReadError(ex: Exception) { - } + override fun onReadError(ex: Exception) { + } - override fun afterRead(item: Int) { - println("afterRead (item: $item)") - } - }, - ) + override fun afterRead(item: Int) { + println("afterRead (item: $item)") + } + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt index ea6cfe6..f10bec1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.ste import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt index 3539d94..08ba77e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt @@ -19,13 +19,13 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.stepoperation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter -import org.springframework.batch.repeat.RepeatCallback -import org.springframework.batch.repeat.RepeatOperations -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.repeat.support.RepeatTemplate +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.batch.infrastructure.repeat.RepeatCallback +import org.springframework.batch.infrastructure.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,47 +35,44 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - writer(testItemWriter()) - stepOperations( - object : RepeatOperations { - override fun iterate(callback: RepeatCallback): RepeatStatus { - val delegate = RepeatTemplate() - println("custom iterate") - return delegate.iterate(callback) - } - }, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + writer(testItemWriter()) + stepOperations( + object : RepeatOperations { + override fun iterate(callback: RepeatCallback): RepeatStatus { + val delegate = RepeatTemplate() + println("custom iterate") + return delegate.iterate(callback) + } + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 20) { + override fun read(): Int? = + if (count < 20) { count++ } else { null } - } } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("[${Thread.currentThread().name}] write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/SampleApplicationTest.kt index 717f11a..292ea2c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.str import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt index dd1a34b..51e7483 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt @@ -19,12 +19,12 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.stream import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemStream -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,61 +34,57 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - stream( - object : ItemStream { - override fun open(executionContext: ExecutionContext) { - println("open stream") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + stream( + object : ItemStream { + override fun open(executionContext: ExecutionContext) { + println("open stream") + } - override fun update(executionContext: ExecutionContext) { - println("update stream") - } + override fun update(executionContext: ExecutionContext) { + println("update stream") + } - override fun close() { - println("close stream") - } - }, - ) + override fun close() { + println("close stream") + } + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("[${Thread.currentThread().name}] write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/SampleApplicationTest.kt index 567761a..0763f2e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.tra import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt index 3b1e1e2..6fb6054 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.transactionattribute import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,44 +33,41 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - writer(testItemWriter()) - transactionAttribute( - DefaultTransactionAttribute().apply { - setName("test-tx") - }, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + writer(testItemWriter()) + transactionAttribute( + DefaultTransactionAttribute().apply { + setName("test-tx") + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 20) { + override fun read(): Int? = + if (count < 20) { count++ } else { null } - } } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> val transactionName = TransactionSynchronizationManager.getCurrentTransactionName() println("write $items (transactionName: $transactionName)") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/SampleApplicationTest.kt index 50d29e4..fc3f63a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.wri import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt index 0a6f61e..e80dfbd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt @@ -19,12 +19,12 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.writerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.ItemWriteListener -import org.springframework.batch.core.Job -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.ItemWriteListener +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,60 +34,59 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener( - object : ItemWriteListener { - override fun beforeWrite(chunk: Chunk) { - println("beforeWrite: ${chunk.items}") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener( + object : ItemWriteListener { + override fun beforeWrite(chunk: Chunk) { + println("beforeWrite: ${chunk.items}") + } - override fun afterWrite(chunk: Chunk) { - println("afterWrite: ${chunk.items}") - } + override fun afterWrite(chunk: Chunk) { + println("afterWrite: ${chunk.items}") + } - override fun onWriteError(exception: Exception, Chunk: Chunk) { - } - }, - ) + override fun onWriteError( + exception: Exception, + Chunk: Chunk, + ) { + } + }, + ) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt index c36fd02..4954317 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt index 07f8df3..0955772 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.backoffpolicy import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.retry.RetryContext @@ -35,34 +35,32 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - backOffPolicy( - object : BackOffPolicy { - override fun start(context: RetryContext?): BackOffContext? { - return null - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + retry() + retryLimit(4) + backOffPolicy( + object : BackOffPolicy { + override fun start(context: RetryContext?): BackOffContext? = null - override fun backOff(backOffContext: BackOffContext?) { - println("backOff (context: $backOffContext)") - } - }, - ) + override fun backOff(backOffContext: BackOffContext?) { + println("backOff (context: $backOffContext)") + } + }, + ) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -94,9 +92,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt index 9b0ce2b..c6f22b9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt index 50b26c1..34931de 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.keygenerator import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,36 +32,36 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - keyGenerator { item -> - println("get key of $item") - item.toString() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + keyGenerator { item -> + println("get key of $item") + item.toString() + } + // same as + // keyGenerator( + // object : KeyGenerator { + // override fun getKey(item: Any): Any { + // println("get key of $item") + // return item.toString() + // } + // } + // ) + retry() + retryLimit(4) } - // same as - // keyGenerator( - // object : KeyGenerator { - // override fun getKey(item: Any): Any { - // println("get key of $item") - // return item.toString() - // } - // } - // ) - retry() - retryLimit(4) } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -93,9 +93,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt index e7a8273..76915eb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt index fa8f389..aeb2f6e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.noretry import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,24 +32,24 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(Int.MAX_VALUE) - noRetry() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + retry() + retryLimit(Int.MAX_VALUE) + noRetry() + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -81,9 +81,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt index 91f09c5..4c60947 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt index 72bb95b..f28ff96 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.noskip import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,24 +32,24 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - skip() - skipLimit(4) - noSkip() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + skip() + skipLimit(4) + noSkip() + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -67,8 +67,8 @@ open class TestJobConfig( } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> if (item % 3 == 0) { throw IllegalStateException("Error") } @@ -79,12 +79,10 @@ open class TestJobConfig( item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt index e790532..7f447c9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt index d22ba60..c9002ef 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.processornontx import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,24 +32,24 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - processorNonTransactional() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + retry() + retryLimit(4) + processorNonTransactional() + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -85,9 +85,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/SampleApplicationTest.kt index 01c93ae..e157549 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt index 6c83374..cec07eb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.retry import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,23 +32,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + retry() + retryLimit(4) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -80,9 +80,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt index 3d9ea9a..b0f4071 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt index 5594c49..2159eed 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.retrycontextcache import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.retry.policy.MapRetryContextCache @@ -33,31 +33,31 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - retryContextCache( - object : MapRetryContextCache() { - override fun containsKey(key: Any?): Boolean { - println("contains key: $key") - return super.containsKey(key) - } - }, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + retry() + retryLimit(4) + retryContextCache( + object : MapRetryContextCache() { + override fun containsKey(key: Any?): Boolean { + println("contains key: $key") + return super.containsKey(key) + } + }, + ) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -89,9 +89,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/SampleApplicationTest.kt index d331387..9ee88a4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt index 7f98580..7ebbe7d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.retrylistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.retry.RetryCallback @@ -35,50 +35,50 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - listener( - object : RetryListener { - override fun open( - context: RetryContext?, - callback: RetryCallback?, - ): Boolean { - println("RetryListener::open (context: $context") - return true - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + listener( + object : RetryListener { + override fun open( + context: RetryContext?, + callback: RetryCallback?, + ): Boolean { + println("RetryListener::open (context: $context") + return true + } - override fun close( - context: RetryContext?, - callback: RetryCallback?, - throwable: Throwable?, - ) { - println("RetryListener::close (error: ${throwable?.message})") - } + override fun close( + context: RetryContext?, + callback: RetryCallback?, + throwable: Throwable?, + ) { + println("RetryListener::close (error: ${throwable?.message})") + } - override fun onError( - context: RetryContext?, - callback: RetryCallback?, - throwable: Throwable?, - ) { - println("RetryListener::onError (error: ${throwable?.message})") - } - }, - ) - retry() - retryLimit(4) + override fun onError( + context: RetryContext?, + callback: RetryCallback?, + throwable: Throwable?, + ) { + println("RetryListener::onError (error: ${throwable?.message})") + } + }, + ) + retry() + retryLimit(4) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -110,9 +110,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/SampleApplicationTest.kt index 564b41a..daa1842 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt index 13e1ac6..6bbe649 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.retrypolicy import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.retry.policy.SimpleRetryPolicy @@ -33,23 +33,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryPolicy(SimpleRetryPolicy(4)) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + retry() + retryPolicy(SimpleRetryPolicy(4)) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -81,9 +81,8 @@ open class TestJobConfig( } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt index 3ca323a..09e85da 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt index b1536e2..2bb8e73 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.rollback import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,22 +32,22 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - noRollback() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + noRollback() + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -65,20 +65,18 @@ open class TestJobConfig( } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> if (item % 3 == 0) { throw IllegalStateException("Error") } item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/SampleApplicationTest.kt index f516cd4..7482a2f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt index 8ded8c2..e246455 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.skip import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,23 +32,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - skip() - skipLimit(4) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + skip() + skipLimit(4) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -66,20 +66,18 @@ open class TestJobConfig( } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> if (item % 3 == 0) { throw IllegalStateException("Error") } item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/SampleApplicationTest.kt index 4245201..3cecc75 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt index e780957..a7af6a2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.skiplistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.SkipListener -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.SkipListener +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,36 +33,42 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - listener( - object : SkipListener { - override fun onSkipInRead(t: Throwable) { - println("Ignore exception of read (exception: ${t.message})") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + listener( + object : SkipListener { + override fun onSkipInRead(t: Throwable) { + println("Ignore exception of read (exception: ${t.message})") + } - override fun onSkipInProcess(item: Int, t: Throwable) { - } + override fun onSkipInProcess( + item: Int, + t: Throwable, + ) { + } - override fun onSkipInWrite(item: String, t: Throwable) { - } - }, - ) - skip() - skipLimit(1) + override fun onSkipInWrite( + item: String, + t: Throwable, + ) { + } + }, + ) + skip() + skipLimit(1) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -86,16 +92,14 @@ open class TestJobConfig( } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/SampleApplicationTest.kt index 8c045ce..96541bd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt index 4796bc3..959b19e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt @@ -19,13 +19,13 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.skiplistenerannotation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.OnSkipInProcess import org.springframework.batch.core.annotation.OnSkipInRead import org.springframework.batch.core.annotation.OnSkipInWrite -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,42 +35,47 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { - @OnSkipInRead fun onSkipInRead(t: Throwable) { println("Ignore exception of read (exception: ${t.message})") } @OnSkipInProcess - fun onSkipInProcess(item: Any, t: Throwable) { + fun onSkipInProcess( + item: Any, + t: Throwable, + ) { println("Ignore exception of process (item: $item, exception: ${t.message})") } @OnSkipInWrite - fun onSkipInWrite(item: Any, t: Throwable) { + fun onSkipInWrite( + item: Any, + t: Throwable, + ) { println("Ignore exception of write (item: $item, exception: ${t.message})") } } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) - faultTolerant { - skip() - skipLimit(1) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + faultTolerant { + skip() + skipLimit(1) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -94,16 +99,14 @@ open class TestJobConfig( } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/SampleApplicationTest.kt index 3255041..4c77d9a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttoler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt index 33d387d..65dbc3f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.skippolicy import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,27 +33,27 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - skipPolicy( - LimitCheckingItemSkipPolicy( - 4, - mapOf(RuntimeException::class.java to true), - ), - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + faultTolerant { + skipPolicy( + LimitCheckingItemSkipPolicy( + 4, + mapOf(RuntimeException::class.java to true), + ), + ) + } } } } } - } @Bean open fun testItemReader(): ItemReader { @@ -71,20 +71,18 @@ open class TestJobConfig( } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> if (item % 3 == 0) { throw IllegalStateException("Error") } item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt index 8b3f695..89752f0 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.repeatoper import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt index c787af1..d5f8374 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt @@ -19,12 +19,12 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.repeatoperation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.item.ItemProcessor -import org.springframework.batch.item.ItemReader -import org.springframework.batch.item.ItemWriter -import org.springframework.batch.repeat.policy.SimpleCompletionPolicy -import org.springframework.batch.repeat.support.RepeatTemplate +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.item.ItemProcessor +import org.springframework.batch.infrastructure.item.ItemReader +import org.springframework.batch.infrastructure.item.ItemWriter +import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,49 +34,46 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - val repeatOperations = RepeatTemplate().apply { - setCompletionPolicy(SimpleCompletionPolicy(3)) - } - chunk(repeatOperations, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + val repeatOperations = + RepeatTemplate().apply { + setCompletionPolicy(SimpleCompletionPolicy(3)) + } + chunk(repeatOperations, transactionManager) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + } } } } - } @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { + open fun testItemReader(): ItemReader = + object : ItemReader { private var count = 0 - override fun read(): Int? { - return if (count < 11) { + override fun read(): Int? = + if (count < 11) { count++ } else { null } - } } - } @Bean - open fun testItemProcessor(): ItemProcessor { - return ItemProcessor { item -> + open fun testItemProcessor(): ItemProcessor = + ItemProcessor { item -> item.toString() } - } @Bean - open fun testItemWriter(): ItemWriter { - return ItemWriter { items -> + open fun testItemWriter(): ItemWriter = + ItemWriter { items -> println("write $items") } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/SampleApplicationTest.kt index 983d572..e38903b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.allowstartifco import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,15 +32,16 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .toJobParameters() - val firstJobExecution = jobLauncher.run(job, jobParameters) - val secondJobExecution = jobLauncher.run(job, jobParameters) - val thirdJobExecution = jobLauncher.run(job, jobParameters) + val firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + val thirdJobExecution = jobOperator.start(job, jobParameters) // always alwaysRunStep is invoked assert(BatchStatus.FAILED == firstJobExecution.status) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/TestJobConfig.kt index a6f2893..3413569 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/allowstartifcomplete/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.allowstartifcomplete import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,28 +30,28 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("alwaysRunStep") { - allowStartIfComplete(true) - tasklet( - { _, _ -> - println("always run") - RepeatStatus.FINISHED - }, - transactionManager, - ) - } - step("alwaysFailsStep") { - tasklet( - { _, _ -> - throw IllegalStateException("always failed") - }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("alwaysRunStep") { + allowStartIfComplete(true) + tasklet( + { _, _ -> + println("always run") + RepeatStatus.FINISHED + }, + transactionManager, + ) + } + step("alwaysFailsStep") { + tasklet( + { _, _ -> + throw IllegalStateException("always failed") + }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/SampleApplicationTest.kt index a855a18..c1602e2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.listenerannota import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/TestJobConfig.kt index 01f71c0..10701b1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerannotation/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.listenerannotation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterStep import org.springframework.batch.core.annotation.BeforeStep -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,7 +32,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeStep fun beforeStep() { @@ -46,12 +45,13 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - listener(TestListener()) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + listener(TestListener()) + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/SampleApplicationTest.kt index d6ab875..2950ac9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.listenerobject import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/TestJobConfig.kt index 36c4c96..60256c8 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/listenerobject/TestJobConfig.kt @@ -20,10 +20,10 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.listenerobject import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.StepExecution -import org.springframework.batch.core.StepExecutionListener -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.StepExecutionListener +import org.springframework.batch.core.step.StepExecution +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,25 +33,25 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - listener( - object : StepExecutionListener { - override fun beforeStep(stepExecution: StepExecution) { - println("beforeStep") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + listener( + object : StepExecutionListener { + override fun beforeStep(stepExecution: StepExecution) { + println("beforeStep") + } - override fun afterStep(stepExecution: StepExecution): ExitStatus? { - println("afterStep") - return null - } - }, - ) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + override fun afterStep(stepExecution: StepExecution): ExitStatus? { + println("afterStep") + return null + } + }, + ) + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt index 510e180..2471cfd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.meterregistry import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt index 3b9c0f6..753ce3b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.meterregistry import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import io.micrometer.core.instrument.simple.SimpleMeterRegistry -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,14 +31,14 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - meterRegistry(SimpleMeterRegistry()) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + meterRegistry(SimpleMeterRegistry()) + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt index 110eb2d..1fd8cf5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.observationcon import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt index 36a6adb..7a5ce6e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.observationconvention import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.observability.DefaultBatchStepObservationConvention -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,14 +31,14 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - observationConvention(DefaultBatchStepObservationConvention()) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + observationConvention(DefaultBatchStepObservationConvention()) + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/SampleApplicationTest.kt index 3932082..c6764b6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.observationreg import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/TestJobConfig.kt index d8ba114..73eceba 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationregistry/TestJobConfig.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.observationreg import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import io.micrometer.observation.ObservationRegistry -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,14 +31,14 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - observationRegistry(ObservationRegistry.create()) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + observationRegistry(ObservationRegistry.create()) + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/SampleApplicationTest.kt index e357a5b..b6818c4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.startlimit import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,16 +32,17 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() + val jobParameters = + JobParametersBuilder() + .toJobParameters() // failed - val firstJobExecution = jobLauncher.run(job, jobParameters) - val secondJobExecution = jobLauncher.run(job, jobParameters) - val thirdJobExecution = jobLauncher.run(job, jobParameters) + val firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + val thirdJobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == firstJobExecution.status) println(firstJobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/TestJobConfig.kt index fd3e71d..4430311 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/startlimit/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.configuration.startlimit import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,24 +30,24 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - private var count = 0 @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - startLimit(2) - tasklet( - { _, _ -> - if (count < 2) { - throw IllegalStateException("count is less than 2 (count: ${count++})") - } - RepeatStatus.FINISHED - }, - transactionManager, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + startLimit(2) + tasklet( + { _, _ -> + if (count < 2) { + throw IllegalStateException("count is less than 2 (count: ${count++})") + } + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/SampleApplicationTest.kt index 3b6a002..a6996f0 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.creation import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/TestJobConfig.kt index b1cb3a0..3b6a06a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.creation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,39 +30,41 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - // within job - step("testStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + // within job + step("testStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("testStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + flow(testFlow()) + step(testStep()) } - step("testStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - flow(testFlow()) - step(testStep()) } - } @Bean - open fun testStep() = batch { - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testStep() = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } - } @Bean - open fun testFlow() = batch { - flow("testFlow") { - // within flow - step("flowStep1") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - step("flowStep2") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testFlow() = + batch { + flow("testFlow") { + // within flow + step("flowStep1") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + step("flowStep2") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt index 3e85270..eff26a9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.flowstep.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt index d1c7145..e5f4254 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.flowstep.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,22 +31,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - flowBean("anotherFlow") + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + flowBean("anotherFlow") + } } } - } @Bean - open fun anotherFlow(): Flow = batch { - flow("anotherFlow") { - step("anotherFlowStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun anotherFlow(): Flow = + batch { + flow("anotherFlow") { + step("anotherFlowStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt index 8c75ad8..40bc960 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.flowstep.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt index a401c30..8205497 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.flowstep.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,17 +30,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - flow("anotherFlow") { - step("anotherFlowStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + flow("anotherFlow") { + step("anotherFlowStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt index 664a213..1b38330 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.flowstep.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt index 3392d09..c6d052f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.flowstep.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.flow.Flow -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,22 +31,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - flow(anotherFlow()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + flow(anotherFlow()) + } } } - } @Bean - open fun anotherFlow(): Flow = batch { - flow("anotherFlow") { - step("anotherFlowStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun anotherFlow(): Flow = + batch { + flow("anotherFlow") { + step("anotherFlowStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt index 4bc6f24..3ab3348 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt index d4a8806..afe71a6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,22 +30,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - jobBean("anotherJob") + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + jobBean("anotherJob") + } } } - } @Bean - open fun anotherJob() = batch { - job("anotherJob") { - step("anotherJobStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun anotherJob() = + batch { + job("anotherJob") { + step("anotherJobStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt index efc9434..781db97 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.config.extractor import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addString("test", "tt") - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("test", "tt") + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt index c8c0ac4..d728f94 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.config.extractor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,38 +31,39 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - job(anotherJob()) { - parametersExtractor { _, _ -> - JobParametersBuilder() - .addString("extra", "value") - .toJobParameters() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + job(anotherJob()) { + parametersExtractor { _, _ -> + JobParametersBuilder() + .addString("extra", "value") + .toJobParameters() + } + // same as + // parametersExtractor( + // object : JobParametersExtractor { + // override fun getJobParameters(job: Job, stepExecution: StepExecution): JobParameters { + // return JobParametersBuilder() + // .addString("extra", "value") + // .toJobParameters() + // } + // } + // ) } - // same as - // parametersExtractor( - // object : JobParametersExtractor { - // override fun getJobParameters(job: Job, stepExecution: StepExecution): JobParameters { - // return JobParametersBuilder() - // .addString("extra", "value") - // .toJobParameters() - // } - // } - // ) } } } - } @Bean - open fun anotherJob() = batch { - job("anotherJob") { - step("anotherJobStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun anotherJob() = + batch { + job("anotherJob") { + step("anotherJobStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt index 7a7c909..be77e03 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.config.launcher import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt index 8c9cc29..ef90ee3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt @@ -19,9 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.config.launcher import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.launch.JobLauncher -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,38 +29,39 @@ import org.springframework.transaction.PlatformTransactionManager open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, - private val jobLauncher: JobLauncher, + private val jobOperator: JobLauncher, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - job(anotherJob()) { - launcher { job, jobParameters -> - println("launch anotherJob!!!") - jobLauncher.run(job, jobParameters) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + job(anotherJob()) { + launcher { job, jobParameters -> + println("launch anotherJob!!!") + jobOperator.start(job, jobParameters) + } + // same as + // launcher( + // object : JobLauncher { + // override fun run(job: Job, jobParameters: JobParameters): JobExecution { + // println("launch anotherJob!!!") + // return jobOperator.start(job, jobParameters) + // } + // } + // ) } - // same as - // launcher( - // object : JobLauncher { - // override fun run(job: Job, jobParameters: JobParameters): JobExecution { - // println("launch anotherJob!!!") - // return jobLauncher.run(job, jobParameters) - // } - // } - // ) } } } - } @Bean - open fun anotherJob() = batch { - job("anotherJob") { - step("anotherJobStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun anotherJob() = + batch { + job("anotherJob") { + step("anotherJobStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt index c022610..2e97f84 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt index 550514e..fe1953d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt @@ -19,8 +19,8 @@ package com.navercorp.spring.batch.plus.sample.step.jobstep.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -30,22 +30,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - job(anotherJob()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + job(anotherJob()) + } } } - } @Bean - open fun anotherJob() = batch { - job("anotherJob") { - step("anotherJobStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + open fun anotherJob() = + batch { + job("anotherJob") { + step("anotherJobStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt index d49f2d5..90d5066 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.aggregator import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt index 01e6ea7..d7c5668 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.aggregator import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.partition.support.DefaultStepExecutionAggregator -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -34,38 +34,39 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - partitioner { - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + partitioner { + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } } + partitionHandler { + taskExecutor(SimpleAsyncTaskExecutor()) + step(testStep()) + gridSize(4) + } + aggregator(DefaultStepExecutionAggregator()) } - partitionHandler { - taskExecutor(SimpleAsyncTaskExecutor()) - step(testStep()) - gridSize(4) - } - aggregator(DefaultStepExecutionAggregator()) } } } - } @Bean - open fun testStep(): Step = batch { - step("actualStep") { - tasklet( - { contribution, _ -> - println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") - RepeatStatus.FINISHED - }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("actualStep") { + tasklet( + { contribution, _ -> + println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt index 54013af..253b7da 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandl import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt index 2f0c759..9bff9ea 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandler.direct import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step +import org.springframework.batch.core.job.Job import org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -34,39 +34,40 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - partitioner { - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + partitioner { + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } } + partitionHandler( + TaskExecutorPartitionHandler().apply { + setTaskExecutor(SimpleAsyncTaskExecutor()) + step = actualStep() + gridSize = 4 + }, + ) } - partitionHandler( - TaskExecutorPartitionHandler().apply { - setTaskExecutor(SimpleAsyncTaskExecutor()) - step = actualStep() - gridSize = 4 - }, - ) } } } - } @Bean - open fun actualStep(): Step = batch { - step("actualStep") { - tasklet( - { contribution, _ -> - println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") - RepeatStatus.FINISHED - }, - transactionManager, - ) + open fun actualStep(): Step = + batch { + step("actualStep") { + tasklet( + { contribution, _ -> + println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt index 514e825..770c95d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandl import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt index 365d9af..6815d09 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandler.inner import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -33,38 +33,39 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - partitioner { - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + partitioner { + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } + } + // use TaskExecutorPartitionHandler internally + partitionHandler { + taskExecutor(SimpleAsyncTaskExecutor()) + step(actualStep()) + gridSize(4) } - } - // use TaskExecutorPartitionHandler internally - partitionHandler { - taskExecutor(SimpleAsyncTaskExecutor()) - step(actualStep()) - gridSize(4) } } } } - } @Bean - open fun actualStep(): Step = batch { - step("actualStep") { - tasklet( - { contribution, _ -> - println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") - RepeatStatus.FINISHED - }, - transactionManager, - ) + open fun actualStep(): Step = + batch { + step("actualStep") { + tasklet( + { contribution, _ -> + println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt index 6371124..0d2491a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.direc import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt index 783a513..6d391b6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt @@ -19,12 +19,12 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.direct import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.core.StepExecution +import org.springframework.batch.core.job.Job import org.springframework.batch.core.partition.StepExecutionSplitter import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.step.Step +import org.springframework.batch.core.step.StepExecution +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -36,47 +36,52 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, private val jobRepository: JobRepository, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - partitioner { - splitter( - object : StepExecutionSplitter { - override fun getStepName(): String = "workerStep" + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + partitioner { + splitter( + object : StepExecutionSplitter { + override fun getStepName(): String = "workerStep" - override fun split(stepExecution: StepExecution, gridSize: Int): Set { - val jobExecution = stepExecution.jobExecution - val stepExecutions = (0 until gridSize) - .map { - jobExecution.createStepExecution("$stepName:partition-$it") - } - jobRepository.addAll(stepExecutions) - return stepExecutions.toSet() - } - }, - ) - partitionHandler { - taskExecutor(SimpleAsyncTaskExecutor()) - step(actualStep()) - gridSize(4) + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + val jobExecution = stepExecution.jobExecution + val stepExecutions = + (0 until gridSize) + .map { + jobExecution.createStepExecution("$stepName:partition-$it") + } + jobRepository.addAll(stepExecutions) + return stepExecutions.toSet() + } + }, + ) + partitionHandler { + taskExecutor(SimpleAsyncTaskExecutor()) + step(actualStep()) + gridSize(4) + } } } } } - } @Bean - open fun actualStep(): Step = batch { - step("actualStep") { - tasklet( - { contribution, _ -> - println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") - RepeatStatus.FINISHED - }, - transactionManager, - ) + open fun actualStep(): Step = + batch { + step("actualStep") { + tasklet( + { contribution, _ -> + println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt index 4bbefdc..9d7d7db 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.inner import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt index 38ab6c4..578017a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.inner import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job -import org.springframework.batch.core.Step -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.Step +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -33,38 +33,39 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - partitioner { - // use SimpleStepExecutionSplitter internally - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + partitioner { + // use SimpleStepExecutionSplitter internally + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } + } + partitionHandler { + taskExecutor(SimpleAsyncTaskExecutor()) + step(testStep()) + gridSize(4) } - } - partitionHandler { - taskExecutor(SimpleAsyncTaskExecutor()) - step(testStep()) - gridSize(4) } } } } - } @Bean - open fun testStep(): Step = batch { - step("actualStep") { - tasklet( - { contribution, _ -> - println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") - RepeatStatus.FINISHED - }, - transactionManager, - ) + open fun testStep(): Step = + batch { + step("actualStep") { + tasklet( + { contribution, _ -> + println("[${Thread.currentThread().name}][${contribution.stepExecution.stepName}] run actual tasklet") + RepeatStatus.FINISHED + }, + transactionManager, + ) + } } - } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt index b5a70af..80e50c2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .addString("param", "I am test") - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addString("param", "I am test") + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt index 250611a..8be7205 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt @@ -19,10 +19,10 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.configuration.annotation.StepScope +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -33,22 +33,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet", transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + taskletBean("testTasklet", transactionManager) + } } } - } @Bean @StepScope open fun testTasklet( @Value("#{jobParameters['param']}") paramValue: String, - ): Tasklet = Tasklet { _, _ -> - println("param is '$paramValue'") - RepeatStatus.FINISHED - } + ): Tasklet = + Tasklet { _, _ -> + println("param is '$paramValue'") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt index 1452146..aef0d19 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.exception import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.FAILED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt index 2ce6bc6..44d26a8 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt @@ -19,7 +19,7 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.exceptionhandler import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -30,32 +30,33 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - exceptionHandler { _, throwable -> - println("handle exception ${throwable.message}") - throw throwable + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + exceptionHandler { _, throwable -> + println("handle exception ${throwable.message}") + throw throwable + } + // same as + // exceptionHandler( + // object : ExceptionHandler { + // override fun handleException(context: RepeatContext, throwable: Throwable) { + // println("handle exception ${throwable.message}") + // throw throwable + // } + // } + // ) } - // same as - // exceptionHandler( - // object : ExceptionHandler { - // override fun handleException(context: RepeatContext, throwable: Throwable) { - // println("handle exception ${throwable.message}") - // throw throwable - // } - // } - // ) } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - throw IllegalStateException("testTasklet error") - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + throw IllegalStateException("testTasklet error") + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt index 48a25dc..366bf6e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.executor import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt index 658be12..e75bf97 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.executor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.task.SimpleAsyncTaskExecutor @@ -33,31 +33,31 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun customExecutor(): TaskExecutor { - return object : SimpleAsyncTaskExecutor() { + open fun customExecutor(): TaskExecutor = + object : SimpleAsyncTaskExecutor() { override fun execute(task: Runnable) { println("run in custom executor") super.execute(task) } } - } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - taskExecutor(customExecutor()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + taskExecutor(customExecutor()) + } } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt index 733606a..f590f68 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenera import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt index af885e5..4a268d8 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt @@ -19,13 +19,13 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenerannotation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job import org.springframework.batch.core.annotation.AfterChunk import org.springframework.batch.core.annotation.AfterChunkError import org.springframework.batch.core.annotation.BeforeChunk +import org.springframework.batch.core.job.Job import org.springframework.batch.core.scope.context.ChunkContext import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -35,7 +35,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeChunk fun beforeChunk(context: ChunkContext) { @@ -53,19 +52,21 @@ open class TestJobConfig( } @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - listener(TestListener()) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + listener(TestListener()) + } } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt index 59dac36..3699538 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenero import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt index 0d09699..29e7ebc 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenerobject import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.ChunkListener -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.listener.ChunkListener import org.springframework.batch.core.scope.context.ChunkContext import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,34 +33,35 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - listener( - object : ChunkListener { - override fun beforeChunk(context: ChunkContext) { - println("beforeChunk: $context") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + listener( + object : ChunkListener { + override fun beforeChunk(context: ChunkContext) { + println("beforeChunk: $context") + } - override fun afterChunk(context: ChunkContext) { - println("afterChunk: $context") - } + override fun afterChunk(context: ChunkContext) { + println("afterChunk: $context") + } - override fun afterChunkError(context: ChunkContext) { - } - }, - ) + override fun afterChunkError(context: ChunkContext) { + } + }, + ) + } } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt index 8c49b28..1ebe894 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.stepopera import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt index d1eb40c..7e2528d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt @@ -19,12 +19,12 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.stepoperation import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatCallback -import org.springframework.batch.repeat.RepeatOperations -import org.springframework.batch.repeat.RepeatStatus -import org.springframework.batch.repeat.support.RepeatTemplate +import org.springframework.batch.infrastructure.repeat.RepeatCallback +import org.springframework.batch.infrastructure.repeat.RepeatOperations +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -34,29 +34,30 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - stepOperations( - object : RepeatOperations { - override fun iterate(callback: RepeatCallback): RepeatStatus { - val delegate = RepeatTemplate() - println("custom iterate") - return delegate.iterate(callback) - } - }, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + stepOperations( + object : RepeatOperations { + override fun iterate(callback: RepeatCallback): RepeatStatus { + val delegate = RepeatTemplate() + println("custom iterate") + return delegate.iterate(callback) + } + }, + ) + } } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt index 79b6bd3..fa40b7a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.stream import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt index 2f68e7f..d7e1e31 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt @@ -19,11 +19,11 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.stream import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.item.ExecutionContext -import org.springframework.batch.item.ItemStream -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,35 +33,36 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - stream( - object : ItemStream { - override fun open(executionContext: ExecutionContext) { - println("open stream") - } + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + stream( + object : ItemStream { + override fun open(executionContext: ExecutionContext) { + println("open stream") + } - override fun update(executionContext: ExecutionContext) { - println("update stream") - } + override fun update(executionContext: ExecutionContext) { + println("update stream") + } - override fun close() { - println("close stream") - } - }, - ) + override fun close() { + println("close stream") + } + }, + ) + } } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt index 21c3b2c..4b6d506 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.transacti import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt index 6587b57..d0553fc 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.transactionattribute import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,27 +33,28 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - transactionAttribute( - DefaultTransactionAttribute().apply { - setName("test-tx") - }, - ) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + transactionAttribute( + DefaultTransactionAttribute().apply { + setName("test-tx") + }, + ) + } } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - // print false - val transactionName = TransactionSynchronizationManager.getCurrentTransactionName() - println("run testTasklet (transactionName: $transactionName}") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + // print false + val transactionName = TransactionSynchronizationManager.getCurrentTransactionName() + println("run testTasklet (transactionName: $transactionName}") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt index 8648c5b..6f239cb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,12 +32,13 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean() - val jobParameters = JobParametersBuilder() - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt index 75b80ff..bf8c43d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt @@ -19,9 +19,9 @@ package com.navercorp.spring.batch.plus.sample.step.taskletstep.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,19 +31,20 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob(): Job = batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) + } } } - } @Bean - open fun testTasklet(): Tasklet = Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/build.gradle.kts b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/build.gradle.kts index 3b3c914..77eb346 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/build.gradle.kts +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + buildscript { repositories { gradlePluginPortal() // give accees to gradle community plugins @@ -17,12 +19,9 @@ repositories { kotlin { jvmToolchain(17) -} - -tasks.withType { - kotlinOptions { + compilerOptions { freeCompilerArgs = listOf("-Xjsr305=strict") // enable jsr305 null-safety in kotlin - jvmTarget = "17" + jvmTarget = JvmTarget.JVM_17 } } @@ -33,15 +32,15 @@ tasks.named("test") { dependencyManagement { imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.0") + mavenBom("org.springframework.boot:spring-boot-dependencies:4.0.7") } } dependencies { - implementation("org.springframework.boot:spring-boot-starter-batch") + implementation("org.springframework.boot:spring-boot-starter-batch-jdbc") implementation(project(":spring-boot-starter-batch-plus-kotlin")) implementation("io.projectreactor:reactor-core:3.5.0") - runtimeOnly("com.h2database:h2:2.1.214") + runtimeOnly("com.h2database:h2:2.4.240") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.kt index 0681d41..39f379d 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.flux.callback import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.kt index 7e6c638..4211468 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.flux.callback import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component import reactor.core.publisher.Flux @@ -57,9 +57,7 @@ open class SampleTasklet( println("onCloseRead") } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun onOpenWrite(executionContext: ExecutionContext) { println("onOpenWrite") diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.kt index c63c7af..e4c2c86 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/callback/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,19 +32,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.callback.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.callback.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.kt index d00f448..9d54883 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessor import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.kt index 6d0ec65..bf313d8 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/SampleTasklet.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessor import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderProcessor import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component import reactor.core.publisher.Flux @@ -44,7 +44,5 @@ open class SampleTasklet( } } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.kt index 23dc2f7..7732e1d 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessor/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,17 +32,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer { chunk -> println(chunk.items) } + open fun testJob(sampleTasklet: SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer { chunk -> println(chunk.items) } + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.kt index d562692..6392608 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.kt index 8dfceb3..b03f7d8 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component import reactor.core.publisher.Flux @@ -45,9 +45,7 @@ open class SampleTasklet( } } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun write(chunk: Chunk) { println(chunk.items) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.kt index 5bd4c41..6b3d01e 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerprocessorwriter/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,17 +33,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.kt index 22ab239..fb5c81a 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.flux.readerwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.kt index 7617a97..bc05e71 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.flux.readerwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component import reactor.core.publisher.Flux diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.kt index 06fcbc9..8152a45 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/readerwriter/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.flux.readerwriter import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,18 +31,16 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.readerwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.readerwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.kt index 41a1d88..21f6d06 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterable.callback import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.kt index d11aef6..15e9203 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.iterable.callback import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -40,13 +40,9 @@ open class SampleTasklet( println("totalCount: $totalCount") return Iterable { object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } } @@ -59,9 +55,7 @@ open class SampleTasklet( println("onCloseRead") } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun onOpenWrite(executionContext: ExecutionContext) { println("onOpenWrite") diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.kt index c21741e..a146d9a 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/callback/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,19 +32,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.callback.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.callback.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.kt index e808d9a..bef074e 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerprocessor import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.kt index 1ad20bc..ce87a17 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/SampleTasklet.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerprocessor import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessor import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -35,18 +35,12 @@ open class SampleTasklet( println("totalCount: $totalCount") return Iterable { object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.kt index 1da5c16..c5fba49 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessor/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerprocessor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,17 +32,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer { chunk -> println(chunk.items) } + open fun testJob(sampleTasklet: SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer { chunk -> println(chunk.items) } + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.kt index 139d559..80e39d2 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerprocessorwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.kt index f37734a..bb515f4 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerprocessorwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -36,20 +36,14 @@ open class SampleTasklet( println("totalCount: $totalCount") return Iterable { object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun write(chunk: Chunk) { println(chunk.items) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.kt index 03f8c4c..1af7a76 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerprocessorwriter/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,17 +33,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.readerprocessorwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.readerprocessorwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.kt index eee53a2..46b0390 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.kt index 46e43f2..c0170ae 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -36,13 +36,9 @@ open class SampleTasklet( println("totalCount: $totalCount") return Iterable { object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.kt index de584d5..ca9b7c4 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/readerwriter/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.iterable.readerwriter import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,18 +31,16 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.readerwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.readerwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.kt index 446c55d..3039a2f 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterator.callback import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.kt index f2e4aa9..405aa48 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.iterator.callback import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -39,13 +39,9 @@ open class SampleTasklet( override fun readIterator(executionContext: ExecutionContext): Iterator { println("totalCount: $totalCount") return object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } @@ -57,9 +53,7 @@ open class SampleTasklet( println("onCloseRead") } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun onOpenWrite(executionContext: ExecutionContext) { println("onOpenWrite") diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.kt index 1152fde..f4121e9 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/callback/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,19 +32,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.callback.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.callback.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.kt index cdecc7f..801aecd 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerprocessor import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.kt index 5490057..f829132 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/SampleTasklet.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerprocessor import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderProcessor import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -34,17 +34,11 @@ open class SampleTasklet( override fun readIterator(executionContext: ExecutionContext): Iterator { println("totalCount: $totalCount") return object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.kt index 3ed24a0..0556652 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessor/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerprocessor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,17 +32,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer { chunk -> println(chunk.items) } + open fun testJob(sampleTasklet: SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer { chunk -> println(chunk.items) } + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.kt index 5947b44..38e4ab4 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerprocessorwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.kt index 8701e52..bb31cd1 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerprocessorwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -35,19 +35,13 @@ open class SampleTasklet( override fun readIterator(executionContext: ExecutionContext): Iterator { println("totalCount: $totalCount") return object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun write(chunk: Chunk) { println(chunk.items) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.kt index 3131fdf..1f5f567 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerprocessorwriter/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,17 +33,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.readerprocessorwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.readerprocessorwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.kt index 1f5655c..b68b8dc 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.kt index 6c14f4a..f284c7b 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -35,13 +35,9 @@ open class SampleTasklet( override fun readIterator(executionContext: ExecutionContext): Iterator { println("totalCount: $totalCount") return object : Iterator { - override fun hasNext(): Boolean { - return count < totalCount - } + override fun hasNext(): Boolean = count < totalCount - override fun next(): Int { - return count++ - } + override fun next(): Int = count++ } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.kt index c70baeb..51b24c5 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/readerwriter/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.iterator.readerwriter import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,18 +31,16 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.readerwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.readerwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.kt index e8c61b0..e5e0810 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.simple.callback import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.kt index 7397470..ec11367 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/SampleTasklet.kt @@ -20,8 +20,8 @@ package com.navercorp.spring.batch.plus.sample.simple.callback import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk -import org.springframework.batch.item.ExecutionContext +import org.springframework.batch.infrastructure.item.Chunk +import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -36,13 +36,12 @@ open class SampleTasklet( println("onOpenRead") } - override fun read(): Int? { - return if (count < totalCount) { + override fun read(): Int? = + if (count < totalCount) { count++ } else { null } - } override fun onUpdateRead(executionContext: ExecutionContext) { println("onUpdateRead") @@ -52,9 +51,7 @@ open class SampleTasklet( println("onCloseRead") } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun onOpenWrite(executionContext: ExecutionContext) { println("onOpenWrite") diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.kt index 8da405f..9446a6e 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/callback/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,19 +32,17 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.callback.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.callback.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.kt index 0f0261f..3881a38 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.simple.readerprocessor import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.kt index 402f115..7d64b41 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.kt @@ -30,15 +30,12 @@ open class SampleTasklet( ) : ItemStreamSimpleReaderProcessor { private var count = 0 - override fun read(): Int? { - return if (count < totalCount) { + override fun read(): Int? = + if (count < totalCount) { count++ } else { null } - } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.kt index 64dc8b9..4c2a629 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.simple.readerprocessor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -32,17 +32,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer { chunk -> println(chunk.items) } + open fun testJob(sampleTasklet: SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer { chunk -> println(chunk.items) } + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.kt index 2fbbad9..2f159d6 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -32,13 +32,14 @@ open class SampleApplicationTest { @Test fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.kt index 22b3757..3c82748 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/SampleTasklet.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderProcessorWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk +import org.springframework.batch.infrastructure.item.Chunk import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -31,17 +31,14 @@ open class SampleTasklet( ) : ItemStreamSimpleReaderProcessorWriter { private var count = 0 - override fun read(): Int? { - return if (count < totalCount) { + override fun read(): Int? = + if (count < totalCount) { count++ } else { null } - } - override fun process(item: Int): String? { - return "'$item'" - } + override fun process(item: Int): String? = "'$item'" override fun write(chunk: Chunk) { println(chunk.items) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.kt index 57ad809..f67a4f9 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerprocessorwriter/TestJobConfig.kt @@ -22,7 +22,7 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -33,17 +33,16 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - processor(sampleTasklet.asItemProcessor()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + processor(sampleTasklet.asItemProcessor()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.kt index 9cb6263..49cc4ee 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleApplicationTest.kt @@ -20,9 +20,9 @@ package com.navercorp.spring.batch.plus.sample.simple.readerwriter import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.Job -import org.springframework.batch.core.JobParametersBuilder -import org.springframework.batch.core.launch.JobLauncher +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator import org.springframework.beans.factory.getBean import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -33,13 +33,14 @@ open class SampleApplicationTest { fun run() { val applicationContext = runApplication() - val jobLauncher = applicationContext.getBean() + val jobOperator = applicationContext.getBean() val job = applicationContext.getBean("testJob") - val jobParameters = JobParametersBuilder() - .addLong("totalCount", 20L) - .toJobParameters() - val jobExecution = jobLauncher.run(job, jobParameters) + val jobParameters = + JobParametersBuilder() + .addLong("totalCount", 20L) + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) assert(BatchStatus.COMPLETED == jobExecution.status) println(jobExecution) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.kt index 1945fa4..f43870c 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/SampleTasklet.kt @@ -20,7 +20,7 @@ package com.navercorp.spring.batch.plus.sample.simple.readerwriter import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderWriter import org.springframework.batch.core.configuration.annotation.StepScope -import org.springframework.batch.item.Chunk +import org.springframework.batch.infrastructure.item.Chunk import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component @@ -31,13 +31,12 @@ open class SampleTasklet( ) : ItemStreamSimpleReaderWriter { private var count = 0 - override fun read(): Int? { - return if (count < totalCount) { + override fun read(): Int? = + if (count < totalCount) { count++ } else { null } - } override fun write(chunk: Chunk) { println(chunk.items) diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.kt b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.kt index 2d7745f..a9e7cb3 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.kt +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/readerwriter/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.simple.readerwriter import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter -import org.springframework.batch.core.Job +import org.springframework.batch.core.job.Job import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.transaction.PlatformTransactionManager @@ -31,18 +31,16 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean - open fun testJob( - sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.readerwriter.SampleTasklet, - ): Job = batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(sampleTasklet.asItemStreamReader()) - writer(sampleTasklet.asItemStreamWriter()) + open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.readerwriter.SampleTasklet): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3, transactionManager) { + reader(sampleTasklet.asItemStreamReader()) + writer(sampleTasklet.asItemStreamWriter()) + } } } } - } } From 81526f0f617cc37a730ac111ae6cf950b2ddf0dd Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 15 Jun 2026 11:13:25 +0900 Subject: [PATCH 30/45] Remove Kotlin sample directories for APIs removed in Spring Batch 6.0 Signed-off-by: Taeik Lim --- .../meterregistry/SampleApplicationTest.kt | 46 ----------- .../meterregistry/TestJobConfig.kt | 44 ----------- .../SampleApplicationTest.kt | 46 ----------- .../observationconvention/TestJobConfig.kt | 44 ----------- .../repeatoperation/SampleApplicationTest.kt | 46 ----------- .../repeatoperation/TestJobConfig.kt | 79 ------------------- .../meterregistry/SampleApplicationTest.kt | 46 ----------- .../meterregistry/TestJobConfig.kt | 44 ----------- .../SampleApplicationTest.kt | 46 ----------- .../observationconvention/TestJobConfig.kt | 44 ----------- .../config/launcher/SampleApplicationTest.kt | 46 ----------- .../jobstep/config/launcher/TestJobConfig.kt | 67 ---------------- 12 files changed, 598 deletions(-) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt deleted file mode 100644 index 7a89075..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.job.configuration.meterregistry - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt deleted file mode 100644 index b8e47c5..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/meterregistry/TestJobConfig.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.job.configuration.meterregistry - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import io.micrometer.core.instrument.simple.SimpleMeterRegistry -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - meterRegistry(SimpleMeterRegistry()) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - } - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt deleted file mode 100644 index d2d385f..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.job.configuration.observationconvention - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt deleted file mode 100644 index 4fe8da1..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/observationconvention/TestJobConfig.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.job.configuration.observationconvention - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.observability.DefaultBatchJobObservationConvention -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - observationConvention(DefaultBatchJobObservationConvention()) - step("testStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - } - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt deleted file mode 100644 index 89752f0..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.repeatoperation - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt deleted file mode 100644 index d5f8374..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/repeatoperation/TestJobConfig.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.repeatoperation - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy -import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - val repeatOperations = - RepeatTemplate().apply { - setCompletionPolicy(SimpleCompletionPolicy(3)) - } - chunk(repeatOperations, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader = - object : ItemReader { - private var count = 0 - - override fun read(): Int? = - if (count < 11) { - count++ - } else { - null - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor = - ItemProcessor { item -> - item.toString() - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt deleted file mode 100644 index 2471cfd..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.configuration.meterregistry - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt deleted file mode 100644 index 753ce3b..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/meterregistry/TestJobConfig.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.configuration.meterregistry - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import io.micrometer.core.instrument.simple.SimpleMeterRegistry -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - meterRegistry(SimpleMeterRegistry()) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - } - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt deleted file mode 100644 index 1fd8cf5..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.configuration.observationconvention - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt deleted file mode 100644 index 7a5ce6e..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/observationconvention/TestJobConfig.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.configuration.observationconvention - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.observability.DefaultBatchStepObservationConvention -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - observationConvention(DefaultBatchStepObservationConvention()) - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - } - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt deleted file mode 100644 index be77e03..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.jobstep.config.launcher - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean("testJob") - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt deleted file mode 100644 index ef90ee3..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/launcher/TestJobConfig.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.jobstep.config.launcher - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, - private val jobOperator: JobLauncher, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - job(anotherJob()) { - launcher { job, jobParameters -> - println("launch anotherJob!!!") - jobOperator.start(job, jobParameters) - } - // same as - // launcher( - // object : JobLauncher { - // override fun run(job: Job, jobParameters: JobParameters): JobExecution { - // println("launch anotherJob!!!") - // return jobOperator.start(job, jobParameters) - // } - // } - // ) - } - } - } - } - - @Bean - open fun anotherJob() = - batch { - job("anotherJob") { - step("anotherJobStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } - } - } -} From ac894ed077a086c84ce8929d4fdd5139efb6bc39 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 15 Jun 2026 11:14:02 +0900 Subject: [PATCH 31/45] Add ChunkListener type arguments in Kotlin samples Signed-off-by: Taeik Lim --- .../chunkorientedstep/config/chunklistener/TestJobConfig.kt | 2 +- .../step/taskletstep/config/listenerobject/TestJobConfig.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt index 6589696..1ef5057 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt @@ -44,7 +44,7 @@ open class TestJobConfig( processor(testItemProcessor()) writer(testItemWriter()) listener( - object : ChunkListener { + object : ChunkListener { override fun beforeChunk(context: ChunkContext) { println("beforeChunk: $context") } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt index 29e7ebc..4fef2ec 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt @@ -40,7 +40,7 @@ open class TestJobConfig( step("testStep") { tasklet(testTasklet(), transactionManager) { listener( - object : ChunkListener { + object : ChunkListener { override fun beforeChunk(context: ChunkContext) { println("beforeChunk: $context") } From 2e587aa0bbe3bb5c78e378c11a9100555ab577c6 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Tue, 23 Jun 2026 10:05:29 +0900 Subject: [PATCH 32/45] Migrate StepExecutionSplitter sample to Spring Batch 6.0 API Signed-off-by: Taeik Lim --- .../partitionstep/splitter/direct/TestJobConfig.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt index 6d391b6..d44cae6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt @@ -33,8 +33,8 @@ import org.springframework.transaction.PlatformTransactionManager @Configuration open class TestJobConfig( private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, private val jobRepository: JobRepository, + private val transactionManager: PlatformTransactionManager, ) { @Bean open fun testJob(): Job = @@ -51,13 +51,9 @@ open class TestJobConfig( gridSize: Int, ): Set { val jobExecution = stepExecution.jobExecution - val stepExecutions = - (0 until gridSize) - .map { - jobExecution.createStepExecution("$stepName:partition-$it") - } - jobRepository.addAll(stepExecutions) - return stepExecutions.toSet() + return (0 until gridSize) + .map { jobRepository.createStepExecution("$stepName:partition-$it", jobExecution) } + .toSet() } }, ) From f44c24adadb0a6143dbb07d3bdbe2db360daea3d Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 24 Jun 2026 20:10:56 +0900 Subject: [PATCH 33/45] Remove kotlin-dsl-sample directories for APIs absent in ChunkOrientedStepBuilder Signed-off-by: Taeik Lim --- .../chunkpolicy/SampleApplicationTest.kt | 46 -------- .../chunkpolicy/TestJobConfig.kt | 74 ------------- .../backoffpolicy/SampleApplicationTest.kt | 46 -------- .../backoffpolicy/TestJobConfig.kt | 99 ----------------- .../keygenerator/SampleApplicationTest.kt | 46 -------- .../keygenerator/TestJobConfig.kt | 100 ------------------ .../noretry/SampleApplicationTest.kt | 46 -------- .../faulttolerant/noretry/TestJobConfig.kt | 88 --------------- .../noskip/SampleApplicationTest.kt | 46 -------- .../faulttolerant/noskip/TestJobConfig.kt | 88 --------------- .../processornontx/SampleApplicationTest.kt | 46 -------- .../processornontx/TestJobConfig.kt | 92 ---------------- .../SampleApplicationTest.kt | 46 -------- .../retrycontextcache/TestJobConfig.kt | 96 ----------------- .../rollback/SampleApplicationTest.kt | 46 -------- .../faulttolerant/rollback/TestJobConfig.kt | 82 -------------- 16 files changed, 1087 deletions(-) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt deleted file mode 100644 index 1416b79..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunkpolicy - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt deleted file mode 100644 index 706faab..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunkpolicy/TestJobConfig.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunkpolicy - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(SimpleCompletionPolicy(3), transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader = - object : ItemReader { - private var count = 0 - - override fun read(): Int? = - if (count < 11) { - count++ - } else { - null - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor = - ItemProcessor { item -> - item.toString() - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt deleted file mode 100644 index 4954317..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.backoffpolicy - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt deleted file mode 100644 index 0955772..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/backoffpolicy/TestJobConfig.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.backoffpolicy - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.retry.RetryContext -import org.springframework.retry.backoff.BackOffContext -import org.springframework.retry.backoff.BackOffPolicy -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - backOffPolicy( - object : BackOffPolicy { - override fun start(context: RetryContext?): BackOffContext? = null - - override fun backOff(backOffContext: BackOffContext?) { - println("backOff (context: $backOffContext)") - } - }, - ) - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - return count++ - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor { - var tryCount = 0 - - return ItemProcessor { item -> - if (item == 5 && tryCount < 3) { - ++tryCount - throw IllegalStateException("Error (tryCount: $tryCount)") - } - - item.toString() - } - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt deleted file mode 100644 index c6f22b9..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.keygenerator - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt deleted file mode 100644 index 34931de..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/keygenerator/TestJobConfig.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.keygenerator - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - keyGenerator { item -> - println("get key of $item") - item.toString() - } - // same as - // keyGenerator( - // object : KeyGenerator { - // override fun getKey(item: Any): Any { - // println("get key of $item") - // return item.toString() - // } - // } - // ) - retry() - retryLimit(4) - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - return count++ - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor { - var tryCount = 0 - - return ItemProcessor { item -> - if (item == 5 && tryCount < 3) { - ++tryCount - throw IllegalStateException("Error (tryCount: $tryCount)") - } - - item.toString() - } - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt deleted file mode 100644 index 76915eb..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.noretry - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.FAILED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt deleted file mode 100644 index aeb2f6e..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noretry/TestJobConfig.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.noretry - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(Int.MAX_VALUE) - noRetry() - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - return count++ - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor { - var tryCount = 0 - - return ItemProcessor { item -> - if (item == 5 && tryCount < 3) { - ++tryCount - throw IllegalArgumentException("I cannot be retried") - } - - item.toString() - } - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt deleted file mode 100644 index 4c60947..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.noskip - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.FAILED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt deleted file mode 100644 index f28ff96..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/noskip/TestJobConfig.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.noskip - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - skip() - skipLimit(4) - noSkip() - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - return count++ - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor = - ItemProcessor { item -> - if (item % 3 == 0) { - throw IllegalStateException("Error") - } - - if (item == 5) { - throw IllegalArgumentException("I cannot be skipped") - } - - item.toString() - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt deleted file mode 100644 index 7f447c9..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.processornontx - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt deleted file mode 100644 index c9002ef..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/processornontx/TestJobConfig.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.processornontx - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - processorNonTransactional() - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - val next = count - println("read: $next") - count++ - return next - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor { - var tryCount = 0 - - return ItemProcessor { item -> - println("process: $item") - if (item == 5 && tryCount < 3) { - ++tryCount - throw IllegalStateException("Error (tryCount: $tryCount)") - } - - item.toString() - } - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt deleted file mode 100644 index b0f4071..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.retrycontextcache - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt deleted file mode 100644 index 2159eed..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrycontextcache/TestJobConfig.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.retrycontextcache - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.retry.policy.MapRetryContextCache -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - retryContextCache( - object : MapRetryContextCache() { - override fun containsKey(key: Any?): Boolean { - println("contains key: $key") - return super.containsKey(key) - } - }, - ) - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - return count++ - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor { - var tryCount = 0 - - return ItemProcessor { item -> - if (item == 5 && tryCount < 3) { - ++tryCount - throw IllegalStateException("Error (tryCount: $tryCount)") - } - - item.toString() - } - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt deleted file mode 100644 index 09e85da..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.rollback - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt deleted file mode 100644 index 2bb8e73..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/rollback/TestJobConfig.kt +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.faulttolerant.rollback - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemProcessor -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - faultTolerant { - noRollback() - } - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader { - return object : ItemReader { - private var count = 0 - - override fun read(): Int? { - if (count < 11) { - return count++ - } else { - return null - } - } - } - } - - @Bean - open fun testItemProcessor(): ItemProcessor = - ItemProcessor { item -> - if (item % 3 == 0) { - throw IllegalStateException("Error") - } - - item.toString() - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} From c04cb5aad71600c78dd61155f5a413368cd008ff Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 24 Jun 2026 20:42:01 +0900 Subject: [PATCH 34/45] Remove kotlin-dsl-sample directories for APIs absent in ChunkOrientedStepBuilder Signed-off-by: Taeik Lim --- .../exceptionhandler/SampleApplicationTest.kt | 46 ----------- .../config/exceptionhandler/TestJobConfig.kt | 71 ----------------- .../stepoperation/SampleApplicationTest.kt | 46 ----------- .../config/stepoperation/TestJobConfig.kt | 78 ------------------- 4 files changed, 241 deletions(-) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt deleted file mode 100644 index 3b7bbfa..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.exceptionhandler - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.FAILED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt deleted file mode 100644 index aff196c..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/exceptionhandler/TestJobConfig.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.exceptionhandler - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - writer(testItemWriter()) - exceptionHandler { _, throwable -> - println("handle exception ${throwable.message}") - throw throwable - } - // same as - // exceptionHandler( - // object : ExceptionHandler { - // override fun handleException(context: RepeatContext, throwable: Throwable) { - // println("handle exception ${throwable.message}") - // throw throwable - // } - // } - // ) - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader = - ItemReader { - throw IllegalStateException("Error in read") - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("write $items") - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt deleted file mode 100644 index f10bec1..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.stepoperation - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt deleted file mode 100644 index 08ba77e..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stepoperation/TestJobConfig.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.stepoperation - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.job.Job -import org.springframework.batch.infrastructure.item.ItemReader -import org.springframework.batch.infrastructure.item.ItemWriter -import org.springframework.batch.infrastructure.repeat.RepeatCallback -import org.springframework.batch.infrastructure.repeat.RepeatOperations -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3, transactionManager) { - reader(testItemReader()) - writer(testItemWriter()) - stepOperations( - object : RepeatOperations { - override fun iterate(callback: RepeatCallback): RepeatStatus { - val delegate = RepeatTemplate() - println("custom iterate") - return delegate.iterate(callback) - } - }, - ) - } - } - } - } - - @Bean - open fun testItemReader(): ItemReader = - object : ItemReader { - private var count = 0 - - override fun read(): Int? = - if (count < 20) { - count++ - } else { - null - } - } - - @Bean - open fun testItemWriter(): ItemWriter = - ItemWriter { items -> - println("[${Thread.currentThread().name}] write $items") - } -} From a5f66e16ca3d41c54d4da601f354f0206d2079c1 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 24 Jun 2026 20:55:27 +0900 Subject: [PATCH 35/45] Migrate kotlin-dsl-sample chunkorientedstep samples to ChunkOrientedStep path Signed-off-by: Taeik Lim --- .../chunksize/TestJobConfig.kt | 3 +- .../chunklistener/TestJobConfig.kt | 13 ++-- .../annotationlistener/mixed/TestJobConfig.kt | 3 +- .../processorlistener/TestJobConfig.kt | 3 +- .../readerlistener/TestJobConfig.kt | 3 +- .../writerlistener/TestJobConfig.kt | 3 +- .../config/chunklistener/TestJobConfig.kt | 15 ++-- .../config/executor/TestJobConfig.kt | 7 +- .../config/processorlistener/TestJobConfig.kt | 3 +- .../config/readerlistener/TestJobConfig.kt | 3 +- .../config/stream/TestJobConfig.kt | 3 +- .../transactionattribute/TestJobConfig.kt | 3 +- .../config/writerlistener/TestJobConfig.kt | 3 +- .../faulttolerant/retry/TestJobConfig.kt | 10 +-- .../retrylistener/TestJobConfig.kt | 68 ++++++++++--------- .../retrypolicy/TestJobConfig.kt | 12 ++-- .../faulttolerant/skip/TestJobConfig.kt | 10 +-- .../skiplistener/TestJobConfig.kt | 44 ++++++------ .../skiplistenerannotation/TestJobConfig.kt | 10 +-- .../faulttolerant/skippolicy/TestJobConfig.kt | 18 ++--- 20 files changed, 126 insertions(+), 111 deletions(-) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt index b5a4227..1b7d803 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt @@ -37,7 +37,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt index a05e088..55887c2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt @@ -23,7 +23,7 @@ import org.springframework.batch.core.annotation.AfterChunk import org.springframework.batch.core.annotation.AfterChunkError import org.springframework.batch.core.annotation.BeforeChunk import org.springframework.batch.core.job.Job -import org.springframework.batch.core.scope.context.ChunkContext +import org.springframework.batch.infrastructure.item.Chunk import org.springframework.batch.infrastructure.item.ItemProcessor import org.springframework.batch.infrastructure.item.ItemReader import org.springframework.batch.infrastructure.item.ItemWriter @@ -38,13 +38,13 @@ open class TestJobConfig( ) { class TestListener { @BeforeChunk - fun beforeChunk(context: ChunkContext) { - println("beforeChunk: $context") + fun beforeChunk(chunk: Chunk) { + println("beforeChunk: $chunk") } @AfterChunk - fun afterChunk(context: ChunkContext) { - println("afterChunk: $context") + fun afterChunk(chunk: Chunk) { + println("afterChunk: $chunk") } @AfterChunkError @@ -57,7 +57,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt index 9066e26..656d1d6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt @@ -61,7 +61,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt index 8fe6e61..68d1d90 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt @@ -63,7 +63,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt index 8553968..3adc0bb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt @@ -57,7 +57,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt index 6f704c1..90c6a2f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt @@ -61,7 +61,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt index 1ef5057..0b58643 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt @@ -21,7 +21,7 @@ package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.chu import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job import org.springframework.batch.core.listener.ChunkListener -import org.springframework.batch.core.scope.context.ChunkContext +import org.springframework.batch.infrastructure.item.Chunk import org.springframework.batch.infrastructure.item.ItemProcessor import org.springframework.batch.infrastructure.item.ItemReader import org.springframework.batch.infrastructure.item.ItemWriter @@ -39,21 +39,22 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) listener( object : ChunkListener { - override fun beforeChunk(context: ChunkContext) { - println("beforeChunk: $context") + override fun beforeChunk(chunk: Chunk) { + println("beforeChunk: $chunk") } - override fun afterChunk(context: ChunkContext) { - println("afterChunk: $context") + override fun afterChunk(chunk: Chunk) { + println("afterChunk: $chunk") } - override fun afterChunkError(context: ChunkContext) { + override fun onChunkError(exception: Exception, chunk: Chunk) { } }, ) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt index bc39031..975a3ec 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt @@ -24,8 +24,8 @@ import org.springframework.batch.infrastructure.item.ItemReader import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.core.task.AsyncTaskExecutor import org.springframework.core.task.SimpleAsyncTaskExecutor -import org.springframework.core.task.TaskExecutor import org.springframework.transaction.PlatformTransactionManager @Configuration @@ -34,14 +34,15 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun customExecutor(): TaskExecutor = SimpleAsyncTaskExecutor() + open fun customExecutor(): AsyncTaskExecutor = SimpleAsyncTaskExecutor() @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) writer(testItemWriter()) taskExecutor(customExecutor()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt index 2afd988..12d110f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt @@ -38,7 +38,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt index 1a20e7f..134b360 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt @@ -38,7 +38,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt index 51e7483..4288a82 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/stream/TestJobConfig.kt @@ -39,7 +39,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt index 6fb6054..2a72aff 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionattribute/TestJobConfig.kt @@ -38,7 +38,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) writer(testItemWriter()) transactionAttribute( diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt index e80dfbd..ac169cb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt @@ -39,7 +39,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt index cec07eb..1281de5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retry/TestJobConfig.kt @@ -37,14 +37,14 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) - faultTolerant { - retry() - retryLimit(4) - } + faultTolerant() + retry() + retryLimit(4L) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt index 7ebbe7d..5ed7999 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrylistener/TestJobConfig.kt @@ -25,9 +25,11 @@ import org.springframework.batch.infrastructure.item.ItemReader import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import org.springframework.retry.RetryCallback -import org.springframework.retry.RetryContext -import org.springframework.retry.RetryListener +import org.springframework.core.retry.RetryException +import org.springframework.core.retry.RetryListener +import org.springframework.core.retry.RetryPolicy +import org.springframework.core.retry.RetryState +import org.springframework.core.retry.Retryable import org.springframework.transaction.PlatformTransactionManager @Configuration @@ -40,41 +42,41 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) - faultTolerant { - listener( - object : RetryListener { - override fun open( - context: RetryContext?, - callback: RetryCallback?, - ): Boolean { - println("RetryListener::open (context: $context") - return true - } + faultTolerant() + retryListener( + object : RetryListener { + override fun beforeRetry( + retryPolicy: RetryPolicy, + retryable: Retryable<*>, + retryState: RetryState, + ) { + println("RetryListener::beforeRetry (state: $retryState)") + } - override fun close( - context: RetryContext?, - callback: RetryCallback?, - throwable: Throwable?, - ) { - println("RetryListener::close (error: ${throwable?.message})") - } + override fun onRetryFailure( + retryPolicy: RetryPolicy, + retryable: Retryable<*>, + throwable: Throwable, + ) { + println("RetryListener::onRetryFailure (error: ${throwable.message})") + } - override fun onError( - context: RetryContext?, - callback: RetryCallback?, - throwable: Throwable?, - ) { - println("RetryListener::onError (error: ${throwable?.message})") - } - }, - ) - retry() - retryLimit(4) - } + override fun onRetryPolicyExhaustion( + retryPolicy: RetryPolicy, + retryable: Retryable<*>, + exception: RetryException, + ) { + println("RetryListener::onRetryPolicyExhaustion (error: ${exception.message})") + } + }, + ) + retry() + retryLimit(4L) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt index 6bbe649..6b456af 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/retrypolicy/TestJobConfig.kt @@ -25,7 +25,7 @@ import org.springframework.batch.infrastructure.item.ItemReader import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import org.springframework.retry.policy.SimpleRetryPolicy +import org.springframework.core.retry.RetryPolicy import org.springframework.transaction.PlatformTransactionManager @Configuration @@ -38,14 +38,14 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) - faultTolerant { - retry() - retryPolicy(SimpleRetryPolicy(4)) - } + faultTolerant() + retry() + retryPolicy(RetryPolicy.withMaxRetries(4)) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt index e246455..fa2da1d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skip/TestJobConfig.kt @@ -37,14 +37,14 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) - faultTolerant { - skip() - skipLimit(4) - } + faultTolerant() + skip() + skipLimit(4L) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt index a7af6a2..e6340d9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistener/TestJobConfig.kt @@ -38,33 +38,33 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) - faultTolerant { - listener( - object : SkipListener { - override fun onSkipInRead(t: Throwable) { - println("Ignore exception of read (exception: ${t.message})") - } + faultTolerant() + skipListener( + object : SkipListener { + override fun onSkipInRead(t: Throwable) { + println("Ignore exception of read (exception: ${t.message})") + } - override fun onSkipInProcess( - item: Int, - t: Throwable, - ) { - } + override fun onSkipInProcess( + item: Int, + t: Throwable, + ) { + } - override fun onSkipInWrite( - item: String, - t: Throwable, - ) { - } - }, - ) - skip() - skipLimit(1) - } + override fun onSkipInWrite( + item: String, + t: Throwable, + ) { + } + }, + ) + skip() + skipLimit(1L) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt index 959b19e..3f05b04 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skiplistenerannotation/TestJobConfig.kt @@ -63,15 +63,15 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) listener(TestListener()) - faultTolerant { - skip() - skipLimit(1) - } + faultTolerant() + skip() + skipLimit(1L) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt index 65dbc3f..d20743a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/skippolicy/TestJobConfig.kt @@ -38,18 +38,18 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) - faultTolerant { - skipPolicy( - LimitCheckingItemSkipPolicy( - 4, - mapOf(RuntimeException::class.java to true), - ), - ) - } + faultTolerant() + skipPolicy( + LimitCheckingItemSkipPolicy( + 4, + mapOf(RuntimeException::class.java to true), + ), + ) } } } From b99a33627f8da7ce9ca4d67e70b854d0c403a92d Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 24 Jun 2026 21:05:46 +0900 Subject: [PATCH 36/45] Add JobStepBuilderDsl.operator sample Signed-off-by: Taeik Lim --- .../config/operator/SampleApplicationTest.kt | 46 +++++++++++++ .../jobstep/config/operator/TestJobConfig.kt | 66 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt new file mode 100644 index 0000000..670d85b --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt @@ -0,0 +1,46 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.jobstep.config.operator + +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class SampleApplicationTest { + @Test + fun run() { + val applicationContext = runApplication() + val jobOperator = applicationContext.getBean() + val job = applicationContext.getBean("testJob") + + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.COMPLETED == jobExecution.status) + println(jobExecution) + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt new file mode 100644 index 0000000..c2fdb9e --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt @@ -0,0 +1,66 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.jobstep.config.operator + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.launch.JobOperator +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.transaction.PlatformTransactionManager + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, + private val transactionManager: PlatformTransactionManager, + private val jobOperator: JobOperator, +) { + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + job(anotherJob()) { + operator(loggingJobOperator(jobOperator)) + } + } + } + } + + private fun loggingJobOperator(delegate: JobOperator): JobOperator = + object : JobOperator by delegate { + override fun start(job: Job, jobParameters: JobParameters): JobExecution { + println("launch ${job.name}!!!") + return delegate.start(job, jobParameters) + } + } + + @Bean + open fun anotherJob() = + batch { + job("anotherJob") { + step("anotherJobStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + } +} From 05ebe477fda36ffc5fa4dbddd386a6f74900fe1c Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 26 Jun 2026 09:13:03 +0900 Subject: [PATCH 37/45] Reformat chunklistener and operator samples to satisfy ktlint Signed-off-by: Taeik Lim --- .../chunkorientedstep/config/chunklistener/TestJobConfig.kt | 5 ++++- .../sample/step/jobstep/config/operator/TestJobConfig.kt | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt index 0b58643..68b9481 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt @@ -54,7 +54,10 @@ open class TestJobConfig( println("afterChunk: $chunk") } - override fun onChunkError(exception: Exception, chunk: Chunk) { + override fun onChunkError( + exception: Exception, + chunk: Chunk, + ) { } }, ) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt index c2fdb9e..c4996f8 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt @@ -48,7 +48,10 @@ open class TestJobConfig( private fun loggingJobOperator(delegate: JobOperator): JobOperator = object : JobOperator by delegate { - override fun start(job: Job, jobParameters: JobParameters): JobExecution { + override fun start( + job: Job, + jobParameters: JobParameters, + ): JobExecution { println("launch ${job.name}!!!") return delegate.start(job, jobParameters) } From 4454ce0ca311eab7447e7956114a10cb512e1e3a Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 26 Jun 2026 09:13:09 +0900 Subject: [PATCH 38/45] Remove kotlin-dsl-sample taskletstep listenerannotation sample Signed-off-by: Taeik Lim --- .../SampleApplicationTest.kt | 46 ------------ .../listenerannotation/TestJobConfig.kt | 72 ------------------- 2 files changed, 118 deletions(-) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt deleted file mode 100644 index f590f68..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenerannotation - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean() - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt deleted file mode 100644 index 4a268d8..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenerannotation - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -import org.springframework.batch.core.annotation.AfterChunk -import org.springframework.batch.core.annotation.AfterChunkError -import org.springframework.batch.core.annotation.BeforeChunk -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.scope.context.ChunkContext -import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.infrastructure.repeat.RepeatStatus -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.transaction.PlatformTransactionManager - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - class TestListener { - @BeforeChunk - fun beforeChunk(context: ChunkContext) { - println("beforeChunk: $context") - } - - @AfterChunk - fun afterChunk(context: ChunkContext) { - println("afterChunk: $context") - } - - @AfterChunkError - fun afterChunkError() { - } - } - - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - tasklet(testTasklet(), transactionManager) { - listener(TestListener()) - } - } - } - } - - @Bean - open fun testTasklet(): Tasklet = - Tasklet { _, _ -> - println("run testTasklet") - RepeatStatus.FINISHED - } -} From 91cad98dd0c02f678f063490fb2499ad0c4390b7 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 28 Jun 2026 16:32:23 +0900 Subject: [PATCH 39/45] Polish jobStep tests, samples Signed-off-by: Taeik Lim --- .../JobStepBuilderDslIntegrationTest.kt | 240 ++++++++++++++++++ .../StepBuilderDslIntegrationTest.kt | 164 ------------ .../step/JobStepBuilderDslTest.kt | 4 + .../config/extractor/SampleApplicationTest.kt | 1 + .../jobstep/config/extractor/TestJobConfig.kt | 9 +- .../config/operator/SampleApplicationTest.kt | 1 + .../jobstep/config/operator/TestJobConfig.kt | 1 + .../bean/SampleApplicationTest.kt | 3 +- .../{ => creation}/bean/TestJobConfig.kt | 3 +- .../variable/SampleApplicationTest.kt | 3 +- .../{ => creation}/variable/TestJobConfig.kt | 3 +- 11 files changed, 263 insertions(+), 169 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/{ => creation}/bean/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/{ => creation}/bean/TestJobConfig.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/{ => creation}/variable/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/{ => creation}/variable/TestJobConfig.kt (95%) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt new file mode 100644 index 0000000..e1c408b --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt @@ -0,0 +1,240 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.launch.JobOperator +import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager +import org.springframework.beans.factory.BeanFactory +import org.springframework.beans.factory.getBean +import org.springframework.context.annotation.AnnotationConfigApplicationContext +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.support.registerBean +import org.springframework.jdbc.datasource.DataSourceTransactionManager +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType +import org.springframework.transaction.TransactionManager +import javax.sql.DataSource + +/** + * Integration tests for creating and executing job steps through the public Kotlin DSL. + */ +internal class JobStepBuilderDslIntegrationTest { + + @Test + fun testJobBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var stepCallCount = 0 + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++stepCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("testJob2") { + testJob2 + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + jobBean("testJob2") + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(stepCallCount).isEqualTo(1) + } + + @Test + fun testJobBeanWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var stepCallCount = 0 + var jobParametersExtractorCallCount = 0 + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++stepCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("testJob2") { + testJob2 + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + jobBean("testJob2") { + parametersExtractor { _, _ -> + ++jobParametersExtractorCallCount + JobParameters() + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(stepCallCount).isEqualTo(1) + assertThat(jobParametersExtractorCallCount).isEqualTo(1) + } + + @Test + fun testJobWithJobVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var stepCallCount = 0 + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++stepCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + job(testJob2) + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(stepCallCount).isEqualTo(1) + } + + @Test + fun testJobWithJobVariableAndInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var jobCallCount = 0 + var jobParametersExtractorCallCount = 0 + val testJob2 = + batch { + job("testJob2") { + step("testStep2") { + ++jobCallCount + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + job(testJob2) { + parametersExtractor { _, _ -> + ++jobParametersExtractorCallCount + JobParameters() + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobCallCount).isEqualTo(1) + assertThat(jobParametersExtractorCallCount).isEqualTo(1) + } + + @Configuration + @EnableBatchProcessing + @EnableJdbcJobRepository( + dataSourceRef = "metadataDataSource", + transactionManagerRef = "metadataTransactionManager", + ) + private open class TestConfiguration { + @Bean + open fun batchDsl( + beanFactory: BeanFactory, + jobRepository: JobRepository, + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) + + @Bean + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) + + @Bean + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .addScript("/org/springframework/batch/core/schema-h2.sql") + .generateUniqueName(true) + .build() + } +} diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 98f9bdd..6b65d07 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -449,170 +449,6 @@ internal class StepBuilderDslIntegrationTest { assertThat(partitionHandlerCallCount).isEqualTo(1) } - @Test - fun testJobBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var stepCallCount = 0 - val testJob2 = - batch { - job("testJob2") { - step("testStep2") { - ++stepCallCount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("testJob2") { - testJob2 - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - jobBean("testJob2") - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(stepCallCount).isEqualTo(1) - } - - @Test - fun testJobBeanWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var stepCallCount = 0 - var jobParametersExtractorCallCount = 0 - val testJob2 = - batch { - job("testJob2") { - step("testStep2") { - ++stepCallCount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("testJob2") { - testJob2 - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - jobBean("testJob2") { - parametersExtractor { _, _ -> - ++jobParametersExtractorCallCount - JobParameters() - } - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(stepCallCount).isEqualTo(1) - assertThat(jobParametersExtractorCallCount).isEqualTo(1) - } - - @Test - fun testJobWithJobVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var stepCallCount = 0 - val testJob2 = - batch { - job("testJob2") { - step("testStep2") { - ++stepCallCount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - job(testJob2) - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(stepCallCount).isEqualTo(1) - } - - @Test - fun testJobWithJobVariableAndInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var jobCallcount = 0 - var jobParametersExtractorCallCount = 0 - val testJob2 = - batch { - job("testJob2") { - step("testStep2") { - ++jobCallcount - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - job(testJob2) { - parametersExtractor { _, _ -> - ++jobParametersExtractorCallCount - JobParameters() - } - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobCallcount).isEqualTo(1) - assertThat(jobParametersExtractorCallCount).isEqualTo(1) - } - @Test fun testFlowBean() { // given diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt index 8e3c8f2..76711b8 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslTest.kt @@ -28,7 +28,11 @@ import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.JobStepBuilder import org.springframework.batch.core.step.job.JobParametersExtractor +/** + * Unit tests for JobStepBuilderDsl's delegation to Spring Batch's JobStepBuilder. + */ internal class JobStepBuilderDslTest { + @Test fun testOperator() { // given diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt index 781db97..962cf49 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt index d728f94..dce102f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/extractor/TestJobConfig.kt @@ -31,6 +31,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { @@ -62,7 +63,13 @@ open class TestJobConfig( batch { job("anotherJob") { step("anotherJobStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + tasklet( + { contribution, _ -> + println("extra: '${contribution.stepExecution.jobParameters.getString("extra")}'") + RepeatStatus.FINISHED + }, + transactionManager, + ) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt index 670d85b..cfb28ac 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt index c4996f8..5415068 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/operator/TestJobConfig.kt @@ -34,6 +34,7 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, private val jobOperator: JobOperator, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/bean/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/bean/SampleApplicationTest.kt index 3ab3348..291a4eb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.jobstep.bean +package com.navercorp.spring.batch.plus.sample.step.jobstep.creation.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/bean/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/bean/TestJobConfig.kt index afe71a6..018ae82 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.jobstep.bean +package com.navercorp.spring.batch.plus.sample.step.jobstep.creation.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -30,6 +30,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/variable/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/variable/SampleApplicationTest.kt index 2e97f84..19432be 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/variable/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.jobstep.variable +package com.navercorp.spring.batch.plus.sample.step.jobstep.creation.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/variable/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/variable/TestJobConfig.kt index fe1953d..8016b88 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.jobstep.variable +package com.navercorp.spring.batch.plus.sample.step.jobstep.creation.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -30,6 +30,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { From 429c816ac4507e09269118a5973a81d90656914c Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 28 Jun 2026 16:57:53 +0900 Subject: [PATCH 40/45] Polish flowStep tests, samples Signed-off-by: Taeik Lim --- .../FlowStepBuilderDslIntegrationTest.kt | 222 ++++++++++++++++++ .../StepBuilderDslIntegrationTest.kt | 146 ------------ .../step/FlowStepBuilderDslTest.kt | 4 + .../bean/SampleApplicationTest.kt | 3 +- .../{ => creation}/bean/TestJobConfig.kt | 3 +- .../init}/SampleApplicationTest.kt | 3 +- .../{ => creation}/init/TestJobConfig.kt | 3 +- .../variable}/SampleApplicationTest.kt | 3 +- .../{ => creation}/variable/TestJobConfig.kt | 3 +- 9 files changed, 238 insertions(+), 152 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/{ => creation}/bean/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/{ => creation}/bean/TestJobConfig.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/{variable => creation/init}/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/{ => creation}/init/TestJobConfig.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/{init => creation/variable}/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/{ => creation}/variable/TestJobConfig.kt (95%) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt new file mode 100644 index 0000000..56ac9ef --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt @@ -0,0 +1,222 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.launch.JobOperator +import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager +import org.springframework.beans.factory.BeanFactory +import org.springframework.beans.factory.getBean +import org.springframework.context.annotation.AnnotationConfigApplicationContext +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.support.registerBean +import org.springframework.jdbc.datasource.DataSourceTransactionManager +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType +import org.springframework.transaction.TransactionManager +import javax.sql.DataSource + +/** + * Integration tests for creating and executing flow steps through the public Kotlin DSL. + */ +internal class FlowStepBuilderDslIntegrationTest { + + @Test + fun testFlowBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testStep2CallCount = 0 + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("testFlow") { + testFlow + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + flowBean("testFlow") + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testStep2CallCount).isEqualTo(1) + } + + @Test + fun testFlowWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testStep2CallCount = 0 + + // when + val job = + batch { + job("testJob") { + step("testStep") { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testStep2CallCount).isEqualTo(1) + } + + @Test + fun testFlowWithVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testStep2CallCount = 0 + val testFlow = + batch { + flow("testFlow") { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + flow(testFlow) + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testStep2CallCount).isEqualTo(1) + } + + @Configuration + @EnableBatchProcessing + @EnableJdbcJobRepository( + dataSourceRef = "metadataDataSource", + transactionManagerRef = "metadataTransactionManager", + ) + private open class TestConfiguration { + @Bean + open fun batchDsl( + beanFactory: BeanFactory, + jobRepository: JobRepository, + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) + + @Bean + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) + + @Bean + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .addScript("/org/springframework/batch/core/schema-h2.sql") + .generateUniqueName(true) + .build() + } +} diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 6b65d07..646fdef 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -449,152 +449,6 @@ internal class StepBuilderDslIntegrationTest { assertThat(partitionHandlerCallCount).isEqualTo(1) } - @Test - fun testFlowBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - val testFlow = - batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("testFlow") { - testFlow - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - flowBean("testFlow") - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) - } - - @Test - fun testFlowWithLambda() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - - // when - val job = - batch { - job("testJob") { - step("testStep") { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) - } - - @Test - fun testFlowWithVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - val testFlow = - batch { - flow("testFlow") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - flow(testFlow) - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) - } - @Configuration @EnableBatchProcessing @EnableJdbcJobRepository( diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt index 519e921..b23f026 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslTest.kt @@ -25,7 +25,11 @@ import org.junit.jupiter.api.Test import org.springframework.batch.core.step.Step import org.springframework.batch.core.step.builder.FlowStepBuilder +/** + * Unit tests for FlowStepBuilderDsl's delegation to Spring Batch's FlowStepBuilder. + */ internal class FlowStepBuilderDslTest { + @Test fun testBuild() { // given diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/bean/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/bean/SampleApplicationTest.kt index eff26a9..ebf1e89 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.flowstep.bean +package com.navercorp.spring.batch.plus.sample.step.flowstep.creation.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/bean/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/bean/TestJobConfig.kt index e5f4254..3030c21 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.flowstep.bean +package com.navercorp.spring.batch.plus.sample.step.flowstep.creation.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -31,6 +31,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/SampleApplicationTest.kt index 1b38330..5a80abd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.flowstep.variable +package com.navercorp.spring.batch.plus.sample.step.flowstep.creation.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/TestJobConfig.kt index 8205497..2d04d2e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.flowstep.init +package com.navercorp.spring.batch.plus.sample.step.flowstep.creation.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -30,6 +30,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/SampleApplicationTest.kt index 40bc960..840ad3f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/init/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.flowstep.init +package com.navercorp.spring.batch.plus.sample.step.flowstep.creation.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/TestJobConfig.kt index c6d052f..3b2d2d3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.flowstep.variable +package com.navercorp.spring.batch.plus.sample.step.flowstep.creation.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -31,6 +31,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { From ae332a244742a3afb7479154e26f58509b03e829 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 28 Jun 2026 17:00:38 +0900 Subject: [PATCH 41/45] Move step integration tests into step package Signed-off-by: Taeik Lim --- .../{ => step}/FlowStepBuilderDslIntegrationTest.kt | 3 ++- .../{ => step}/JobStepBuilderDslIntegrationTest.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ => step}/FlowStepBuilderDslIntegrationTest.kt (98%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ => step}/JobStepBuilderDslIntegrationTest.kt (98%) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt similarity index 98% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt index 56ac9ef..a319ac6 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt @@ -16,8 +16,9 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration +package com.navercorp.spring.batch.plus.kotlin.configuration.step +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt similarity index 98% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt index e1c408b..96a2cd4 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt @@ -16,8 +16,9 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration +package com.navercorp.spring.batch.plus.kotlin.configuration.step +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus From d42eff3a3656a41e007ddc11d7de36276509b559 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 28 Jun 2026 19:17:30 +0900 Subject: [PATCH 42/45] Polish taskletStep tests, samples Signed-off-by: Taeik Lim --- .../StepBuilderDslIntegrationTest.kt | 255 --------------- .../step/FlowStepBuilderDslIntegrationTest.kt | 2 +- .../TaskletStepBuilderDslIntegrationTest.kt | 296 ++++++++++++++++++ .../step/TaskletStepBuilderDsl.kt | 14 +- .../step/TaskletStepBuilderDslTest.kt | 22 ++ .../sample/step/taskletstep/config/README.md | 6 + .../exceptionhandler/SampleApplicationTest.kt | 1 + .../config/exceptionhandler/TestJobConfig.kt | 1 + .../config/executor/SampleApplicationTest.kt | 1 + .../config/executor/TestJobConfig.kt | 1 + .../SampleApplicationTest.kt | 3 +- .../listenerannotation/TestJobConfig.kt | 79 +++++ .../listenerobject/SampleApplicationTest.kt | 1 + .../config/listenerobject/TestJobConfig.kt | 1 + .../stepoperation/SampleApplicationTest.kt | 1 + .../config/stepoperation/TestJobConfig.kt | 1 + .../config/stream/SampleApplicationTest.kt | 1 + .../config/stream/TestJobConfig.kt | 1 + .../SampleApplicationTest.kt | 1 + .../transactionattribute/TestJobConfig.kt | 1 + .../SampleApplicationTest.kt | 47 +++ .../transactionmanager/TestJobConfig.kt | 53 ++++ .../step/taskletstep/creation/README.md | 6 + .../SampleApplicationTest.kt | 48 +++ .../TestJobConfig.kt | 54 ++++ .../SampleApplicationTest.kt | 3 +- .../TestJobConfig.kt | 3 +- .../SampleApplicationTest.kt | 47 +++ .../TestJobConfig.kt | 49 +++ .../SampleApplicationTest.kt | 47 +++ .../TestJobConfig.kt | 3 +- 31 files changed, 787 insertions(+), 262 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/README.md rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/{variable => config/listenerannotation}/SampleApplicationTest.kt (98%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/TestJobConfig.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/{bean => creation/beanwithtransactionmanager}/SampleApplicationTest.kt (97%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/{bean => creation/beanwithtransactionmanager}/TestJobConfig.kt (98%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/{variable => creation/variablewithtransactionmanager}/TestJobConfig.kt (97%) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 646fdef..9275326 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -19,7 +19,6 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing @@ -27,8 +26,6 @@ import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepo import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobLauncher import org.springframework.batch.core.repository.JobRepository -import org.springframework.batch.core.step.tasklet.Tasklet -import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory @@ -36,265 +33,13 @@ import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import org.springframework.context.support.registerBean import org.springframework.jdbc.datasource.DataSourceTransactionManager import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager import javax.sql.DataSource -@Suppress("DEPRECATION") internal class StepBuilderDslIntegrationTest { - @Test - fun testDeprecatedTaskletBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - var taskletCallCount = 0 - val tasklet = - Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } - context.registerBean("testTasklet") { - tasklet - } - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet") - } - } - } - } - } - - @Test - fun testDeprecatedTaskletBeanWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - var taskletCallCount = 0 - var taskExecutorCallCount = 0 - val tasklet = - Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } - context.registerBean("testTasklet") { - tasklet - } - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet") { - taskExecutor { - ++taskExecutorCallCount - it.run() - } - } - } - } - } - } - } - - @Test - fun testDeprecatedTaskletWithLambda() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - var taskletCallCount = 0 - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } - } - } - } - } - } - - @Test - fun testDeprecatedTaskletWithLambdaAndInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - var taskletCallCount = 0 - var taskExecutorCallCount = 0 - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - }, - ) { - taskExecutor { - ++taskExecutorCallCount - it.run() - } - } - } - } - } - } - } - - @Test - fun testTaskletBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var taskletCallCount = 0 - val tasklet = - Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } - context.registerBean("testTasklet") { - tasklet - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet", ResourcelessTransactionManager()) - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(taskletCallCount).isEqualTo(1) - } - - @Test - fun testTaskletBeanWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var taskletCallCount = 0 - var taskExecutorCallCount = 0 - val tasklet = - Tasklet { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - } - context.registerBean("testTasklet") { - tasklet - } - - // when - val job = - batch { - job("testJob") { - step("testStep") { - taskletBean("testTasklet", ResourcelessTransactionManager()) { - taskExecutor { - ++taskExecutorCallCount - it.run() - } - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(taskletCallCount).isEqualTo(1) - assertThat(taskExecutorCallCount).isEqualTo(1) - } - - @Test - fun testTaskletWithLambda() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var taskletCallCount = 0 - - // when - val job = - batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(taskletCallCount).isEqualTo(1) - } - - @Test - fun testTaskletWithLambdaAndInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var taskletCallCount = 0 - var taskExecutorCallCount = 0 - - // when - val job = - batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> - ++taskletCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) { - taskExecutor { - ++taskExecutorCallCount - it.run() - } - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(taskletCallCount).isEqualTo(1) - assertThat(taskExecutorCallCount).isEqualTo(1) - } - @Test fun testChunkWithCount() { // given diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt index a319ac6..a81cf2b 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt @@ -99,7 +99,7 @@ internal class FlowStepBuilderDslIntegrationTest { } @Test - fun testFlowWithInit() { + fun testFlowWithLambda() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt new file mode 100644 index 0000000..1e638a1 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt @@ -0,0 +1,296 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration.step + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.annotation.AfterChunk +import org.springframework.batch.core.annotation.AfterStep +import org.springframework.batch.core.annotation.BeforeChunk +import org.springframework.batch.core.annotation.BeforeStep +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.launch.JobOperator +import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.tasklet.Tasklet +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.beans.factory.BeanFactory +import org.springframework.beans.factory.getBean +import org.springframework.context.annotation.AnnotationConfigApplicationContext +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.support.registerBean +import org.springframework.jdbc.datasource.DataSourceTransactionManager +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType +import org.springframework.transaction.TransactionManager +import javax.sql.DataSource + +/** + * Integration tests for creating and executing tasklet steps through the public Kotlin DSL. + */ +internal class TaskletStepBuilderDslIntegrationTest { + + @Test + fun testTaskletBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var taskletCallCount = 0 + val tasklet = + Tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } + context.registerBean("testTasklet") { + tasklet + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + taskletBean("testTasklet") + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(taskletCallCount).isEqualTo(1) + } + + @Test + fun testTaskletBeanWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var taskletCallCount = 0 + var streamOpenCallCount = 0 + var streamCloseCallCount = 0 + val tasklet = + Tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } + context.registerBean("testTasklet") { + tasklet + } + + // when + val job = + batch { + job("testJob") { + step("testStep") { + taskletBean("testTasklet") { + stream( + object : ItemStream { + override fun open(executionContext: ExecutionContext) { + ++streamOpenCallCount + } + + override fun close() { + ++streamCloseCallCount + } + }, + ) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(taskletCallCount).isEqualTo(1) + assertThat(streamOpenCallCount).isEqualTo(1) + assertThat(streamCloseCallCount).isEqualTo(1) + } + + @Test + fun testTaskletWithLambda() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var taskletCallCount = 0 + + // when + val job = + batch { + job("testJob") { + step("testStep") { + tasklet { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(taskletCallCount).isEqualTo(1) + } + + @Test + fun testTaskletWithLambdaAndInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var taskletCallCount = 0 + var streamOpenCallCount = 0 + var streamCloseCallCount = 0 + + // when + val job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + }, + ) { + stream( + object : ItemStream { + override fun open(executionContext: ExecutionContext) { + ++streamOpenCallCount + } + + override fun close() { + ++streamCloseCallCount + } + }, + ) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(taskletCallCount).isEqualTo(1) + assertThat(streamOpenCallCount).isEqualTo(1) + assertThat(streamCloseCallCount).isEqualTo(1) + } + + @Test + fun testTaskletWithAnnotationListener() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var taskletCallCount = 0 + var beforeStepCallCount = 0 + var afterStepCallCount = 0 + var beforeChunkCallCount = 0 + var afterChunkCallCount = 0 + + // when + val job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> + ++taskletCallCount + RepeatStatus.FINISHED + }, + ) { + listener( + object { + @BeforeStep + fun beforeStep() { + ++beforeStepCallCount + } + + @AfterStep + fun afterStep() { + ++afterStepCallCount + } + + @BeforeChunk + fun beforeChunk() { + ++beforeChunkCallCount + } + + @AfterChunk + fun afterChunk() { + ++afterChunkCallCount + } + }, + ) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(taskletCallCount).isEqualTo(1) + assertThat(beforeStepCallCount).isEqualTo(1) + assertThat(afterStepCallCount).isEqualTo(1) + assertThat(beforeChunkCallCount).isEqualTo(1) + assertThat(afterChunkCallCount).isEqualTo(1) + } + + @Configuration + @EnableBatchProcessing + @EnableJdbcJobRepository( + dataSourceRef = "metadataDataSource", + transactionManagerRef = "metadataTransactionManager", + ) + private open class TestConfiguration { + @Bean + open fun batchDsl( + beanFactory: BeanFactory, + jobRepository: JobRepository, + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) + + @Bean + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) + + @Bean + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .addScript("/org/springframework/batch/core/schema-h2.sql") + .generateUniqueName(true) + .build() + } +} diff --git a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt index aae2ba2..6eb85ec 100644 --- a/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt +++ b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDsl.kt @@ -28,6 +28,7 @@ import org.springframework.batch.infrastructure.item.ItemStream import org.springframework.batch.infrastructure.repeat.RepeatOperations import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler import org.springframework.core.task.TaskExecutor +import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.interceptor.TransactionAttribute /** @@ -59,6 +60,8 @@ class TaskletStepBuilderDsl internal constructor( /** * Set listener processing followings. * + * - [org.springframework.batch.core.annotation.BeforeStep] + * - [org.springframework.batch.core.annotation.AfterStep] * - [org.springframework.batch.core.annotation.BeforeChunk] * - [org.springframework.batch.core.annotation.AfterChunk] * - [org.springframework.batch.core.annotation.AfterChunkError] @@ -93,8 +96,6 @@ class TaskletStepBuilderDsl internal constructor( this.taskExecutorSet = true } - // Maybe throttleLimit can be here. But throttleLimit is redundant in a tasklet step. - /** * Set for [TaskletStepBuilder.exceptionHandler][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.exceptionHandler]. * It can't be used when [stepOperations] is set. @@ -116,6 +117,15 @@ class TaskletStepBuilderDsl internal constructor( this.stepOperationsSet = true } + /** + * Set for [TaskletStepBuilder.transactionManager][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.transactionManager]. + */ + fun transactionManager(transactionManager: PlatformTransactionManager) { + this.lazyConfigurer.add { + it.transactionManager(transactionManager) + } + } + /** * Set for [TaskletStepBuilder.transactionAttribute][org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder.transactionAttribute]. */ diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index 5181aef..1fd6ef3 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -42,11 +42,16 @@ import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandle import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.core.task.TaskExecutor +import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.interceptor.TransactionAttribute import java.util.UUID import java.util.concurrent.ThreadLocalRandom +/** + * Unit tests for TaskletStepBuilderDsl's delegation to Spring Batch's TaskletStepBuilder. + */ internal class TaskletStepBuilderDslTest { + @Test fun testChunkListener() { // given @@ -146,6 +151,22 @@ internal class TaskletStepBuilderDslTest { verify(exactly = 1) { taskletStepBuilder.stepOperations(repeatOperations) } } + @Test + fun testTransactionManager() { + // given + val taskletStepBuilder = mockk(relaxed = true) + + // when + val transactionManager = mockk() + TaskletStepBuilderDsl(mockk(), taskletStepBuilder) + .apply { + transactionManager(transactionManager) + }.build() + + // then + verify(exactly = 1) { taskletStepBuilder.transactionManager(transactionManager) } + } + @Test fun testTransactionalAttribute() { // given @@ -215,6 +236,7 @@ internal class TaskletStepBuilderDslTest { @Nested inner class RedundancyCheck { + @Suppress("DEPRECATION") @Test fun testStepOperationsAndRedundantSettings() { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/README.md new file mode 100644 index 0000000..85d168d --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/README.md @@ -0,0 +1,6 @@ +# Tasklet Step Config Samples + +## Invariants + +- Every tasklet step configuration option exposed by the Kotlin DSL should have + a runnable sample in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt index aef0d19..c88d3f5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt index 44d26a8..5d60f12 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/exceptionhandler/TestJobConfig.kt @@ -30,6 +30,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt index 366bf6e..4339a7e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt index e75bf97..c94b6f4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/executor/TestJobConfig.kt @@ -33,6 +33,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun customExecutor(): TaskExecutor = object : SimpleAsyncTaskExecutor() { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt index 6f239cb..8f2b0ec 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.taskletstep.variable +package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenerannotation import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt new file mode 100644 index 0000000..7ae688c --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerannotation/TestJobConfig.kt @@ -0,0 +1,79 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.listenerannotation + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.annotation.AfterChunk +import org.springframework.batch.core.annotation.AfterStep +import org.springframework.batch.core.annotation.BeforeChunk +import org.springframework.batch.core.annotation.BeforeStep +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.tasklet.Tasklet +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.transaction.PlatformTransactionManager + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, + private val transactionManager: PlatformTransactionManager, +) { + + class TestListener { + @BeforeStep + fun beforeStep() { + println("beforeStep") + } + + @AfterStep + fun afterStep() { + println("afterStep") + } + + @BeforeChunk + fun beforeChunk() { + println("beforeChunk") + } + + @AfterChunk + fun afterChunk() { + println("afterChunk") + } + } + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet(), transactionManager) { + listener(TestListener()) + } + } + } + } + + @Bean + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt index 3699538..546ee1f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt index 4fef2ec..24b3386 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/listenerobject/TestJobConfig.kt @@ -33,6 +33,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt index 1ebe894..99cd342 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt index 7e2528d..eb854ab 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stepoperation/TestJobConfig.kt @@ -34,6 +34,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt index fa40b7a..39e3499 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt index d7e1e31..d8055b8 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/stream/TestJobConfig.kt @@ -33,6 +33,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt index 4b6d506..27cbca4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/SampleApplicationTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt index d0553fc..256a17d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionattribute/TestJobConfig.kt @@ -33,6 +33,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/SampleApplicationTest.kt new file mode 100644 index 0000000..5eb79a2 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/SampleApplicationTest.kt @@ -0,0 +1,47 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.transactionmanager + +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class SampleApplicationTest { + + @Test + fun run() { + val applicationContext = runApplication() + val jobOperator = applicationContext.getBean() + val job = applicationContext.getBean() + + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.COMPLETED == jobExecution.status) + println(jobExecution) + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/TestJobConfig.kt new file mode 100644 index 0000000..cf96423 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/config/transactionmanager/TestJobConfig.kt @@ -0,0 +1,53 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.config.transactionmanager + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.tasklet.Tasklet +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.transaction.PlatformTransactionManager + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, + private val transactionManager: PlatformTransactionManager, +) { + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet()) { + transactionManager(transactionManager) + } + } + } + } + + @Bean + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/README.md new file mode 100644 index 0000000..6bafe1b --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/README.md @@ -0,0 +1,6 @@ +# Tasklet Step Creation Samples + +## Invariants + +- Every supported way to create a tasklet step with the Kotlin DSL should have a + runnable sample in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/SampleApplicationTest.kt new file mode 100644 index 0000000..eb51ee8 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/SampleApplicationTest.kt @@ -0,0 +1,48 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.beandefaulttransactionmanager + +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class SampleApplicationTest { + + @Test + fun run() { + val applicationContext = runApplication() + val jobOperator = applicationContext.getBean() + val job = applicationContext.getBean() + + val jobParameters = + JobParametersBuilder() + .addString("param", "I am test") + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.COMPLETED == jobExecution.status) + println(jobExecution) + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/TestJobConfig.kt new file mode 100644 index 0000000..6e03a2e --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beandefaulttransactionmanager/TestJobConfig.kt @@ -0,0 +1,54 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.beandefaulttransactionmanager + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.configuration.annotation.StepScope +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.tasklet.Tasklet +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, +) { + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + taskletBean("testTasklet") + } + } + } + + @Bean + @StepScope + open fun testTasklet( + @Value("#{jobParameters['param']}") paramValue: String, + ): Tasklet = + Tasklet { _, _ -> + println("param is '$paramValue'") + RepeatStatus.FINISHED + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/SampleApplicationTest.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/SampleApplicationTest.kt index 80e50c2..1356df9 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.taskletstep.bean +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.beanwithtransactionmanager import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/TestJobConfig.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/TestJobConfig.kt index 8be7205..eb99fda 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/bean/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.taskletstep.bean +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.beanwithtransactionmanager import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.configuration.annotation.StepScope @@ -33,6 +33,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/SampleApplicationTest.kt new file mode 100644 index 0000000..204326f --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/SampleApplicationTest.kt @@ -0,0 +1,47 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.variabledefaulttransactionmanager + +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class SampleApplicationTest { + + @Test + fun run() { + val applicationContext = runApplication() + val jobOperator = applicationContext.getBean() + val job = applicationContext.getBean() + + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.COMPLETED == jobExecution.status) + println(jobExecution) + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/TestJobConfig.kt new file mode 100644 index 0000000..9867a71 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variabledefaulttransactionmanager/TestJobConfig.kt @@ -0,0 +1,49 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.variabledefaulttransactionmanager + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.tasklet.Tasklet +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, +) { + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + tasklet(testTasklet()) + } + } + } + + @Bean + open fun testTasklet(): Tasklet = + Tasklet { _, _ -> + println("run testTasklet") + RepeatStatus.FINISHED + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/SampleApplicationTest.kt new file mode 100644 index 0000000..06b875d --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/SampleApplicationTest.kt @@ -0,0 +1,47 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.variablewithtransactionmanager + +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class SampleApplicationTest { + + @Test + fun run() { + val applicationContext = runApplication() + val jobOperator = applicationContext.getBean() + val job = applicationContext.getBean() + + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.COMPLETED == jobExecution.status) + println(jobExecution) + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/TestJobConfig.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/TestJobConfig.kt index bf8c43d..a1f17de 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/variable/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.taskletstep.variable +package com.navercorp.spring.batch.plus.sample.step.taskletstep.creation.variablewithtransactionmanager import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -31,6 +31,7 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { From 4747c260777725cdcdadeb80429a91d06e06bec2 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 28 Jun 2026 19:19:03 +0900 Subject: [PATCH 43/45] Document step sample invariants Signed-off-by: Taeik Lim --- .../batch/plus/sample/step/flowstep/creation/README.md | 6 ++++++ .../spring/batch/plus/sample/step/jobstep/config/README.md | 6 ++++++ .../batch/plus/sample/step/jobstep/creation/README.md | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/README.md diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/README.md new file mode 100644 index 0000000..f4ed462 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/README.md @@ -0,0 +1,6 @@ +# Flow Step Creation Samples + +## Invariants + +- Every supported way to create a flow step with the Kotlin DSL should have a + runnable sample in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/README.md new file mode 100644 index 0000000..ab1336f --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/config/README.md @@ -0,0 +1,6 @@ +# Job Step Config Samples + +## Invariants + +- Every job step configuration option exposed by the Kotlin DSL should have a + runnable sample in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/README.md new file mode 100644 index 0000000..068e5de --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/README.md @@ -0,0 +1,6 @@ +# Job Step Creation Samples + +## Invariants + +- Every supported way to create a job step with the Kotlin DSL should have a + runnable sample in this package. From 014a3df8df3659487333d84f64a4d5eb9d2f734b Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 6 Jul 2026 09:48:52 +0900 Subject: [PATCH 44/45] Polish partitionStep tests, samples Signed-off-by: Taeik Lim --- .../StepBuilderDslIntegrationTest.kt | 31 +- .../step/FlowStepBuilderDslIntegrationTest.kt | 1 + .../step/JobStepBuilderDslIntegrationTest.kt | 1 + .../PartitionStepBuilderDslIntegrationTest.kt | 315 ++++++++ .../TaskletStepBuilderDslIntegrationTest.kt | 1 + .../step/PartitionStepBuilderDslTest.kt | 721 ++++-------------- .../step/partitionstep/config/README.md | 6 + .../aggregator/SampleApplicationTest.kt | 3 +- .../{ => config}/aggregator/TestJobConfig.kt | 13 +- .../builtin}/SampleApplicationTest.kt | 3 +- .../splitter/builtin}/TestJobConfig.kt | 14 +- .../splitter/direct/SampleApplicationTest.kt | 3 +- .../splitter/direct/TestJobConfig.kt | 20 +- .../step/partitionstep/creation/README.md | 6 + .../builtinhandler/SampleApplicationTest.kt | 47 ++ .../builtinhandler}/TestJobConfig.kt | 14 +- .../directhandler}/SampleApplicationTest.kt | 3 +- .../directhandler}/TestJobConfig.kt | 13 +- .../splitter/inner/SampleApplicationTest.kt | 46 -- 19 files changed, 591 insertions(+), 670 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslIntegrationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/README.md rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{ => config}/aggregator/SampleApplicationTest.kt (98%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{ => config}/aggregator/TestJobConfig.kt (99%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{partitionhandler/inner => config/splitter/builtin}/SampleApplicationTest.kt (98%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{splitter/inner => config/splitter/builtin}/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{ => config}/splitter/direct/SampleApplicationTest.kt (98%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{ => config}/splitter/direct/TestJobConfig.kt (89%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{partitionhandler/inner => creation/builtinhandler}/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{partitionhandler/direct => creation/directhandler}/SampleApplicationTest.kt (98%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/{partitionhandler/direct => creation/directhandler}/TestJobConfig.kt (99%) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt index 9275326..072e0a1 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt @@ -40,6 +40,7 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class StepBuilderDslIntegrationTest { + @Test fun testChunkWithCount() { // given @@ -164,36 +165,6 @@ internal class StepBuilderDslIntegrationTest { assertThat(writeCallCount).isEqualTo(7) // Ceil(20/3) } - @Test - fun testPartitioner() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var partitionHandlerCallCount = 0 - - // when - val job = - batch { - job("testJob") { - step("testStep") { - partitioner { - partitionHandler { _, _ -> - ++partitionHandlerCallCount - listOf() - } - splitter("splitStep") { mapOf() } - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(partitionHandlerCallCount).isEqualTo(1) - } - @Configuration @EnableBatchProcessing @EnableJdbcJobRepository( diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt index a81cf2b..701fcf3 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt @@ -199,6 +199,7 @@ internal class FlowStepBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { + @Bean open fun batchDsl( beanFactory: BeanFactory, diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt index 96a2cd4..ba40ae9 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt @@ -217,6 +217,7 @@ internal class JobStepBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { + @Bean open fun batchDsl( beanFactory: BeanFactory, diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslIntegrationTest.kt new file mode 100644 index 0000000..1fff09e --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslIntegrationTest.kt @@ -0,0 +1,315 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.kotlin.configuration.step + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.ExitStatus +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.parameters.JobParameters +import org.springframework.batch.core.launch.JobOperator +import org.springframework.batch.core.partition.PartitionHandler +import org.springframework.batch.core.partition.StepExecutionSplitter +import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.StepExecution +import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager +import org.springframework.beans.factory.BeanFactory +import org.springframework.beans.factory.getBean +import org.springframework.context.annotation.AnnotationConfigApplicationContext +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.jdbc.datasource.DataSourceTransactionManager +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType +import org.springframework.transaction.TransactionManager +import java.util.UUID +import javax.sql.DataSource + +/** + * Integration tests for creating and executing partition steps through the public Kotlin DSL. + */ +internal class PartitionStepBuilderDslIntegrationTest { + + @Test + fun testPartitionHandlerWithDirectOne() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + val jobName = UUID.randomUUID().toString() + val stepName = UUID.randomUUID().toString() + val splitStepName = UUID.randomUUID().toString() + val gridSize = 4 + var partitionHandlerCallCount = 0 + var partitionerCallCount = 0 + + // when + val job = + batch { + job(jobName) { + step(stepName) { + partitioner { + partitionHandler { stepSplitter, stepExecution -> + ++partitionHandlerCallCount + stepSplitter + .split(stepExecution, gridSize) + .map { it.complete() } + } + splitter(splitStepName) { partitionCount -> + ++partitionerCallCount + (0 until partitionCount) + .associate { "$it" to ExecutionContext() } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(partitionHandlerCallCount).isEqualTo(1) + assertThat(partitionerCallCount).isEqualTo(1) + } + + @Test + fun testPartitionHandlerWithBuiltInOne() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + val jobName = UUID.randomUUID().toString() + val stepName = UUID.randomUUID().toString() + val splitStepName = UUID.randomUUID().toString() + val gridSize = 4 + var workerStepCallCount = 0 + var taskExecutorCallCount = 0 + var partitionerCallCount = 0 + val workerStep = + batch { + step(splitStepName) { + tasklet( + { _, _ -> + ++workerStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + + // when + val job = + batch { + job(jobName) { + step(stepName) { + partitioner { + partitionHandler { + step(workerStep) + taskExecutor { task -> + ++taskExecutorCallCount + task.run() + } + gridSize(gridSize) + } + splitter(splitStepName) { partitionCount -> + ++partitionerCallCount + (0 until partitionCount) + .associate { "$it" to ExecutionContext() } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(workerStepCallCount).isEqualTo(gridSize) + assertThat(taskExecutorCallCount).isEqualTo(gridSize) + assertThat(partitionerCallCount).isEqualTo(1) + } + + @Nested + inner class RedundancyCheck { + + @Test + fun testPartitionHandlerAndRedundantSettings() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + val jobName = UUID.randomUUID().toString() + val stepName = UUID.randomUUID().toString() + val splitStepName = UUID.randomUUID().toString() + val gridSize = 4 + var partitionHandlerCallCount = 0 + var taskExecutorCallCount = 0 + var workerStepCallCount = 0 + val workerStep = + batch { + step(splitStepName) { + tasklet( + { _, _ -> + ++workerStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + + // when + val job = + batch { + job(jobName) { + step(stepName) { + partitioner { + partitionHandler { _, _ -> + ++partitionHandlerCallCount + listOf() + } + partitionHandler { + step(workerStep) + taskExecutor { task -> + ++taskExecutorCallCount + task.run() + } + gridSize(gridSize) + } + splitter(splitStepName) { partitionCount -> + (0 until partitionCount) + .associate { "$it" to ExecutionContext() } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(partitionHandlerCallCount).isEqualTo(1) + assertThat(taskExecutorCallCount).isEqualTo(0) + assertThat(workerStepCallCount).isEqualTo(0) + } + + @Test + fun testSplitterAndRedundantSettings() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + val jobName = UUID.randomUUID().toString() + val stepName = UUID.randomUUID().toString() + val splitStepName = UUID.randomUUID().toString() + val gridSize = 4 + var splitterCallCount = 0 + var partitionerCallCount = 0 + val partitionHandler = + PartitionHandler { stepSplitter, stepExecution -> + stepSplitter + .split(stepExecution, gridSize) + .map { it.complete() } + } + val splitter = + object : StepExecutionSplitter { + override fun getStepName(): String = splitStepName + + override fun split( + stepExecution: StepExecution, + gridSize: Int, + ): Set { + ++splitterCallCount + val jobExecution = stepExecution.jobExecution + return (0 until gridSize) + .map { + StepExecution(0L, "${stepName}$it", jobExecution) + .also { jobExecution.addStepExecution(it) } + }.toSet() + } + } + + // when + val job = + batch { + job(jobName) { + step(stepName) { + partitioner { + partitionHandler(partitionHandler) + splitter(splitter) + splitter(splitStepName) { + ++partitionerCallCount + mapOf() + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(splitterCallCount).isEqualTo(1) + assertThat(partitionerCallCount).isEqualTo(0) + } + } + + private fun StepExecution.complete(): StepExecution = + apply { + exitStatus = ExitStatus.COMPLETED + status = BatchStatus.COMPLETED + } + + @Configuration + @EnableBatchProcessing + @EnableJdbcJobRepository( + dataSourceRef = "metadataDataSource", + transactionManagerRef = "metadataTransactionManager", + ) + private open class TestConfiguration { + + @Bean + open fun batchDsl( + beanFactory: BeanFactory, + jobRepository: JobRepository, + ): BatchDsl = + BatchDsl( + beanFactory, + jobRepository, + ) + + @Bean + open fun metadataTransactionManager(): TransactionManager = DataSourceTransactionManager(metadataDataSource()) + + @Bean + open fun metadataDataSource(): DataSource = + EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .addScript("/org/springframework/batch/core/schema-h2.sql") + .generateUniqueName(true) + .build() + } +} diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt index 1e638a1..7bce7a9 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt @@ -272,6 +272,7 @@ internal class TaskletStepBuilderDslIntegrationTest { transactionManagerRef = "metadataTransactionManager", ) private open class TestConfiguration { + @Bean open fun batchDsl( beanFactory: BeanFactory, diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt index eecb10d..6bfc186 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslTest.kt @@ -21,608 +21,215 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.support.DslContext import io.mockk.every import io.mockk.mockk +import io.mockk.verify import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy -import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.ExitStatus -import org.springframework.batch.core.job.JobExecution -import org.springframework.batch.core.job.JobInstance -import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.partition.PartitionHandler +import org.springframework.batch.core.partition.Partitioner +import org.springframework.batch.core.partition.StepExecutionAggregator import org.springframework.batch.core.partition.StepExecutionSplitter -import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.core.step.Step -import org.springframework.batch.core.step.StepExecution -import org.springframework.batch.core.step.builder.StepBuilder -import org.springframework.batch.infrastructure.item.ExecutionContext +import org.springframework.batch.core.step.builder.PartitionStepBuilder +import org.springframework.core.task.TaskExecutor +import java.util.UUID +import java.util.concurrent.ThreadLocalRandom +/** + * Unit tests for PartitionStepBuilderDsl's delegation and DSL-owned preconditions. + */ internal class PartitionStepBuilderDslTest { - private val jobInstance = JobInstance(0L, "testJob") - - private val jobParameters = JobParameters() - - @Nested - inner class PartitionHandlerTest { - @Test - fun testPartitionHandlerAndDummySettings() { - // given - var partitionHandlerCallCount = 0 - var taskExecutorCallCount = 0 - val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val partitionStepBuilder = TestBuilderBridge.partitionStepBuilder(stepBuilder) - - // when - val step = - partitionStepBuilder - .partitionHandler { _, _ -> - ++partitionHandlerCallCount - listOf() - } - // dummy - .step( - object : Step { - override fun getName(): String = throw RuntimeException("Should not be called") - override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - - override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - - override fun execute(stepExecution: StepExecution): Unit = throw RuntimeException("Should not be called") - }, - ).taskExecutor { task -> - ++taskExecutorCallCount - task.run() - }.gridSize(3) - .build() - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) + @Test + fun testPartitionHandler() { + // given + val partitionHandler = mockk() + val splitter = mockk() + val mockStep = mockk() + val partitionStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep + } - // then - assertThat(stepExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(partitionHandlerCallCount).isEqualTo(1) - assertThat(taskExecutorCallCount).isEqualTo(0) + // when + partitionStepBuilderDsl(partitionStepBuilder) { + partitionHandler(partitionHandler) + splitter(splitter) } - @Test - fun testPartitionHandlerWithDirectOne() { - // given - val gridSize = 4 - var partitionHandlerCallCount = 0 - val splitter = - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - } - - // when - val step = - partitionStepBuilderDsl { - partitionHandler { splitter, stepExecution -> - ++partitionHandlerCallCount - splitter - .split(stepExecution, gridSize) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED - } - } - } - splitter(splitter) - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) + // then + verify(exactly = 1) { partitionStepBuilder.partitionHandler(partitionHandler) } + } - // then - assertThat(partitionHandlerCallCount).isEqualTo(1) - assertThat(jobExecution.stepExecutions).hasSize(gridSize + 1) - assertThat(jobExecution.stepExecutions).allMatch { - it.status == BatchStatus.COMPLETED - } - assertThat(jobExecution.stepExecutions.find { it.stepName == "testStep" }).isNotNull - (0 until gridSize).forEach { gridNumber -> - assertThat(jobExecution.stepExecutions.find { it.stepName == "splitStep$gridNumber" }).isNotNull + @Test + fun testPartitionHandlerWithInit() { + // given + val step = mockk() + val taskExecutor = mockk() + val gridSize = ThreadLocalRandom.current().nextInt(1, 10) + val splitter = mockk() + val mockStep = mockk() + val partitionStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep } - } - - @Test - fun testPartitionHandlerWithTaskExecutorPartitionHandler() { - // given - var stepExecuteCallCount = 0 - var taskExecutorCallCount = 0 - val gridSize = 4 - val splitter = - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - } - // when - val step = - partitionStepBuilderDsl { - partitionHandler { - step( - object : Step { - override fun getName(): String = throw RuntimeException("Should not be called") - - override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - - override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - - override fun execute(stepExecution: StepExecution) { - ++stepExecuteCallCount - stepExecution.apply { - status = BatchStatus.COMPLETED - exitStatus = ExitStatus.COMPLETED - } - } - }, - ) - taskExecutor { task -> - ++taskExecutorCallCount - task.run() - } - gridSize(gridSize) - } - splitter(splitter) - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) - - // then - assertThat(stepExecuteCallCount).isEqualTo(gridSize) - assertThat(taskExecutorCallCount).isEqualTo(gridSize) - assertThat(jobExecution.stepExecutions).hasSize(gridSize + 1) - assertThat(jobExecution.stepExecutions).allMatch { - it.status == BatchStatus.COMPLETED - } - assertThat(jobExecution.stepExecutions.find { it.stepName == "testStep" }).isNotNull - (0 until gridSize).forEach { gridNumber -> - assertThat(jobExecution.stepExecutions.find { it.stepName == "splitStep$gridNumber" }).isNotNull + // when + partitionStepBuilderDsl(partitionStepBuilder) { + partitionHandler { + step(step) + taskExecutor(taskExecutor) + gridSize(gridSize) } + splitter(splitter) } - @Test - fun testPartitionHandlerWithTaskExecutorPartitionHandlerWithoutTaskExecutor() { - // given - var stepExecuteCallCount = 0 - val gridSize = 4 - val splitter = - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - } - - // when - val step = - partitionStepBuilderDsl { - partitionHandler { - step( - object : Step { - override fun getName(): String = throw RuntimeException("Should not be called") - - override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - - override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - - override fun execute(stepExecution: StepExecution) { - ++stepExecuteCallCount - stepExecution.apply { - status = BatchStatus.COMPLETED - exitStatus = ExitStatus.COMPLETED - } - } - }, - ) - gridSize(gridSize) - } - splitter(splitter) - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) + // then + verify(exactly = 1) { partitionStepBuilder.step(step) } + verify(exactly = 1) { partitionStepBuilder.taskExecutor(taskExecutor) } + verify(exactly = 1) { partitionStepBuilder.gridSize(gridSize) } + } - // then - assertThat(stepExecuteCallCount).isEqualTo(gridSize) - assertThat(jobExecution.stepExecutions).hasSize(gridSize + 1) - assertThat(jobExecution.stepExecutions).allMatch { - it.status == BatchStatus.COMPLETED - } - assertThat(jobExecution.stepExecutions.find { it.stepName == "testStep" }).isNotNull - (0 until gridSize).forEach { gridNumber -> - assertThat(jobExecution.stepExecutions.find { it.stepName == "splitStep$gridNumber" }).isNotNull + @Test + fun testSplitter() { + // given + val partitionHandler = mockk() + val splitter = mockk() + val mockStep = mockk() + val partitionStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep } - } - @Test - fun testPartitionHandlerWithTaskExecutorPartitionHandlerWithoutGridSize() { - // given - var stepExecuteCallCount = 0 - var taskExecutorCallCount = 0 - val splitter = - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - } - // org.springframework.batch.core.step.builder.PartitionStepBuilder.DEFAULT_GRID_SIZE - val defaultGridSize = 6 - - // when - val step = - partitionStepBuilderDsl { - partitionHandler { - step( - object : Step { - override fun getName(): String = throw RuntimeException("Should not be called") - - override fun isAllowStartIfComplete(): Boolean = throw RuntimeException("Should not be called") - - override fun getStartLimit(): Int = throw RuntimeException("Should not be called") - - override fun execute(stepExecution: StepExecution) { - ++stepExecuteCallCount - stepExecution.apply { - status = BatchStatus.COMPLETED - exitStatus = ExitStatus.COMPLETED - } - } - }, - ) - taskExecutor { task -> - ++taskExecutorCallCount - task.run() - } - } - splitter(splitter) - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) - - // then - assertThat(stepExecuteCallCount).isEqualTo(defaultGridSize) - assertThat(taskExecutorCallCount).isEqualTo(defaultGridSize) - assertThat(jobExecution.stepExecutions).hasSize(defaultGridSize + 1) - assertThat(jobExecution.stepExecutions).allMatch { - it.status == BatchStatus.COMPLETED - } - assertThat(jobExecution.stepExecutions.find { it.stepName == "testStep" }).isNotNull - (0 until defaultGridSize).forEach { gridNumber -> - assertThat(jobExecution.stepExecutions.find { it.stepName == "splitStep$gridNumber" }).isNotNull - } + // when + partitionStepBuilderDsl(partitionStepBuilder) { + partitionHandler(partitionHandler) + splitter(splitter) } - @Test - fun testPartitionHandlerWithTaskExecutorPartitionHandlerWithoutStep() { - // given - val splitter = - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" + // then + verify(exactly = 1) { partitionStepBuilder.splitter(splitter) } + } - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - } + @Test + fun testSplitterWithPartitioner() { + // given + val stepName = UUID.randomUUID().toString() + val partitionHandler = mockk() + val partitioner = mockk() + val mockStep = mockk() + val partitionStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep + } - // when, then - assertThatThrownBy { - partitionStepBuilderDsl { - partitionHandler { - taskExecutor { task -> - task.run() - } - gridSize(3) - } - splitter(splitter) - } - }.hasMessageContaining("step is not set") + // when + partitionStepBuilderDsl(partitionStepBuilder) { + partitionHandler(partitionHandler) + splitter(stepName, partitioner) } - @Test - fun testWithoutPartitionHandler() { - // given - val splitter = - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - } - - // when, then - assertThatThrownBy { - partitionStepBuilderDsl { - splitter(splitter) - } - }.hasMessageContaining("partitionHandler is not set") - } + // then + verify(exactly = 1) { partitionStepBuilder.partitioner(stepName, partitioner) } } - @Nested - inner class SplitterTest { - @Test - fun testSplitterAndDummySettings() { - // given - var splitterCallCount = 0 - val dummyStepName = "dummyStepName" - var partitionerCallCount = 0 - val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) - val partitionStepBuilder = TestBuilderBridge.partitionStepBuilder(stepBuilder) - - // when - val step = - partitionStepBuilder - .partitionHandler { stepSplitter, stepExecution -> - stepSplitter.split(stepExecution, 1) - }.splitter( - object : StepExecutionSplitter { - override fun getStepName(): String = "testStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - ++splitterCallCount - return setOf() - } - }, - ) - // dummy - .partitioner(dummyStepName) { - ++partitionerCallCount - mapOf() - }.build() - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) + @Test + fun testAggregator() { + // given + val aggregator = mockk() + val partitionHandler = mockk() + val splitter = mockk() + val mockStep = mockk() + val partitionStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep + } - // then - assertThat(stepExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(splitterCallCount).isEqualTo(1) - assertThat(stepExecution.stepName).isEqualTo("testStep") - assertThat(partitionerCallCount).isEqualTo(0) + // when + partitionStepBuilderDsl(partitionStepBuilder) { + aggregator(aggregator) + partitionHandler(partitionHandler) + splitter(splitter) } - @Test - fun testSplitterWithDirectOne() { - // given - var splitterCallCount = 0 - val gridSize = 4 - val partitionHandler = - PartitionHandler { stepSplitter, stepExecution -> - stepSplitter - .split(stepExecution, gridSize) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED - } - } - } - - // when - val step = - partitionStepBuilderDsl { - partitionHandler(partitionHandler) - splitter( - object : StepExecutionSplitter { - override fun getStepName(): String = "splitStep" - - override fun split( - stepExecution: StepExecution, - gridSize: Int, - ): Set { - ++splitterCallCount - val jobExecution = stepExecution.jobExecution - return (0 until gridSize) - .map { - StepExecution(0L, "${stepName}$it", jobExecution) - .also { jobExecution.addStepExecution(it) } - }.toSet() - } - }, - ) - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) + // then + verify(exactly = 1) { partitionStepBuilder.aggregator(aggregator) } + } - // then - assertThat(splitterCallCount).isEqualTo(1) - assertThat(jobExecution.stepExecutions).hasSize(gridSize + 1) - assertThat(jobExecution.stepExecutions).allMatch { - it.status == BatchStatus.COMPLETED - } - assertThat(jobExecution.stepExecutions.find { it.stepName == "testStep" }).isNotNull - (0 until gridSize).forEach { gridNumber -> - assertThat(jobExecution.stepExecutions.find { it.stepName == "splitStep$gridNumber" }).isNotNull + @Test + fun testBuild() { + // given + val partitionHandler = mockk() + val splitter = mockk() + val mockStep = mockk() + val partitionStepBuilder = + mockk(relaxed = true) { + every { build() } returns mockStep } - } - - @Test - fun testSplitterWithSimpleStepExecutionSplitter() { - // given - var partitionerCallCount = 0 - val gridSize = 4 - val partitionHandler = - PartitionHandler { stepSplitter, stepExecution -> - stepSplitter - .split(stepExecution, gridSize) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED - } - } - } - - // when - val step = - partitionStepBuilderDsl { - partitionHandler(partitionHandler) - splitter("splitStep") { gridSize -> - ++partitionerCallCount - (0 until gridSize) - .map { - "$it" to ExecutionContext() - }.toMap() - } - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) - // then - assertThat(partitionerCallCount).isEqualTo(1) - assertThat(jobExecution.stepExecutions).hasSize(gridSize + 1) - assertThat(jobExecution.stepExecutions).allMatch { - it.status == BatchStatus.COMPLETED - } - assertThat(jobExecution.stepExecutions.find { it.stepName == "testStep" }).isNotNull - (0 until gridSize).forEach { gridNumber -> - assertThat(jobExecution.stepExecutions.find { it.stepName == "splitStep:$gridNumber" }).isNotNull + // when + val actual = + partitionStepBuilderDsl(partitionStepBuilder) { + partitionHandler(partitionHandler) + splitter(splitter) } - } - - @Test - fun testWithoutSplitter() { - // given - val partitionHandler = - PartitionHandler { stepSplitter, stepExecution -> - stepSplitter - .split(stepExecution, 2_000_000_000) - .map { - it.apply { - exitStatus = ExitStatus.COMPLETED - status = BatchStatus.COMPLETED - } - } - } - // when, then - assertThatThrownBy { - partitionStepBuilderDsl { - partitionHandler(partitionHandler) - } - }.hasMessageContaining("splitter is not set") - } + // then + assertThat(actual).isEqualTo(mockStep) } @Test - fun testAggregator() { + fun testPartitionHandlerBuilderRequiresStep() { // given - var aggregatorCallCount = 0 + val taskExecutor = mockk() + val gridSize = ThreadLocalRandom.current().nextInt(1, 10) + val partitionStepBuilder = mockk(relaxed = true) + + // when, then + assertThatThrownBy { + PartitionStepBuilderDsl(mockk(), partitionStepBuilder) + .partitionHandler { + taskExecutor(taskExecutor) + gridSize(gridSize) + } + }.isInstanceOf(IllegalStateException::class.java) + } - // when - val step = - partitionStepBuilderDsl { - aggregator { _, _ -> - ++aggregatorCallCount - } - partitionHandler(mockk(relaxed = true)) - splitter(mockk()) - } - val jobExecution = JobExecution(0L, jobInstance, jobParameters) - val stepExecution = StepExecution(0L, step.name, jobExecution) - jobExecution.addStepExecution(stepExecution) - step.execute(stepExecution) + @Test + fun testWithoutPartitionHandler() { + // given + val splitter = mockk() + val partitionStepBuilder = mockk(relaxed = true) - // then - assertThat(stepExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(aggregatorCallCount).isEqualTo(1) + // when, then + assertThatThrownBy { + PartitionStepBuilderDsl(mockk(), partitionStepBuilder) + .apply { + splitter(splitter) + }.build() + }.isInstanceOf(IllegalStateException::class.java) } - private fun partitionStepBuilderDsl(init: PartitionStepBuilderDsl.() -> Unit): Step { - val dslContext = - DslContext( - beanFactory = mockk(), - jobRepository = mockk(), - ) - val mockk = - mockk(relaxed = true) { - every { getLastStepExecution(any(), any()) } returns null - every { createStepExecution(any(), any()) } answers { - val name = firstArg() - val jobExecution = secondArg() - StepExecution(0L, name, jobExecution).also { jobExecution.addStepExecution(it) } - } - } - val stepBuilder = StepBuilder("testStep", mockk) + @Test + fun testWithoutSplitter() { + // given + val partitionHandler = mockk() + val partitionStepBuilder = mockk(relaxed = true) - return PartitionStepBuilderDsl(dslContext, TestBuilderBridge.partitionStepBuilder(stepBuilder)).apply(init).build() + // when, then + assertThatThrownBy { + PartitionStepBuilderDsl(mockk(), partitionStepBuilder) + .apply { + partitionHandler(partitionHandler) + }.build() + }.isInstanceOf(IllegalStateException::class.java) } + + private fun partitionStepBuilderDsl( + partitionStepBuilder: PartitionStepBuilder, + init: PartitionStepBuilderDsl.() -> Unit, + ): Step = + PartitionStepBuilderDsl(mockk(), partitionStepBuilder) + .apply(init) + .build() } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/README.md new file mode 100644 index 0000000..5fc237e --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/README.md @@ -0,0 +1,6 @@ +# Partition Step Config Samples + +## Invariants + +- Every partition step splitter and aggregator option exposed by the Kotlin DSL + should have a runnable sample in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/aggregator/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/aggregator/SampleApplicationTest.kt index 90d5066..e9f742e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/aggregator/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.aggregator +package com.navercorp.spring.batch.plus.sample.step.partitionstep.config.aggregator import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/aggregator/TestJobConfig.kt similarity index 99% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/aggregator/TestJobConfig.kt index d7c5668..efaae67 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/aggregator/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/aggregator/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.aggregator +package com.navercorp.spring.batch.plus.sample.step.partitionstep.config.aggregator import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -34,22 +34,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { partitioner { - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() - } - } partitionHandler { taskExecutor(SimpleAsyncTaskExecutor()) step(testStep()) gridSize(4) } + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } + } aggregator(DefaultStepExecutionAggregator()) } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/SampleApplicationTest.kt index 770c95d..7b2d183 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandler.inner +package com.navercorp.spring.batch.plus.sample.step.partitionstep.config.splitter.builtin import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/TestJobConfig.kt index 578017a..8fdd12e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.inner +package com.navercorp.spring.batch.plus.sample.step.partitionstep.config.splitter.builtin import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -33,23 +33,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { partitioner { - // use SimpleStepExecutionSplitter internally - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() - } - } partitionHandler { taskExecutor(SimpleAsyncTaskExecutor()) step(testStep()) gridSize(4) } + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } + } } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/direct/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/direct/SampleApplicationTest.kt index 0d2491a..9b387a3 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/direct/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.direct +package com.navercorp.spring.batch.plus.sample.step.partitionstep.config.splitter.direct import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/direct/TestJobConfig.kt similarity index 89% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/direct/TestJobConfig.kt index d44cae6..ec180f7 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/direct/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/direct/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.direct +package com.navercorp.spring.batch.plus.sample.step.partitionstep.config.splitter.direct import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -36,12 +36,18 @@ open class TestJobConfig( private val jobRepository: JobRepository, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { partitioner { + partitionHandler { + taskExecutor(SimpleAsyncTaskExecutor()) + step(actualStep()) + gridSize(4) + } splitter( object : StepExecutionSplitter { override fun getStepName(): String = "workerStep" @@ -52,16 +58,16 @@ open class TestJobConfig( ): Set { val jobExecution = stepExecution.jobExecution return (0 until gridSize) - .map { jobRepository.createStepExecution("$stepName:partition-$it", jobExecution) } + .map { + jobRepository.createStepExecution( + "$stepName:partition-$it", + jobExecution, + ) + } .toSet() } }, ) - partitionHandler { - taskExecutor(SimpleAsyncTaskExecutor()) - step(actualStep()) - gridSize(4) - } } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/README.md new file mode 100644 index 0000000..a404622 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/README.md @@ -0,0 +1,6 @@ +# Partition Step Creation Samples + +## Invariants + +- Every supported way to provide a partition handler with the Kotlin DSL should + have a runnable sample in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/SampleApplicationTest.kt new file mode 100644 index 0000000..6351719 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/SampleApplicationTest.kt @@ -0,0 +1,47 @@ +/* + * Spring Batch Plus + * + * Copyright 2022-present NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.spring.batch.plus.sample.step.partitionstep.creation.builtinhandler + +import org.junit.jupiter.api.Test +import org.springframework.batch.core.BatchStatus +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.job.parameters.JobParametersBuilder +import org.springframework.batch.core.launch.JobOperator +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class SampleApplicationTest { + + @Test + fun run() { + val applicationContext = runApplication() + val jobOperator = applicationContext.getBean() + val job = applicationContext.getBean("testJob") + + val jobParameters = + JobParametersBuilder() + .toJobParameters() + val jobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.COMPLETED == jobExecution.status) + println(jobExecution) + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/TestJobConfig.kt index 6815d09..0f3e476 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/inner/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandler.inner +package com.navercorp.spring.batch.plus.sample.step.partitionstep.creation.builtinhandler import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -33,23 +33,23 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { partitioner { - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() - } - } - // use TaskExecutorPartitionHandler internally partitionHandler { taskExecutor(SimpleAsyncTaskExecutor()) step(actualStep()) gridSize(4) } + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } + } } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/SampleApplicationTest.kt index 253b7da..e1f50fc 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandler.direct +package com.navercorp.spring.batch.plus.sample.step.partitionstep.creation.directhandler import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus @@ -29,6 +29,7 @@ import org.springframework.boot.runApplication @SpringBootApplication open class SampleApplicationTest { + @Test fun run() { val applicationContext = runApplication() diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/TestJobConfig.kt similarity index 99% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/TestJobConfig.kt index 9bff9ea..6b2ac17 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/partitionhandler/direct/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.partitionstep.partitionhandler.direct +package com.navercorp.spring.batch.plus.sample.step.partitionstep.creation.directhandler import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -34,17 +34,13 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { partitioner { - splitter("workerStep") { gridSize -> - (0 until gridSize).associate { - "partition-$it" to ExecutionContext() - } - } partitionHandler( TaskExecutorPartitionHandler().apply { setTaskExecutor(SimpleAsyncTaskExecutor()) @@ -52,6 +48,11 @@ open class TestJobConfig( gridSize = 4 }, ) + splitter("workerStep") { gridSize -> + (0 until gridSize).associate { + "partition-$it" to ExecutionContext() + } + } } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt deleted file mode 100644 index 9d7d7db..0000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/splitter/inner/SampleApplicationTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Spring Batch Plus - * - * Copyright 2022-present NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.spring.batch.plus.sample.step.partitionstep.splitter.inner - -import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.Job -import org.springframework.batch.core.job.parameters.JobParametersBuilder -import org.springframework.batch.core.launch.JobOperator -import org.springframework.beans.factory.getBean -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -open class SampleApplicationTest { - @Test - fun run() { - val applicationContext = runApplication() - val jobOperator = applicationContext.getBean() - val job = applicationContext.getBean("testJob") - - val jobParameters = - JobParametersBuilder() - .toJobParameters() - val jobExecution = jobOperator.start(job, jobParameters) - - assert(BatchStatus.COMPLETED == jobExecution.status) - println(jobExecution) - } -} From 709811172a6d2a24e4d2d00a846f399f4f2ea181 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 6 Jul 2026 10:12:51 +0900 Subject: [PATCH 45/45] Move taskletStep redundancy check to integration test Signed-off-by: Taeik Lim --- .../TaskletStepBuilderDslIntegrationTest.kt | 55 +++++++++++++++++++ .../step/SimpleStepBuilderDslTest.kt | 8 ++- .../step/TaskletStepBuilderDslTest.kt | 55 ------------------- 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt index 7bce7a9..e78b498 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt @@ -19,7 +19,9 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.step import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import io.mockk.mockk import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus import org.springframework.batch.core.annotation.AfterChunk @@ -28,13 +30,20 @@ import org.springframework.batch.core.annotation.BeforeChunk import org.springframework.batch.core.annotation.BeforeStep import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.JobExecution +import org.springframework.batch.core.job.JobInstance import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository +import org.springframework.batch.core.step.StepExecution +import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.tasklet.Tasklet import org.springframework.batch.infrastructure.item.ExecutionContext import org.springframework.batch.infrastructure.item.ItemStream +import org.springframework.batch.infrastructure.repeat.RepeatCallback import org.springframework.batch.infrastructure.repeat.RepeatStatus +import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate +import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.annotation.AnnotationConfigApplicationContext @@ -45,6 +54,8 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager +import java.util.UUID +import java.util.concurrent.ThreadLocalRandom import javax.sql.DataSource /** @@ -265,6 +276,50 @@ internal class TaskletStepBuilderDslIntegrationTest { assertThat(afterChunkCallCount).isEqualTo(1) } + @Nested + inner class RedundancyCheck { + + @Suppress("DEPRECATION") + @Test + fun testStepOperationsIgnoreTaskExecutorAndExceptionHandler() { + // given + var iterateCount = 0 + var taskExecutorCallCount = 0 + var exceptionHandlerCallCount = 0 + val stepBuilder = StepBuilder(UUID.randomUUID().toString(), mockk(relaxed = true)) + + // when + val step = + stepBuilder + .tasklet({ _, _ -> RepeatStatus.FINISHED }, ResourcelessTransactionManager()) + .stepOperations( + object : RepeatTemplate() { + override fun iterate(callback: RepeatCallback): RepeatStatus { + ++iterateCount + return super.iterate(callback) + } + }, + ) + .taskExecutor { task -> + ++taskExecutorCallCount + task.run() + }.exceptionHandler { _, e -> + ++exceptionHandlerCallCount + throw e + }.build() + val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) + val jobExecution = JobExecution(0L, jobInstance, JobParameters()) + val stepExecution = StepExecution(0L, step.name, jobExecution) + step.execute(stepExecution) + + // then + assertThat(stepExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(iterateCount).isEqualTo(1) + assertThat(taskExecutorCallCount).isEqualTo(0) + assertThat(exceptionHandlerCallCount).isEqualTo(0) + } + } + @Configuration @EnableBatchProcessing @EnableJdbcJobRepository( diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt index 77e80c4..b700de9 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslTest.kt @@ -55,7 +55,11 @@ import org.springframework.transaction.interceptor.TransactionAttribute import java.util.UUID import java.util.concurrent.ThreadLocalRandom +/** + * Tests for deprecated SimpleStepBuilderDsl, including its legacy execution-backed redundancy check. + */ internal class SimpleStepBuilderDslTest { + @Test fun testReader() { // given @@ -332,8 +336,9 @@ internal class SimpleStepBuilderDslTest { @Nested inner class RedundancyCheck { + @Test - fun testStepOperationsAndRedundantSettings() { + fun testStepOperationsIgnoreTaskExecutorAndExceptionHandler() { // given val chunkSize = 3 val readLimit = 20 @@ -363,7 +368,6 @@ internal class SimpleStepBuilderDslTest { } }, ) - // redundant .taskExecutor { task -> ++taskExecutorCallCount task.run() diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt index 1fd6ef3..d7f0db2 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslTest.kt @@ -23,29 +23,18 @@ import io.mockk.mockk import io.mockk.verify import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy -import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test -import org.springframework.batch.core.BatchStatus -import org.springframework.batch.core.job.JobExecution -import org.springframework.batch.core.job.JobInstance import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.listener.ChunkListener -import org.springframework.batch.core.step.StepExecution -import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.batch.core.step.builder.TaskletStepBuilder import org.springframework.batch.core.step.tasklet.TaskletStep import org.springframework.batch.infrastructure.item.ItemStream -import org.springframework.batch.infrastructure.repeat.RepeatCallback import org.springframework.batch.infrastructure.repeat.RepeatOperations -import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate -import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.core.task.TaskExecutor import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.interceptor.TransactionAttribute -import java.util.UUID -import java.util.concurrent.ThreadLocalRandom /** * Unit tests for TaskletStepBuilderDsl's delegation to Spring Batch's TaskletStepBuilder. @@ -234,48 +223,4 @@ internal class TaskletStepBuilderDslTest { }.hasMessageContaining("exceptionHandler is redundant") } - @Nested - inner class RedundancyCheck { - - @Suppress("DEPRECATION") - @Test - fun testStepOperationsAndRedundantSettings() { - // given - var iterateCount = 0 - var taskExecutorCallCount = 0 - var exceptionHandlerCallCount = 0 - val stepBuilder = StepBuilder(UUID.randomUUID().toString(), mockk(relaxed = true)) - - // when - val step = - stepBuilder - .tasklet({ _, _ -> RepeatStatus.FINISHED }, ResourcelessTransactionManager()) - .stepOperations( - object : RepeatTemplate() { - override fun iterate(callback: RepeatCallback): RepeatStatus { - ++iterateCount - return super.iterate(callback) - } - }, - ) - // redundant - .taskExecutor { task -> - ++taskExecutorCallCount - task.run() - }.exceptionHandler { _, e -> - ++exceptionHandlerCallCount - throw e - }.build() - val jobInstance = JobInstance(ThreadLocalRandom.current().nextLong(), UUID.randomUUID().toString()) - val jobExecution = JobExecution(0L, jobInstance, JobParameters()) - val stepExecution = StepExecution(0L, step.name, jobExecution) - step.execute(stepExecution) - - // then - assertThat(stepExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(iterateCount).isEqualTo(1) - assertThat(taskExecutorCallCount).isEqualTo(0) - assertThat(exceptionHandlerCallCount).isEqualTo(0) - } - } }