From 8b015302c17d967ff492a7faf0121c586a166db8 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Fri, 15 May 2026 13:29:31 +0900 Subject: [PATCH 01/69] 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 487983a8..973ea985 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/69] 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 48dd63b2..638888a3 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 33411f26..68c23d4f 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 cdd24800..1b024ca6 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 8d1a7685..1bcc0f8e 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 ecd48047..30da241a 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 23e07601..299a6770 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 91d83484..140a6dab 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 fd5f062d..e9b585f6 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 8193f12e..cfa985c6 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 34329980..787e84c4 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 8058a921..b7c08df2 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 16ee812b..19866167 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 59816027..2398e5e4 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 8ef4948a..9440aa6a 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 09cb7118..bd80914b 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 cc240bf1..aab8bdda 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 73e3d5bb..17155ac7 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 784fc341..0f60384e 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 37746339..f72b3fc7 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 563fc080..daf2fa50 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 21e7c109..9e2d2b84 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 3a29ab98..63ac6691 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 381a7f0f..3a16e4fe 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 e671a17c..2288810e 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 9a537424..1429f7a6 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 8b0eb112..6895f9b5 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 7172045b..35b6566a 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 0ceb253e..f6fe67c8 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 d861862e..8c104b9e 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 96f3701b..e83b5156 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 6b0934a0..5164428e 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 373612a2..1fb3d09f 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 c135796c..d0cb5a36 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 b09d4817..318848a7 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 dc49d933..a56b36e7 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 0c964dff..5763d148 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 253a1f4c..44b34b5b 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 b003905e..f5d545e2 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 3dbf1376..4a3d2697 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 6f01e261..5d9f24ed 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 5bd932e5..4fe75243 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 803f9f86..b2b10c56 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 056a8ccb..8c2e19e0 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 c64969c5..9c99dccc 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 f03e7e1d..dfb54415 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 8d383a05..a41b4df6 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 b3378d33..a4b7d8f6 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 92727bbf..ea920423 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 c0f94619..d569d4e2 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 4523bba3..11bc86f8 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 3dc0916b..2696e884 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 89e72bc5..74d2f88e 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 12880bed..996b57b8 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 b50c31b8..b52e5fa0 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 85be5db0..08f59537 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 2dc64e0d..71f5a1d8 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 3fd76852..36addb63 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 90392b9c..04672def 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 cb6cd789..8a8e67b8 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 07cc0a0d..df5880fd 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 34513d5c..a75a7ba8 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 20bc07b5..b01f2308 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 7c19b89f..bcd1c1a6 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 ac6f8aa1..eb8d034f 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 03e497b9..e530f012 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 96500043..be5d27c4 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 2cf19dde..f48cb4c0 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 2719cf57..ef5ef66e 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 03f85863..3508a950 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 f807a892..2ccaabf8 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 286df35f..87a737da 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 57cb45a8..ccd8798d 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 32824379..cb210af4 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 3bc2fd46..fa40072a 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/69] 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 973ea985..199478b0 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 93eecbd6..bcab002f 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 4c81d6d9..7dfcbadc 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/69] 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 638888a3..525dde66 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 68c23d4f..eb111baa 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 1b024ca6..bb679d39 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 1bcc0f8e..1622e78e 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 30da241a..1db52d18 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 299a6770..da51e0c7 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 140a6dab..043d46fc 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 e9b585f6..d4e9eacd 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 cfa985c6..5d08af0c 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 787e84c4..a5892ea4 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 b7c08df2..173bc689 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 19866167..44ce5f7b 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 2398e5e4..f5192d4a 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 9440aa6a..f255cab0 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 6895f9b5..534a5f84 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 35b6566a..3b7048c5 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 f6fe67c8..861ac96b 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 a75a7ba8..e02a7d4f 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 b01f2308..bd65f54a 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 bcd1c1a6..512d7829 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 eb8d034f..c2d74b3e 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 e530f012..eafdaa2d 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 be5d27c4..c3ad20e7 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/69] 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 199478b0..a3e9318b 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 7dfcbadc..9d630823 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 525dde66..1b9eaa13 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 eb111baa..4c4e0087 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 bb679d39..ce49f29e 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 1622e78e..d00fcf2d 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 1db52d18..22854436 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 da51e0c7..938c02d8 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 043d46fc..de2b4248 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 d4e9eacd..9fb05642 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 5d08af0c..09ee2693 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 a5892ea4..965069e2 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 173bc689..c3641887 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 44ce5f7b..e8699099 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 f5192d4a..3fec1529 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 f255cab0..a29fb061 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 bd80914b..03c66ee2 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 aab8bdda..47ad9eca 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 17155ac7..faa23684 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 0f60384e..59d5abd1 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 f72b3fc7..c1d3b6fb 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 63ac6691..e89cd690 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 3a16e4fe..13c0361b 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 a43e167c..d812a5d0 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 1429f7a6..f05d71bf 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 3b7048c5..cc2c10d0 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 7639e821..29d1c0b6 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 e8c1586d..11247f6f 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 8c104b9e..cabbf522 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 e83b5156..75b31f86 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 5164428e..69b118c5 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 1fb3d09f..4a3ead46 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 d0cb5a36..7c1822e8 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 44b34b5b..eed63e1a 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 f5d545e2..ba9d8c34 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 b2b10c56..c8023064 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 8c2e19e0..6c2eec4f 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 a4b7d8f6..b8517b2d 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 ea920423..78c569d2 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 74d2f88e..50e0c9fe 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 996b57b8..27fa4cb4 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 b52e5fa0..1d5f067e 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 66df9240..772c5ea7 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/69] 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 1b9eaa13..c74a50e4 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 4c4e0087..b636bceb 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 ce49f29e..3c73329c 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 d00fcf2d..b3fe852f 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 22854436..aa95a8c0 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 938c02d8..26f06278 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 de2b4248..c38e293e 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 9fb05642..700f3307 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 09ee2693..c2a2e64b 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 965069e2..b3b5f0d1 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 c3641887..5f311914 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 e8699099..41654303 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 3fec1529..d0c1cfd1 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 a29fb061..09cf9b91 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 512d7829..b82a25bd 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 df8403ec..864bb2f9 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/69] 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 495c7926..18dec13a 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 e0fcc874..4161006c 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 f008e2be..b77061d4 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 5400eb98..65670ba9 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 8f0c58e3..ef0d551b 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 ec808989..73f95ca7 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 da4a5c58..df17fc3b 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 b1ea2fd9..f4518d04 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 97e5c2db..4d366292 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 495c7926..18dec13a 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 2ce45232..a9d6526b 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 7795e232..5789025c 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 8e133b1c..276e2317 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 d3d3ad7b..b11d43a6 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 63bdc28f..0ad2423e 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 ca771e3d..5aeb9566 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 9bfe1ffd..54df5b62 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 46ce3c4c..a6a985ab 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 f9ce2588..f7cd0e5a 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 b153ef3d..b576f204 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 269fff53..ad0dfab6 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 4ef9d937..6e638b01 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 63e42eaa..7dd315bc 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 a3efe26b..fa75c67d 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 1ee70876..465b6d1f 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 52aa8c78..15c47cf1 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 be64330f..ade72d24 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 c22e28c4..48cadd7c 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 b2d2cab2..086c0013 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 fd1c8c7c..6c6e903d 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 58695317..9e6c4152 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 f2333599..453477a6 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 1559dafe..8a33ed06 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 ba8a47d3..f25627fd 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 718302fb..a65cc0f5 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 8a80ce28..3ed49be1 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 d64b8fa8..0ca69d3b 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 bb2e08ce..6554230c 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 851ecbaf..df47010d 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 d9eeba3d..2ebcd96c 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 abeb765b..86ab461e 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 3b1d6c1b..ebfb5865 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 ab9348c8..65537f4b 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 795b599a..e0410cd3 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 f685bf9e..de9bc5bd 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 d6bfb710..25aa00dd 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 de12d482..816ed0d4 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 40f7685c..43b8c65a 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 9f732a89..514e0f34 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 d9b036f6..76781bda 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 a31924ad..52a7c60c 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 874cace3..27156ad8 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 53028024..bfef6a4b 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 7ff6e342..c135dd07 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 015f6490..19eb7cf8 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 f433c18a..e753a623 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 4e891c6e..ae40c645 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 6b48cb24..f82b91e3 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 b0a90652..0f6d1de3 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 d096c161..5b21cea5 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 83903d17..3c2a47aa 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 3e2cba4c..1538329e 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 bb877174..faf5f942 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 7f7a57c2..dbee6355 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 db14fdbd..13ebf972 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 13aa896e..e11d8eed 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 21f25795..27e78cea 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 a287e2a6..0e4583b0 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 226da478..5dd14205 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 e01e204b..ead90946 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 d974aeb4..55ffa776 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 cfd347a8..ca8778fb 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 5e35ad4e..5f5c65b3 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 0723f2c3..7504071d 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 242ea677..b689920e 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 ce39cd1c..673a5b2f 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 716ad77b..ddd2011a 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 4e4003f6..864ed133 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 06f037a0..e45ec7d4 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 14b91e19..3efb2b69 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 80a3ea0c..2e16ae2b 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 2e30dfc1..25195a98 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 6e6e25af..34e7e5a3 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/69] 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 facf8fdc..90c82df3 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 aebc0eff..f268b59a 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/69] 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 88c0b69c..043d0209 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 0dfbc5b1..308ce22d 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 785c6d7e..785ca2a1 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 a362b240..87b38831 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 90c77177..1b1003fe 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 e2ec4313..d1373a2e 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 99636808..422d7000 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 1ee4c5bb..10b807f1 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 885013ba..940e155f 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 403a389d..4f79be9a 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 e58329ce..871d36d0 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 7fb4b95a..e168f515 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 680ed0f4..bdbfc6bb 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 bae7930b..0268368b 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 92447f17..c0dbf81a 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 c3d4f7b9..a76abd36 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 864c9025..87bdfe36 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 24d9f8c4..81761684 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 1ae5286a..121e8bc5 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 73e23c9a..d674a2e2 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 c89bddbc..570864e5 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 310fee80..edab0ff2 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 1d14fc70..327d8a5e 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 3c6d3f8d..c014f300 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 aefda05a..3333d83c 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 d4b4a999..90ecf61f 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 df330a14..46c79673 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 e9f3b50f..6aafd68a 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 9af85ad2..9e24ceb3 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 187a6879..b2f469dd 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 ddf234d5..02a2b47f 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 812c790e..cf2933c4 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 97d3525d..56e227f8 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 c459c7e7..fe6900ad 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 646da3ea..ffd6fc46 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 645ed07d..74c4aa7e 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/69] 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 043d0209..01bc155b 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 308ce22d..77341983 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 785ca2a1..1fca2a38 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 87b38831..48379047 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 1b1003fe..36c1025e 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 d1373a2e..b330ab82 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 422d7000..09b5918d 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 10b807f1..8a539aca 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 940e155f..bcaf9c76 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 4f79be9a..2ed5f6c1 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 871d36d0..e9489c9e 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 3c74f73e..211351ad 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 e168f515..aa7f7899 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 bdbfc6bb..30ee4cfe 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 dcb7259f..1df4c780 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 0268368b..4d6e043b 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 c0dbf81a..181c2ff7 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 a76abd36..95d45413 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 a721b14e..dd5c0791 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 87bdfe36..994e7703 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 81761684..7a7ad921 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 121e8bc5..6dfdc4f7 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 d674a2e2..1d7b2876 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 570864e5..c2615144 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 edab0ff2..b516f6a3 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 327d8a5e..e6d8acba 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 c014f300..a33ef685 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 3333d83c..024d5087 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 90ecf61f..9f6da80c 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 46c79673..c83b60c0 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 6aafd68a..4bed7b22 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 9e24ceb3..b5fff163 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 b2f469dd..4b15202f 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 02a2b47f..519e9216 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 cf2933c4..43640304 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 56e227f8..52c852cd 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 fe6900ad..d5d7115e 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 ffd6fc46..ec2f83b8 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 82ad9e31..893133ec 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 74c4aa7e..94cdc052 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 9ad59be8..ed9023c1 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/69] 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 4d6e043b..6ca2edb3 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 994e7703..b50e8a30 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 c83b60c0..73bfe84d 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 b5fff163..a3812784 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/69] 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 00000000..6c2036dd --- /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 6ca2edb3..5fdfa391 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/69] 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 6c2036dd..3e00bd3c 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 b50e8a30..fbe0c73c 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/69] 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 e6d8acba..10a84371 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 a33ef685..5f5c2418 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 4b15202f..9901583c 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 d5d7115e..09b86925 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 ec2f83b8..c77d5d62 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/69] 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 10a84371..adec8e54 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 09b86925..c8c7b47f 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/69] 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 c2615144..9a73a7a6 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 43640304..8e3c8f21 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/69] 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 00000000..aefb4fb2 --- /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 9901583c..8da2e2a0 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 52c852cd..1b8f9ec1 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 c8c7b47f..f2bcc47f 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 c77d5d62..66f04226 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/69] 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 01bc155b..cf3dc7e7 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 77341983..e1aa1a66 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 1fca2a38..19031545 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 48379047..f78e33fa 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 36c1025e..f9fae3d2 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 b330ab82..1ae1bbdf 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 09b5918d..bf35c8ea 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 8a539aca..b3d5145b 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 bcaf9c76..56da0b79 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/69] 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 1b8f9ec1..f0dafaf0 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/69] 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 8da2e2a0..4e00a05e 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 f2bcc47f..e43a1433 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/69] 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 fbe0c73c..2f0d5128 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 adec8e54..35ad2865 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 5f5c2418..aae2ba20 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 4e00a05e..0af43ccd 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 f0dafaf0..eecb10db 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 e43a1433..77e80c49 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 66f04226..5181aef6 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/69] 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 2f0d5128..aa9aac18 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/69] 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 bf35c8ea..98f9bdd6 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 aa9aac18..216d4a70 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 00000000..9c9b9700 --- /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 00000000..c2c6f02a --- /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/69] 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 a3e9318b..fd1847b9 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/69] 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 b516f6a3..95bfe782 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/69] 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 fd1847b9..8234dac0 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 18dec13a..5f869286 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 18dec13a..5f869286 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 3ed49be1..19d1efb3 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/69] 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 37f853b1..5dd3c012 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/69] 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 8234dac0..fd7d5b0a 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 1e805468..120bf063 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 8979f780..d5efbf1a 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 4ba4056c..8ddd9a23 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/69] 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 db01bfaa..6a4c7cbd 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 a49002ca..3c30b57a 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 23801c2d..b69c55e0 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 95f52c3d..699191c0 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 b82c442c..d5c3863c 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 db01bfaa..6a4c7cbd 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 50256cde..5792a674 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 0e49f00e..46f766e9 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 4017317f..58ff219f 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 ee154016..46f857ba 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 db499657..3fe97ddd 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 dbb0cb27..9fa19eda 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 1cdb3fc4..dce2c001 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 777c205d..79bade07 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 80071b57..adfc0e8a 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 b7e582b5..b49491c8 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 0a57c768..17405660 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 6734b7fa..f1765489 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 159bd660..624cef2f 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 235483b7..303dcf14 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 2d5309f0..8f62c869 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 dae66227..d5d92d59 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 6eeda43d..270151f6 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 a21c0f73..cf95dea7 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 84427780..0188302c 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 9de7b78a..617dd676 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 23a9530c..395fc31b 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 b08910a4..f091ae08 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 3d65d626..545e67d0 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 d2e40ac6..ccfe048e 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 718302fb..a65cc0f5 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 db01bfaa..6a4c7cbd 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 645cc00e..d14d7811 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 947e21bb..bb8f9112 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 dc31d538..499d97bb 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 23350029..a8a8fb21 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 e6355d91..6eebbd69 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 17f8933e..3d3ae5af 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 33c6682b..3abb2716 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 6d743ab6..9cb0bd01 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 b63fa7ee..fb73261c 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 08d8b47c..0a877978 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 0e11df62..aff90f5e 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 1fb15654..2099e31b 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 14469892..7a890750 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 1ba0a0af..b8e47c58 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 c0ea049a..d2d385f3 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 6696a3d6..4fe8da1a 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 9c004531..3a3fd6eb 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 63f16461..585b1e9e 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 3c17ec5b..1f501388 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 b9d1231b..e23ddb49 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 2899a551..c6996641 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 e66f545e..0e423f1d 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 2864460a..31ee7e1d 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 035a22c3..f41bc3b0 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 461bca27..a61aa92f 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 e9804313..c292a512 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 eff902e3..03e58204 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 d6f7acc9..41473092 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 15ecf0af..a9d73dd7 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 6e9c8a81..c3a46699 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 82ba6fae..d2782622 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 e3b91026..4407cc38 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 01a62f2f..59a5e32f 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 daaf1e98..b0fd60ec 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 3c0e4954..1780aa24 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 a66d16bd..94cfd86a 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 f56c2247..72d16924 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 bf8c1857..b40f2ca9 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 cef15d48..93129cb3 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 1a3ecdf7..6f0fee5b 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 cd179182..d230abed 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 afbcf54e..36281e07 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 98c3c5a6..41c83204 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 79e0b153..6ee70699 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 f3f45319..ca3a8d77 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 259dbe6f..60f200bd 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 601b6559..8ee9ff31 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 b91d81d4..613af7c1 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 0bf11a2c..5304a421 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 49bc22e7..ad792e0a 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 14273e9b..6e5bab39 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 554bb285..163ce2b8 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 28ab5312..f3c3aac7 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 8253c1f3..6d0180be 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 8e1fbbcf..812393cd 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 65ccb827..e7e34cda 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 81dbaf91..df6c3238 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 2f0f9aad..00a676f9 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 33161792..f2c83115 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 d639b16d..1bd1d7f7 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 d060e56b..0d05b9fd 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 5a40c11d..479039cd 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 02971cf7..3388eede 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 7d247d0b..f93b0a33 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 16df90c1..8ae66ae3 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 c742f0d4..0570e6ee 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 6afb31ae..a829bdfd 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 a31b9831..c60d7def 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 b7ef99ef..01460c46 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 cdc91e17..cbab7f2a 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 f313010e..7b24b9ae 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 c88f62bc..1f57f61b 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 72d240d2..d8e49ebd 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 6d4e1323..b1e3eef2 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 70068ba4..4719f0bc 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 5977d06f..87268c3a 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 a7b70527..60286bd9 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 0a8a4a4a..37f37753 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 8fe82746..08e2f259 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 71b81d05..2c1a577b 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 451b00e7..fbb70555 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 b5d2f7ff..e8a78b42 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 c31babae..daa975e2 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 4be92876..2e8c384f 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 1f70e8f5..038911b7 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 96de180c..76cd9baa 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 6fcd16d3..2d036a4b 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 c064cecd..05ba6709 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 6b65fe3e..879f1e92 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 570aa59c..d5bda71f 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 4b514c56..d8c848d6 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 e4f94830..46de6d53 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 2e85b6d3..183060cd 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 fd4a7deb..4e79f182 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 e031be37..9ebf5926 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 89c138d6..1416b795 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 3837a270..706faabf 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 8d566230..aafa99e8 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 8d3cfb9a..b5a4227d 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 0d832820..5b424c45 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 3fffe044..a05e088f 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 3201e74d..443f764a 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 562fe8c2..9066e26d 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 38795109..1148cb8d 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 1b56569a..8fe6e610 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 20eeba7f..c1530d9b 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 09412cf7..85539682 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 9c7d1c4e..59ed0532 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 75dd3471..6f704c18 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 853a627f..18a811bc 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 f96878ce..65896969 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 071bee7d..3b7bbfa7 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 2473c6be..aff196cf 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 81e5854f..2ed65678 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 38b0d4b7..bc390311 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 8791d4dc..7ce736ca 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 bb3f05cc..2afd988d 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 3d6f1fd5..c8f43780 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 2ef278c1..1a20e7f2 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 ea6cfe60..f10bec1a 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 3539d94a..08ba77ef 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 717f11a0..292ea2cd 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 dd1a34b1..51e74833 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 567761af..0763f2ec 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 3b1e1e29..6fb60549 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 50d29e4e..fc3f63ac 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 0a6f61e8..e80dfbdb 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 c36fd02c..49543173 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 07f8df34..09557724 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 9b0ce2b5..c6f22b95 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 50b26c1e..34931deb 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 e7a82736..76915ebf 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 fa8f3899..aeb2f6ef 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 91f09c54..4c60947c 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 72bb95ba..f28ff969 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 e790532c..7f447c9c 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 d22ba606..c9002ef1 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 01c93aeb..e157549c 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 6c833749..cec07eb1 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 3d9ea9a8..b0f40714 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 5594c49d..2159eed8 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 d331387c..9ee88a45 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 7f985807..7ebbe7d9 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 564b41a6..daa1842e 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 13e1ac6d..6bbe6496 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 3ca323a0..09e85da6 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 b1536e28..2bb8e73b 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 f516cd40..7482a2ff 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 8ded8c2f..e246455d 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 4245201d..3cecc75c 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 e7809578..a7af6a22 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 8c045cea..96541bd8 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 4796bc39..959b19e3 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 32550414..4c77d9a4 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 33d387de..65dbc3fc 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 8b3f695c..89752f0a 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 c787af12..d5f8374f 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 983d572a..e38903b1 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 a6f28932..3413569c 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 a855a183..c1602e2e 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 01f71c01..10701b12 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 d6ab8751..2950ac9e 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 36c4c96e..60256c80 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 510e1802..2471cfd9 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 3b9c0f67..753ce3be 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 110eb2d0..1fd8cf56 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 36a6adb8..7a5ce6e5 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 39320822..c6764b6b 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 d8ba114a..73eceba6 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 e357a5bc..b6818c47 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 fd3e71d6..44303111 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 3b6a0020..a6996f06 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 b1cb3a07..3b6a06aa 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 3e85270a..eff26a95 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 d1c7145c..e5f4254c 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 8c75ad8a..40bc960f 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 a401c30e..82054978 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 664a213e..1b383306 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 3392d091..c6d052fb 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 4bc6f24b..3ab33483 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 d4a8806c..afe71a69 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 efc94346..781db97e 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 c8c0ac45..d728f942 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 7a7c9092..be77e03b 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 8c9cc291..ef90ee3d 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 c022610d..2e97f848 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 550514ee..fe1953dc 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 d49f2d59..90d50661 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 01e6ea70..d7c56686 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 54013af2..253b7da5 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 2f0c7596..9bff9ead 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 514e8254..770c95df 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 365d9af7..6815d099 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 63711248..0d2491ae 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 783a5139..6d391b6b 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 4bbefdc0..9d7d7db6 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 38ab6c47..578017a6 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 b5a70afb..80e50c2c 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 250611ad..8be72057 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 1452146f..aef0d190 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 2ce6bc6f..44d26a8d 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 48a25dcd..366bf6ee 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 658be126..e75bf97b 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 733606a8..f590f68c 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 af885e58..4a268d8f 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 59dac36b..3699538a 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 0d096998..29e7ebc7 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 8c49b286..1ebe8947 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 d1eb40c9..7e2528d4 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 79b6bd3a..fa40b7af 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 2f68e7f6..d7e1e31c 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 21c3b2c2..4b6d5064 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 6587b574..d0553fcb 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 8648c5bc..6f239cbd 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 75b80ff4..bf8c43d4 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 3b3c9145..77eb3465 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 0681d417..39f379df 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 7e6c638f..4211468c 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 c63c7af8..e4c2c86b 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 d00f4482..9d548839 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 6d0ec653..bf313d85 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 23dc2f79..7732e1d8 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 d5626923..63926089 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 8dfceb32..b03f7d8b 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 5bd4c41c..6b3d01e2 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 22ab239d..fb5c81af 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 7617a974..bc05e71b 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 06fcbc9a..8152a456 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 41a1d88c..21f6d063 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 d11aef68..15e92038 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 c21741e9..a146d9a2 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 e808d9a0..bef074ea 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 1ad20bc1..ce87a17a 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 1da5c164..c5fba493 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 139d559a..80e39d2a 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 f37734a7..bb515f4c 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 03f8c4c2..1af7a768 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 eee53a24..46b0390b 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 46e43f2b..c0170aec 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 de584d52..ca9b7c4a 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 446c55da..3039a2f3 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 f2e4aa9d..405aa48c 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 1152fde0..f4121e90 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 cdecc7f8..801aecd2 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 54900579..f8291329 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 3ed24a0f..0556652d 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 5947b440..38e4ab48 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 8701e52f..bb31cd17 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 3131fdfc..1f5f5671 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 1f5655c0..b68b8dca 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 6c14f4ac..f284c7b0 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 c70baeb9..51b24c52 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 e8c61b06..e5e0810b 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 73974705..ec113673 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 8da405ff..9446a6e5 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 0f0261fb..3881a38d 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 402f1156..7d64b41b 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 64dc8b94..4c2a6299 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 2fbbad97..2f159d60 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 22b3757d..3c827486 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 57ad809c..f67a4f93 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 9cb62638..49cc4eed 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 1945fa44..f43870c6 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 2d7745fe..a9e7cb3b 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/69] 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 7a890750..00000000 --- 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 b8e47c58..00000000 --- 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 d2d385f3..00000000 --- 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 4fe8da1a..00000000 --- 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 89752f0a..00000000 --- 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 d5f8374f..00000000 --- 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 2471cfd9..00000000 --- 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 753ce3be..00000000 --- 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 1fd8cf56..00000000 --- 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 7a5ce6e5..00000000 --- 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 be77e03b..00000000 --- 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 ef90ee3d..00000000 --- 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/69] 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 65896969..1ef50573 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 29e7ebc7..4fef2ec0 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/69] 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 6d391b6b..d44cae6c 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/69] 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 1416b795..00000000 --- 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 706faabf..00000000 --- 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 49543173..00000000 --- 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 09557724..00000000 --- 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 c6f22b95..00000000 --- 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 34931deb..00000000 --- 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 76915ebf..00000000 --- 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 aeb2f6ef..00000000 --- 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 4c60947c..00000000 --- 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 f28ff969..00000000 --- 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 7f447c9c..00000000 --- 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 c9002ef1..00000000 --- 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 b0f40714..00000000 --- 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 2159eed8..00000000 --- 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 09e85da6..00000000 --- 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 2bb8e73b..00000000 --- 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/69] 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 3b7bbfa7..00000000 --- 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 aff196cf..00000000 --- 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 f10bec1a..00000000 --- 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 08ba77ef..00000000 --- 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/69] 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 b5a4227d..1b7d8031 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 a05e088f..55887c27 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 9066e26d..656d1d64 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 8fe6e610..68d1d908 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 85539682..3adc0bb0 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 6f704c18..90c6a2f6 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 1ef50573..0b58643c 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 bc390311..975a3ecf 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 2afd988d..12d110f3 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 1a20e7f2..134b3603 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 51e74833..4288a820 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 6fb60549..2a72aff2 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 e80dfbdb..ac169cbd 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 cec07eb1..1281de50 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 7ebbe7d9..5ed7999b 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 6bbe6496..6b456af5 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 e246455d..fa2da1df 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 a7af6a22..e6340d93 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 959b19e3..3f05b048 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 65dbc3fc..d20743a7 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/69] 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 00000000..670d85b0 --- /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 00000000..c2fdb9eb --- /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/69] 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 0b58643c..68b9481f 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 c2fdb9eb..c4996f8f 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/69] 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 f590f68c..00000000 --- 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 4a268d8f..00000000 --- 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/69] 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 00000000..e1c408b3 --- /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 98f9bdd6..6b65d070 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 8e3c8f21..76711b8b 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 781db97e..962cf496 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 d728f942..dce102f3 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 670d85b0..cfb28ac6 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 c4996f8f..5415068e 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 3ab33483..291a4eb0 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 afe71a69..018ae82f 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 2e97f848..19432be0 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 fe1953dc..8016b883 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/69] 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 00000000..56ac9ef9 --- /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 6b65d070..646fdef1 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 519e9216..b23f0266 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 eff26a95..ebf1e895 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 e5f4254c..3030c21e 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 1b383306..5a80abd9 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 82054978..2d04d2e3 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 40bc960f..840ad3f3 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 c6d052fb..3b2d2d37 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/69] 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 56ac9ef9..a319ac6d 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 e1c408b3..96a2cd4c 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/69] 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 646fdef1..92753265 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 a319ac6d..a81cf2b3 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 00000000..1e638a1c --- /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 aae2ba20..6eb85eca 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 5181aef6..1fd6ef3f 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 00000000..85d168d9 --- /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 aef0d190..c88d3f55 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 44d26a8d..5d60f122 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 366bf6ee..4339a7ee 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 e75bf97b..c94b6f4a 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 6f239cbd..8f2b0ec0 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 00000000..7ae688c2 --- /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 3699538a..546ee1fe 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 4fef2ec0..24b33860 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 1ebe8947..99cd342d 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 7e2528d4..eb854aba 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 fa40b7af..39e3499d 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 d7e1e31c..d8055b82 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 4b6d5064..27cbca46 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 d0553fcb..256a17d8 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 00000000..5eb79a29 --- /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 00000000..cf96423c --- /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 00000000..6bafe1b7 --- /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 00000000..eb51ee86 --- /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 00000000..6e03a2e4 --- /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 80e50c2c..1356df99 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 8be72057..eb99fdac 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 00000000..204326f6 --- /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 00000000..9867a710 --- /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 00000000..06b875d7 --- /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 bf8c43d4..a1f17de1 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/69] 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 00000000..f4ed4628 --- /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 00000000..ab1336f6 --- /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 00000000..068e5deb --- /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/69] 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 92753265..072e0a1d 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 a81cf2b3..701fcf31 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 96a2cd4c..ba40ae95 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 00000000..1fff09ea --- /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 1e638a1c..7bce7a99 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 eecb10db..6bfc186d 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 00000000..5fc237e9 --- /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 90d50661..e9f742ee 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 d7c56686..efaae672 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 770c95df..7b2d1833 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 578017a6..8fdd12ed 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 0d2491ae..9b387a3c 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 d44cae6c..ec180f78 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 00000000..a4046229 --- /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 00000000..6351719f --- /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 6815d099..0f3e4769 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 253b7da5..e1f50fc9 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 9bff9ead..6b2ac17d 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 9d7d7db6..00000000 --- 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/69] 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 7bce7a99..e78b4980 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 77e80c49..b700de9c 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 1fd6ef3f..d7f0db21 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) - } - } } From 21c069a1bbeabb520d3ab1f8f82c584a5f6289c5 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Tue, 7 Jul 2026 20:18:30 +0900 Subject: [PATCH 46/69] Polish chunkorientedStep tests, samples Signed-off-by: Taeik Lim --- ...nkOrientedStepBuilderDslIntegrationTest.kt | 268 ++++++++++++++++++ .../step/ChunkOrientedStepBuilderDsl.kt | 10 +- .../step/ChunkOrientedStepBuilderDslTest.kt | 4 + .../step/chunkorientedstep/config/README.md | 6 + .../annotationlistener/mixed/TestJobConfig.kt | 99 ------- .../writerlistener/SampleApplicationTest.kt | 46 --- .../SampleApplicationTest.kt | 3 +- .../interruptionpolicy/TestJobConfig.kt | 66 +++++ .../chunklistener}/SampleApplicationTest.kt | 3 +- .../chunklistener/TestJobConfig.kt | 6 +- .../SampleApplicationTest.kt | 47 +++ .../processorlistener/TestJobConfig.kt | 6 +- .../readerlistener}/SampleApplicationTest.kt | 3 +- .../readerlistener/TestJobConfig.kt | 6 +- .../SampleApplicationTest.kt | 47 +++ .../stepexecutionlistener/TestJobConfig.kt | 90 ++++++ .../writerlistener}/SampleApplicationTest.kt | 3 +- .../writerlistener/TestJobConfig.kt | 6 +- .../chunklistener}/SampleApplicationTest.kt | 3 +- .../chunklistener/TestJobConfig.kt | 6 +- .../SampleApplicationTest.kt | 47 +++ .../processorlistener/TestJobConfig.kt | 6 +- .../readerlistener/SampleApplicationTest.kt | 47 +++ .../readerlistener/TestJobConfig.kt | 6 +- .../SampleApplicationTest.kt | 47 +++ .../stepexecutionlistener/TestJobConfig.kt | 87 ++++++ .../writerlistener/SampleApplicationTest.kt | 47 +++ .../writerlistener/TestJobConfig.kt | 6 +- .../SampleApplicationTest.kt | 47 +++ .../observationregistry/TestJobConfig.kt | 66 +++++ .../readerlistener/SampleApplicationTest.kt | 46 --- .../config/stream/SampleApplicationTest.kt | 1 + .../config/stream/TestJobConfig.kt | 4 +- .../SampleApplicationTest.kt | 3 +- .../TestJobConfig.kt | 6 +- .../SampleApplicationTest.kt | 1 + .../transactionattribute/TestJobConfig.kt | 4 +- .../SampleApplicationTest.kt | 3 +- .../transactionmanager/TestJobConfig.kt | 67 +++++ .../writerlistener/SampleApplicationTest.kt | 46 --- .../step/chunkorientedstep/creation/README.md | 6 + .../chunksize/SampleApplicationTest.kt | 3 +- .../{ => creation}/chunksize/TestJobConfig.kt | 6 +- .../chunkorientedstep/faulttolerant/README.md | 6 + .../retry/SampleApplicationTest.kt | 1 + .../faulttolerant/retry/TestJobConfig.kt | 4 +- .../retrylistener/SampleApplicationTest.kt | 1 + .../retrylistener/TestJobConfig.kt | 4 +- .../retrypolicy/SampleApplicationTest.kt | 1 + .../retrypolicy/TestJobConfig.kt | 4 +- .../skip/SampleApplicationTest.kt | 1 + .../faulttolerant/skip/TestJobConfig.kt | 4 +- .../skiplistener/SampleApplicationTest.kt | 1 + .../skiplistener/TestJobConfig.kt | 4 +- .../SampleApplicationTest.kt | 1 + .../skiplistenerannotation/TestJobConfig.kt | 6 +- .../skippolicy/SampleApplicationTest.kt | 1 + .../faulttolerant/skippolicy/TestJobConfig.kt | 4 +- 58 files changed, 1056 insertions(+), 317 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/README.md delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{executor => interruptionpolicy}/SampleApplicationTest.kt (98%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener/readerlistener => listener/annotation/chunklistener}/SampleApplicationTest.kt (97%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener => listener/annotation}/chunklistener/TestJobConfig.kt (92%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener => listener/annotation}/processorlistener/TestJobConfig.kt (92%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener/chunklistener => listener/annotation/readerlistener}/SampleApplicationTest.kt (97%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener => listener/annotation}/readerlistener/TestJobConfig.kt (92%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener/mixed => listener/annotation/writerlistener}/SampleApplicationTest.kt (97%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener => listener/annotation}/writerlistener/TestJobConfig.kt (92%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{annotationlistener/processorlistener => listener/steplistener/chunklistener}/SampleApplicationTest.kt (97%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{ => listener/steplistener}/chunklistener/TestJobConfig.kt (93%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{ => listener/steplistener}/processorlistener/TestJobConfig.kt (93%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{ => listener/steplistener}/readerlistener/TestJobConfig.kt (92%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{ => listener/steplistener}/writerlistener/TestJobConfig.kt (93%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{chunklistener => taskexecutor}/SampleApplicationTest.kt (98%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{executor => taskexecutor}/TestJobConfig.kt (91%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/{processorlistener => transactionmanager}/SampleApplicationTest.kt (98%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/README.md rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/{ => creation}/chunksize/SampleApplicationTest.kt (98%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/{ => creation}/chunksize/TestJobConfig.kt (91%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/README.md diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt new file mode 100644 index 00000000..b66d8388 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt @@ -0,0 +1,268 @@ +/* + * 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.listener.SkipListener +import org.springframework.batch.core.repository.JobRepository +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.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 chunk-oriented steps through the public Kotlin DSL. + */ +internal class ChunkOrientedStepBuilderDslIntegrationTest { + + @Test + fun testChunkOrientedStep() { + // 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 readLimit = 6 + var readCallCount = 0 + val writtenItems = mutableListOf() + val reader: ItemReader = + ItemReader { + if (readCallCount < readLimit) { + readCallCount++ + } else { + null + } + } + val writer: ItemWriter = + ItemWriter { chunk -> + writtenItems.addAll(chunk.items) + } + + // when + val job = + batch { + job(jobName) { + step(stepName) { + chunk(3) { + transactionManager(ResourcelessTransactionManager()) + reader(reader) + writer(writer) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(readCallCount).isEqualTo(readLimit) + assertThat(writtenItems).containsExactly(0, 1, 2, 3, 4, 5) + } + + @Test + fun testChunkOrientedStepWithAnnotationListener() { + // 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() + var readCallCount = 0 + var beforeStepCallCount = 0 + var afterStepCallCount = 0 + var beforeChunkCallCount = 0 + var afterChunkCallCount = 0 + val reader: ItemReader = + ItemReader { + if (readCallCount < 1) { + readCallCount++ + } else { + null + } + } + val writer: ItemWriter = ItemWriter { } + + // when + val job = + batch { + job(jobName) { + step(stepName) { + chunk(3) { + transactionManager(ResourcelessTransactionManager()) + reader(reader) + writer(writer) + 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(readCallCount).isEqualTo(1) + assertThat(beforeStepCallCount).isEqualTo(1) + assertThat(afterStepCallCount).isEqualTo(1) + assertThat(beforeChunkCallCount).isEqualTo(1) + assertThat(afterChunkCallCount).isEqualTo(1) + } + + @Test + fun testFaultTolerantChunkOrientedStepWithVariantItemComponentTypes() { + // 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() + var readCallCount = 0 + var skipInProcessCallCount = 0 + val writtenItems = mutableListOf() + val reader: ItemReader = + ItemReader { + if (readCallCount < 6) { + readCallCount++ + } else { + null + } + } + val processor: ItemProcessor = + ItemProcessor { item -> + val value = item.toInt() + if (value == 2) { + throw IllegalArgumentException("skipped") + } + value * 10 + } + val writer: ItemWriter = + ItemWriter { chunk -> + writtenItems.addAll(chunk.items) + } + val skipListener = + object : SkipListener { + override fun onSkipInProcess( + item: Any, + t: Throwable, + ) { + ++skipInProcessCallCount + } + } + + // when + val job = + batch { + job(jobName) { + step(stepName) { + chunk(3) { + transactionManager(ResourcelessTransactionManager()) + reader(reader) + processor(processor) + writer(writer) + faultTolerant() + skip() + skipLimit(1L) + skipListener(skipListener) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(readCallCount).isEqualTo(6) + assertThat(skipInProcessCallCount).isEqualTo(1) + assertThat(writtenItems).containsExactly(0, 10, 30, 40, 50) + } + + @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/ChunkOrientedStepBuilderDsl.kt b/spring-batch-plus-kotlin/src/main/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDsl.kt index 9c9b9700..38be4c89 100644 --- 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 @@ -44,7 +44,7 @@ import kotlin.reflect.KClass * * 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. + * the outer [com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl] before `chunk()` is called. * Method order matches the upstream source. * * @since 2.0.0 @@ -60,7 +60,7 @@ class ChunkOrientedStepBuilderDsl internal constructor( /** * Set for [ChunkOrientedStepBuilder.reader][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.reader]. */ - fun reader(reader: ItemReader) { + fun reader(reader: ItemReader) { this.lazyConfigurer.add { it.reader(reader) } @@ -69,7 +69,7 @@ class ChunkOrientedStepBuilderDsl internal constructor( /** * Set for [ChunkOrientedStepBuilder.processor][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.processor]. */ - fun processor(processor: ItemProcessor) { + fun processor(processor: ItemProcessor) { this.lazyConfigurer.add { it.processor(processor) } @@ -78,7 +78,7 @@ class ChunkOrientedStepBuilderDsl internal constructor( /** * Set for [ChunkOrientedStepBuilder.writer][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.writer]. */ - fun writer(writer: ItemWriter) { + fun writer(writer: ItemWriter) { this.lazyConfigurer.add { it.writer(writer) } @@ -219,7 +219,7 @@ class ChunkOrientedStepBuilderDsl internal constructor( /** * Set for [ChunkOrientedStepBuilder.skipListener][org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder.skipListener]. */ - fun skipListener(skipListener: SkipListener) { + fun skipListener(skipListener: SkipListener) { this.lazyConfigurer.add { it.skipListener(skipListener) } 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 index c2c6f02a..15ef5856 100644 --- 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 @@ -41,7 +41,11 @@ import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.interceptor.TransactionAttribute import java.util.concurrent.ThreadLocalRandom +/** + * Unit tests for ChunkOrientedStepBuilderDsl's delegation to Spring Batch's ChunkOrientedStepBuilder. + */ internal class ChunkOrientedStepBuilderDslTest { + @Test fun testReader() { // given diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/README.md new file mode 100644 index 00000000..92300e9d --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/README.md @@ -0,0 +1,6 @@ +# Chunk-Oriented Step Config Samples + +## Invariants + +- Every non-fault-tolerant chunk-oriented step configuration capability 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/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 deleted file mode 100644 index 656d1d64..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/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.config.annotationlistener.mixed - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -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.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 - -@Configuration -open class TestJobConfig( - private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, -) { - class TestListener { - @AfterRead - fun afterRead(item: Any) { - println("afterRead (item: $item)") - } - - @AfterProcess - fun afterProcess( - item: Any, - result: Any?, - ) { - println("afterProcess: $item, result: $result") - } - - @BeforeWrite - fun beforeWrite(chunk: Chunk) { - println("beforeWrite: ${chunk.items}") - } - } - - @Bean - open fun testJob(): Job = - batch { - job("testJob") { - step("testStep") { - chunk(3) { - transactionManager(transactionManager) - reader(testItemReader()) - processor(testItemProcessor()) - writer(testItemWriter()) - listener(TestListener()) - } - } - } - } - - @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("[${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/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 deleted file mode 100644 index 59ed0532..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/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.annotationlistener.writerlistener - -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/executor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/SampleApplicationTest.kt index 2ed65678..a36cdb9d 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/interruptionpolicy/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.executor +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.interruptionpolicy 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/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt new file mode 100644 index 00000000..6f93ddb8 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/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.chunkorientedstep.config.interruptionpolicy + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.ThreadStepInterruptionPolicy +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 + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, +) { + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3) { + reader(testItemReader()) + writer(testItemWriter()) + interruptionPolicy(ThreadStepInterruptionPolicy()) + } + } + } + } + + @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("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/listener/annotation/chunklistener/SampleApplicationTest.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/SampleApplicationTest.kt index c1530d9b..fa714156 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/listener/annotation/chunklistener/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.readerlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.chunklistener 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/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/listener/annotation/chunklistener/TestJobConfig.kt similarity index 92% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/TestJobConfig.kt index 55887c27..681458e8 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/listener/annotation/chunklistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.chunklistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.chunklistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.annotation.AfterChunk @@ -29,13 +29,12 @@ 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, ) { + class TestListener { @BeforeChunk fun beforeChunk(chunk: Chunk) { @@ -58,7 +57,6 @@ open class TestJobConfig( job("testJob") { step("testStep") { 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/listener/annotation/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/SampleApplicationTest.kt new file mode 100644 index 00000000..e97b55a6 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/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.chunkorientedstep.config.listener.annotation.processorlistener + +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/annotationlistener/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/TestJobConfig.kt similarity index 92% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/TestJobConfig.kt index 68d1d908..e7c80513 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/listener/annotation/processorlistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.processorlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.processorlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.annotation.AfterProcess @@ -28,13 +28,12 @@ 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, ) { + class TestListener { @BeforeProcess fun beforeProcess(item: Any) { @@ -64,7 +63,6 @@ open class TestJobConfig( job("testJob") { step("testStep") { 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/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/SampleApplicationTest.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/chunklistener/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/SampleApplicationTest.kt index 5b424c45..dda8befe 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/listener/annotation/readerlistener/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.chunklistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.readerlistener 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/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/listener/annotation/readerlistener/TestJobConfig.kt similarity index 92% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/readerlistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/TestJobConfig.kt index 3adc0bb0..35c94ca8 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/listener/annotation/readerlistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.readerlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.readerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.annotation.AfterRead @@ -28,13 +28,12 @@ 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, ) { + class TestListener { @BeforeRead fun beforeRead() { @@ -58,7 +57,6 @@ open class TestJobConfig( job("testJob") { step("testStep") { 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/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt new file mode 100644 index 00000000..dce75646 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/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.chunkorientedstep.config.listener.annotation.stepexecutionlistener + +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/listener/annotation/stepexecutionlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt new file mode 100644 index 00000000..9d6c44c7 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt @@ -0,0 +1,90 @@ +/* + * 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.listener.annotation.stepexecutionlistener + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.ExitStatus +import org.springframework.batch.core.annotation.AfterStep +import org.springframework.batch.core.annotation.BeforeStep +import org.springframework.batch.core.job.Job +import org.springframework.batch.core.step.StepExecution +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 + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, +) { + + class TestListener { + @BeforeStep + fun beforeStep(stepExecution: StepExecution) { + println("beforeStep: $stepExecution") + } + + @AfterStep + fun afterStep(stepExecution: StepExecution): ExitStatus? { + println("afterStep: $stepExecution") + return null + } + } + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener(TestListener()) + } + } + } + } + + @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/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/listener/annotation/writerlistener/SampleApplicationTest.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/mixed/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/SampleApplicationTest.kt index 443f764a..7956be29 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/listener/annotation/writerlistener/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.mixed +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.writerlistener 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/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/listener/annotation/writerlistener/TestJobConfig.kt similarity index 92% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/writerlistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/TestJobConfig.kt index 90c6a2f6..3e4fa4db 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/listener/annotation/writerlistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.writerlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.annotation.writerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.annotation.AfterWrite @@ -29,13 +29,12 @@ 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, ) { + class TestListener { @BeforeWrite fun beforeWrite(chunk: Chunk) { @@ -62,7 +61,6 @@ open class TestJobConfig( job("testJob") { step("testStep") { 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/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/SampleApplicationTest.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/annotationlistener/processorlistener/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/SampleApplicationTest.kt index 1148cb8d..c8684648 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/listener/steplistener/chunklistener/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.annotationlistener.processorlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.steplistener.chunklistener 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/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/listener/steplistener/chunklistener/TestJobConfig.kt similarity index 93% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/TestJobConfig.kt index 68b9481f..01c22f6f 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/listener/steplistener/chunklistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.chunklistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.steplistener.chunklistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -27,20 +27,18 @@ 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(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/listener/steplistener/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/SampleApplicationTest.kt new file mode 100644 index 00000000..9de799d5 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/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.chunkorientedstep.config.listener.steplistener.processorlistener + +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/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/TestJobConfig.kt similarity index 93% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/TestJobConfig.kt index 12d110f3..029d15f5 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/listener/steplistener/processorlistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.processorlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.steplistener.processorlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -26,20 +26,18 @@ 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(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/listener/steplistener/readerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/SampleApplicationTest.kt new file mode 100644 index 00000000..cfdef570 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/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.chunkorientedstep.config.listener.steplistener.readerlistener + +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/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/TestJobConfig.kt similarity index 92% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/TestJobConfig.kt index 134b3603..d60d9024 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/listener/steplistener/readerlistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.readerlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.steplistener.readerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -26,20 +26,18 @@ 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(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/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt new file mode 100644 index 00000000..c4797b1e --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/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.chunkorientedstep.config.listener.steplistener.stepexecutionlistener + +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/listener/steplistener/stepexecutionlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt new file mode 100644 index 00000000..865a53d9 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt @@ -0,0 +1,87 @@ +/* + * 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.listener.steplistener.stepexecutionlistener + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.ExitStatus +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.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 + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, +) { + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3) { + reader(testItemReader()) + processor(testItemProcessor()) + writer(testItemWriter()) + listener( + object : StepExecutionListener { + override fun beforeStep(stepExecution: StepExecution) { + println("beforeStep: $stepExecution") + } + + override fun afterStep(stepExecution: StepExecution): ExitStatus? { + println("afterStep: $stepExecution") + return null + } + }, + ) + } + } + } + } + + @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/config/listener/steplistener/writerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/SampleApplicationTest.kt new file mode 100644 index 00000000..f7c5c3ca --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/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.chunkorientedstep.config.listener.steplistener.writerlistener + +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/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/TestJobConfig.kt similarity index 93% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/TestJobConfig.kt index ac169cbd..d56f2955 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/listener/steplistener/writerlistener/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.writerlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.listener.steplistener.writerlistener import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -27,20 +27,18 @@ 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(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/observationregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/SampleApplicationTest.kt new file mode 100644 index 00000000..a7af033c --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/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.chunkorientedstep.config.observationregistry + +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/observationregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/TestJobConfig.kt new file mode 100644 index 00000000..5e711669 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/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.chunkorientedstep.config.observationregistry + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import io.micrometer.observation.ObservationRegistry +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 + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, +) { + + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step("testStep") { + chunk(3) { + reader(testItemReader()) + writer(testItemWriter()) + observationRegistry(ObservationRegistry.create()) + } + } + } + } + + @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("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 deleted file mode 100644 index c8f43780..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/readerlistener/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.readerlistener - -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/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 292ea2cd..2e14d646 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 @@ -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/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 4288a820..1479c6c6 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 @@ -27,20 +27,18 @@ 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 @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(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/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/chunklistener/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/SampleApplicationTest.kt index 18a811bc..ed7c087e 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/taskexecutor/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.chunklistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.taskexecutor 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/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/taskexecutor/TestJobConfig.kt similarity index 91% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/executor/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/TestJobConfig.kt index 975a3ecf..4f918946 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/taskexecutor/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.executor +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.taskexecutor import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -26,13 +26,12 @@ 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.transaction.PlatformTransactionManager @Configuration open class TestJobConfig( private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun customExecutor(): AsyncTaskExecutor = SimpleAsyncTaskExecutor() @@ -42,7 +41,6 @@ open class TestJobConfig( job("testJob") { step("testStep") { 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/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 0763f2ec..b1049ab3 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 @@ -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/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 2a72aff2..e1f3393e 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 @@ -24,22 +24,20 @@ 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 import org.springframework.transaction.interceptor.DefaultTransactionAttribute import org.springframework.transaction.support.TransactionSynchronizationManager @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(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/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/processorlistener/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/SampleApplicationTest.kt index 7ce736ca..5944347e 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/transactionmanager/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.processorlistener +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.config.transactionmanager 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/chunkorientedstep/config/transactionmanager/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/TestJobConfig.kt new file mode 100644 index 00000000..78a05502 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/TestJobConfig.kt @@ -0,0 +1,67 @@ +/* + * 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.transactionmanager + +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(transactionManager) + reader(testItemReader()) + writer(testItemWriter()) + } + } + } + } + + @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("write $items") + } +} 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 deleted file mode 100644 index fc3f63ac..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/writerlistener/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.writerlistener - -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/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/README.md new file mode 100644 index 00000000..0b20a3a8 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/README.md @@ -0,0 +1,6 @@ +# Chunk-Oriented Step Creation Samples + +## Invariants + +- Every non-deprecated chunk-oriented step creation capability 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/chunkorientedstep/chunksize/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/SampleApplicationTest.kt similarity index 98% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/SampleApplicationTest.kt index aafa99e8..c5e241e2 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/creation/chunksize/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunksize +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.creation.chunksize 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/chunkorientedstep/chunksize/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/TestJobConfig.kt similarity index 91% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/chunksize/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/TestJobConfig.kt index 1b7d8031..d085a503 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/creation/chunksize/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.chunksize +package com.navercorp.spring.batch.plus.sample.step.chunkorientedstep.creation.chunksize import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -25,20 +25,18 @@ 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(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/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/README.md new file mode 100644 index 00000000..c1fdb962 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/faulttolerant/README.md @@ -0,0 +1,6 @@ +# Fault-Tolerant Chunk-Oriented Step Samples + +## Invariants + +- Every retry and skip capability exposed by the Kotlin DSL for + chunk-oriented steps 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/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 e157549c..1cb29456 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 @@ -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/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 1281de50..982ecc53 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 @@ -25,20 +25,18 @@ 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(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/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 9ee88a45..6d89b8d7 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 @@ -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/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 5ed7999b..c9d027a4 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 @@ -30,20 +30,18 @@ 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 open class TestJobConfig( private val batch: BatchDsl, - private val transactionManager: PlatformTransactionManager, ) { + @Bean open fun testJob(): Job = batch { job("testJob") { step("testStep") { 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/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 daa1842e..e2ffc350 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 @@ -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/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 6b456af5..127ee8e0 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 @@ -26,20 +26,18 @@ import org.springframework.batch.infrastructure.item.ItemWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.retry.RetryPolicy -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(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/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 7482a2ff..c2b38fed 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 @@ -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/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 fa2da1df..590ed765 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 @@ -25,20 +25,18 @@ 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(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/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 3cecc75c..d9db36e2 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 @@ -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/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 e6340d93..35c6d5bc 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 @@ -26,20 +26,18 @@ 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(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/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 96541bd8..767b6a3c 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 @@ -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/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 3f05b048..6bfa5214 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 @@ -28,13 +28,12 @@ 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, ) { + class TestListener { @OnSkipInRead fun onSkipInRead(t: Throwable) { @@ -64,10 +63,11 @@ open class TestJobConfig( job("testJob") { step("testStep") { chunk(3) { - transactionManager(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) + // TODO: Keep this pending until annotation-based skip callbacks are observable + // through ChunkOrientedStepBuilder.listener(Object). listener(TestListener()) faultTolerant() skip() 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 4c77d9a4..fb79acd6 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 @@ -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/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 d20743a7..d1437d21 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 @@ -26,20 +26,18 @@ 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(transactionManager) reader(testItemReader()) processor(testItemProcessor()) writer(testItemWriter()) From cbfa78d2ed381f22a4986cf12e9ea036e6254d4f Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 8 Jul 2026 11:15:12 +0900 Subject: [PATCH 47/69] Polish Kotlin formatting Signed-off-by: Taeik Lim --- .../kotlin/spring.batch.plus.kotlin-conventions.gradle.kts | 1 - .../kotlin/configuration/StepBuilderDslIntegrationTest.kt | 1 - .../step/ChunkOrientedStepBuilderDslIntegrationTest.kt | 2 -- .../configuration/step/FlowStepBuilderDslIntegrationTest.kt | 2 -- .../configuration/step/JobStepBuilderDslIntegrationTest.kt | 2 -- .../step/PartitionStepBuilderDslIntegrationTest.kt | 3 --- .../step/TaskletStepBuilderDslIntegrationTest.kt | 6 +----- .../configuration/step/ChunkOrientedStepBuilderDslTest.kt | 1 - .../kotlin/configuration/step/FlowStepBuilderDslTest.kt | 1 - .../plus/kotlin/configuration/step/JobStepBuilderDslTest.kt | 1 - .../configuration/step/PartitionStepBuilderDslTest.kt | 1 - .../kotlin/configuration/step/SimpleStepBuilderDslTest.kt | 5 +---- .../kotlin/configuration/step/TaskletStepBuilderDslTest.kt | 4 ---- .../config/interruptionpolicy/SampleApplicationTest.kt | 1 - .../config/interruptionpolicy/TestJobConfig.kt | 1 - .../annotation/chunklistener/SampleApplicationTest.kt | 1 - .../listener/annotation/chunklistener/TestJobConfig.kt | 1 - .../annotation/processorlistener/SampleApplicationTest.kt | 1 - .../listener/annotation/processorlistener/TestJobConfig.kt | 1 - .../annotation/readerlistener/SampleApplicationTest.kt | 1 - .../listener/annotation/readerlistener/TestJobConfig.kt | 1 - .../stepexecutionlistener/SampleApplicationTest.kt | 1 - .../annotation/stepexecutionlistener/TestJobConfig.kt | 1 - .../annotation/writerlistener/SampleApplicationTest.kt | 1 - .../listener/annotation/writerlistener/TestJobConfig.kt | 1 - .../steplistener/chunklistener/SampleApplicationTest.kt | 1 - .../listener/steplistener/chunklistener/TestJobConfig.kt | 1 - .../steplistener/processorlistener/SampleApplicationTest.kt | 1 - .../steplistener/processorlistener/TestJobConfig.kt | 1 - .../steplistener/readerlistener/SampleApplicationTest.kt | 1 - .../listener/steplistener/readerlistener/TestJobConfig.kt | 1 - .../stepexecutionlistener/SampleApplicationTest.kt | 1 - .../steplistener/stepexecutionlistener/TestJobConfig.kt | 1 - .../steplistener/writerlistener/SampleApplicationTest.kt | 1 - .../listener/steplistener/writerlistener/TestJobConfig.kt | 1 - .../config/observationregistry/SampleApplicationTest.kt | 1 - .../config/observationregistry/TestJobConfig.kt | 1 - .../config/stream/SampleApplicationTest.kt | 1 - .../step/chunkorientedstep/config/stream/TestJobConfig.kt | 1 - .../config/taskexecutor/SampleApplicationTest.kt | 1 - .../chunkorientedstep/config/taskexecutor/TestJobConfig.kt | 1 - .../config/transactionattribute/SampleApplicationTest.kt | 1 - .../config/transactionattribute/TestJobConfig.kt | 1 - .../config/transactionmanager/SampleApplicationTest.kt | 1 - .../config/transactionmanager/TestJobConfig.kt | 1 - .../creation/chunksize/SampleApplicationTest.kt | 1 - .../chunkorientedstep/creation/chunksize/TestJobConfig.kt | 1 - .../faulttolerant/retry/SampleApplicationTest.kt | 1 - .../chunkorientedstep/faulttolerant/retry/TestJobConfig.kt | 1 - .../faulttolerant/retrylistener/SampleApplicationTest.kt | 1 - .../faulttolerant/retrylistener/TestJobConfig.kt | 1 - .../faulttolerant/retrypolicy/SampleApplicationTest.kt | 1 - .../faulttolerant/retrypolicy/TestJobConfig.kt | 1 - .../faulttolerant/skip/SampleApplicationTest.kt | 1 - .../chunkorientedstep/faulttolerant/skip/TestJobConfig.kt | 1 - .../faulttolerant/skiplistener/SampleApplicationTest.kt | 1 - .../faulttolerant/skiplistener/TestJobConfig.kt | 1 - .../skiplistenerannotation/SampleApplicationTest.kt | 1 - .../faulttolerant/skiplistenerannotation/TestJobConfig.kt | 1 - .../faulttolerant/skippolicy/SampleApplicationTest.kt | 1 - .../faulttolerant/skippolicy/TestJobConfig.kt | 1 - .../step/flowstep/creation/bean/SampleApplicationTest.kt | 1 - .../sample/step/flowstep/creation/bean/TestJobConfig.kt | 1 - .../step/flowstep/creation/init/SampleApplicationTest.kt | 1 - .../sample/step/flowstep/creation/init/TestJobConfig.kt | 1 - .../flowstep/creation/variable/SampleApplicationTest.kt | 1 - .../sample/step/flowstep/creation/variable/TestJobConfig.kt | 1 - .../step/jobstep/config/extractor/SampleApplicationTest.kt | 1 - .../sample/step/jobstep/config/extractor/TestJobConfig.kt | 1 - .../step/jobstep/config/operator/SampleApplicationTest.kt | 1 - .../sample/step/jobstep/config/operator/TestJobConfig.kt | 1 - .../step/jobstep/creation/bean/SampleApplicationTest.kt | 1 - .../plus/sample/step/jobstep/creation/bean/TestJobConfig.kt | 1 - .../step/jobstep/creation/variable/SampleApplicationTest.kt | 1 - .../sample/step/jobstep/creation/variable/TestJobConfig.kt | 1 - .../config/aggregator/SampleApplicationTest.kt | 1 - .../step/partitionstep/config/aggregator/TestJobConfig.kt | 1 - .../config/splitter/builtin/SampleApplicationTest.kt | 1 - .../partitionstep/config/splitter/builtin/TestJobConfig.kt | 1 - .../config/splitter/direct/SampleApplicationTest.kt | 1 - .../partitionstep/config/splitter/direct/TestJobConfig.kt | 4 +--- .../creation/builtinhandler/SampleApplicationTest.kt | 1 - .../partitionstep/creation/builtinhandler/TestJobConfig.kt | 1 - .../creation/directhandler/SampleApplicationTest.kt | 1 - .../partitionstep/creation/directhandler/TestJobConfig.kt | 1 - .../config/exceptionhandler/SampleApplicationTest.kt | 1 - .../taskletstep/config/exceptionhandler/TestJobConfig.kt | 1 - .../taskletstep/config/executor/SampleApplicationTest.kt | 1 - .../step/taskletstep/config/executor/TestJobConfig.kt | 1 - .../config/listenerannotation/SampleApplicationTest.kt | 1 - .../taskletstep/config/listenerannotation/TestJobConfig.kt | 1 - .../config/listenerobject/SampleApplicationTest.kt | 1 - .../step/taskletstep/config/listenerobject/TestJobConfig.kt | 1 - .../config/stepoperation/SampleApplicationTest.kt | 1 - .../step/taskletstep/config/stepoperation/TestJobConfig.kt | 1 - .../step/taskletstep/config/stream/SampleApplicationTest.kt | 1 - .../sample/step/taskletstep/config/stream/TestJobConfig.kt | 1 - .../config/transactionattribute/SampleApplicationTest.kt | 1 - .../config/transactionattribute/TestJobConfig.kt | 1 - .../config/transactionmanager/SampleApplicationTest.kt | 1 - .../taskletstep/config/transactionmanager/TestJobConfig.kt | 1 - .../beandefaulttransactionmanager/SampleApplicationTest.kt | 1 - .../creation/beandefaulttransactionmanager/TestJobConfig.kt | 1 - .../beanwithtransactionmanager/SampleApplicationTest.kt | 1 - .../creation/beanwithtransactionmanager/TestJobConfig.kt | 1 - .../SampleApplicationTest.kt | 1 - .../variabledefaulttransactionmanager/TestJobConfig.kt | 1 - .../variablewithtransactionmanager/SampleApplicationTest.kt | 1 - .../variablewithtransactionmanager/TestJobConfig.kt | 1 - 109 files changed, 3 insertions(+), 126 deletions(-) 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 f268b59a..9fe8fe14 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 @@ -11,7 +11,6 @@ plugins { id("org.jlleitschuh.gradle.ktlint") } - /* kotlin */ kotlin { 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 072e0a1d..e29e25dc 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,7 +40,6 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource internal class StepBuilderDslIntegrationTest { - @Test fun testChunkWithCount() { // given diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt index b66d8388..04e54599 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt @@ -52,7 +52,6 @@ import javax.sql.DataSource * Integration tests for creating and executing chunk-oriented steps through the public Kotlin DSL. */ internal class ChunkOrientedStepBuilderDslIntegrationTest { - @Test fun testChunkOrientedStep() { // given @@ -243,7 +242,6 @@ internal class ChunkOrientedStepBuilderDslIntegrationTest { 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/FlowStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt index 701fcf31..f54a5b45 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 @@ -45,7 +45,6 @@ import javax.sql.DataSource * Integration tests for creating and executing flow steps through the public Kotlin DSL. */ internal class FlowStepBuilderDslIntegrationTest { - @Test fun testFlowBean() { // given @@ -199,7 +198,6 @@ 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 ba40ae95..caa7aef9 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 @@ -45,7 +45,6 @@ import javax.sql.DataSource * Integration tests for creating and executing job steps through the public Kotlin DSL. */ internal class JobStepBuilderDslIntegrationTest { - @Test fun testJobBean() { // given @@ -217,7 +216,6 @@ 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 index 1fff09ea..a25c0ee6 100644 --- 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 @@ -51,7 +51,6 @@ import javax.sql.DataSource * Integration tests for creating and executing partition steps through the public Kotlin DSL. */ internal class PartitionStepBuilderDslIntegrationTest { - @Test fun testPartitionHandlerWithDirectOne() { // given @@ -154,7 +153,6 @@ internal class PartitionStepBuilderDslIntegrationTest { @Nested inner class RedundancyCheck { - @Test fun testPartitionHandlerAndRedundantSettings() { // given @@ -290,7 +288,6 @@ internal class PartitionStepBuilderDslIntegrationTest { 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/TaskletStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt index e78b4980..8cc09c93 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 @@ -62,7 +62,6 @@ import javax.sql.DataSource * Integration tests for creating and executing tasklet steps through the public Kotlin DSL. */ internal class TaskletStepBuilderDslIntegrationTest { - @Test fun testTaskletBean() { // given @@ -278,7 +277,6 @@ internal class TaskletStepBuilderDslIntegrationTest { @Nested inner class RedundancyCheck { - @Suppress("DEPRECATION") @Test fun testStepOperationsIgnoreTaskExecutorAndExceptionHandler() { @@ -299,8 +297,7 @@ internal class TaskletStepBuilderDslIntegrationTest { return super.iterate(callback) } }, - ) - .taskExecutor { task -> + ).taskExecutor { task -> ++taskExecutorCallCount task.run() }.exceptionHandler { _, e -> @@ -327,7 +324,6 @@ 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/ChunkOrientedStepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslTest.kt index 15ef5856..87240491 100644 --- 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 @@ -45,7 +45,6 @@ import java.util.concurrent.ThreadLocalRandom * Unit tests for ChunkOrientedStepBuilderDsl's delegation to Spring Batch's ChunkOrientedStepBuilder. */ internal class ChunkOrientedStepBuilderDslTest { - @Test fun testReader() { // given 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 b23f0266..68f32571 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 @@ -29,7 +29,6 @@ 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-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 76711b8b..04cac525 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 @@ -32,7 +32,6 @@ 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-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 6bfc186d..f1c0bedf 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 @@ -39,7 +39,6 @@ import java.util.concurrent.ThreadLocalRandom * Unit tests for PartitionStepBuilderDsl's delegation and DSL-owned preconditions. */ internal class PartitionStepBuilderDslTest { - @Test fun testPartitionHandler() { // given 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 b700de9c..bed5c4ae 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 @@ -59,7 +59,6 @@ import java.util.concurrent.ThreadLocalRandom * Tests for deprecated SimpleStepBuilderDsl, including its legacy execution-backed redundancy check. */ internal class SimpleStepBuilderDslTest { - @Test fun testReader() { // given @@ -336,7 +335,6 @@ internal class SimpleStepBuilderDslTest { @Nested inner class RedundancyCheck { - @Test fun testStepOperationsIgnoreTaskExecutorAndExceptionHandler() { // given @@ -367,8 +365,7 @@ internal class SimpleStepBuilderDslTest { return super.iterate(callback) } }, - ) - .taskExecutor { task -> + ).taskExecutor { task -> ++taskExecutorCallCount task.run() }.exceptionHandler { _, e -> 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 d7f0db21..eced8a0b 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 @@ -24,14 +24,12 @@ import io.mockk.verify 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.job.parameters.JobParameters import org.springframework.batch.core.listener.ChunkListener 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.RepeatOperations import org.springframework.batch.infrastructure.repeat.exception.ExceptionHandler -import org.springframework.batch.infrastructure.repeat.support.RepeatTemplate import org.springframework.core.task.TaskExecutor import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.interceptor.TransactionAttribute @@ -40,7 +38,6 @@ import org.springframework.transaction.interceptor.TransactionAttribute * Unit tests for TaskletStepBuilderDsl's delegation to Spring Batch's TaskletStepBuilder. */ internal class TaskletStepBuilderDslTest { - @Test fun testChunkListener() { // given @@ -222,5 +219,4 @@ internal class TaskletStepBuilderDslTest { }.build() }.hasMessageContaining("exceptionHandler is redundant") } - } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/SampleApplicationTest.kt index a36cdb9d..c6c7da1f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt index 6f93ddb8..4c6c2b40 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/interruptionpolicy/TestJobConfig.kt @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/listener/annotation/chunklistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/SampleApplicationTest.kt index fa714156..8db9f06d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/annotation/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/TestJobConfig.kt index 681458e8..fb276281 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/chunklistener/TestJobConfig.kt @@ -34,7 +34,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - class TestListener { @BeforeChunk fun beforeChunk(chunk: Chunk) { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/SampleApplicationTest.kt index e97b55a6..a917d1dd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/annotation/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/TestJobConfig.kt index e7c80513..b2461e5f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/processorlistener/TestJobConfig.kt @@ -33,7 +33,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - class TestListener { @BeforeProcess fun beforeProcess(item: Any) { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/SampleApplicationTest.kt index dda8befe..6109dfb5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/annotation/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/TestJobConfig.kt index 35c94ca8..9af0854e 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/readerlistener/TestJobConfig.kt @@ -33,7 +33,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - class TestListener { @BeforeRead fun beforeRead() { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt index dce75646..5aae517c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt index 9d6c44c7..f92ed283 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/stepexecutionlistener/TestJobConfig.kt @@ -34,7 +34,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - class TestListener { @BeforeStep fun beforeStep(stepExecution: StepExecution) { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/SampleApplicationTest.kt index 7956be29..57bc8772 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/annotation/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/TestJobConfig.kt index 3e4fa4db..8bf9af25 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/annotation/writerlistener/TestJobConfig.kt @@ -34,7 +34,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - class TestListener { @BeforeWrite fun beforeWrite(chunk: Chunk) { diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/SampleApplicationTest.kt index c8684648..999e467a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/steplistener/chunklistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/TestJobConfig.kt index 01c22f6f..56c7ed43 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/chunklistener/TestJobConfig.kt @@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/listener/steplistener/processorlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/SampleApplicationTest.kt index 9de799d5..b7ded639 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/steplistener/processorlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/TestJobConfig.kt index 029d15f5..ce4657da 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/processorlistener/TestJobConfig.kt @@ -31,7 +31,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/listener/steplistener/readerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/SampleApplicationTest.kt index cfdef570..8884258b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/steplistener/readerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/TestJobConfig.kt index d60d9024..24af41ed 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/readerlistener/TestJobConfig.kt @@ -31,7 +31,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt index c4797b1e..cdaf1294 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt index 865a53d9..61767d4b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/stepexecutionlistener/TestJobConfig.kt @@ -33,7 +33,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/listener/steplistener/writerlistener/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/SampleApplicationTest.kt index f7c5c3ca..d6b4cbfe 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/listener/steplistener/writerlistener/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/TestJobConfig.kt index d56f2955..674aacf4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/listener/steplistener/writerlistener/TestJobConfig.kt @@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/observationregistry/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/SampleApplicationTest.kt index a7af033c..d2f1a3d6 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/observationregistry/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/TestJobConfig.kt index 5e711669..6445eb9b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/observationregistry/TestJobConfig.kt @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 2e14d646..292ea2cd 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 @@ -29,7 +29,6 @@ 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/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 1479c6c6..6be7cea2 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 @@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/taskexecutor/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/SampleApplicationTest.kt index ed7c087e..5bd40715 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/taskexecutor/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/TestJobConfig.kt index 4f918946..c1d8d459 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/taskexecutor/TestJobConfig.kt @@ -31,7 +31,6 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor open class TestJobConfig( private val batch: BatchDsl, ) { - @Bean open fun customExecutor(): AsyncTaskExecutor = SimpleAsyncTaskExecutor() 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 b1049ab3..0763f2ec 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 @@ -29,7 +29,6 @@ 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/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 e1f3393e..673428e5 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 @@ -31,7 +31,6 @@ import org.springframework.transaction.support.TransactionSynchronizationManager open class TestJobConfig( private val batch: BatchDsl, ) { - @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/chunkorientedstep/config/transactionmanager/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/SampleApplicationTest.kt index 5944347e..4d9ae987 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/config/transactionmanager/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/TestJobConfig.kt index 78a05502..3d0002dd 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/config/transactionmanager/TestJobConfig.kt @@ -31,7 +31,6 @@ 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/chunkorientedstep/creation/chunksize/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/SampleApplicationTest.kt index c5e241e2..7460247f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/SampleApplicationTest.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/SampleApplicationTest.kt @@ -29,7 +29,6 @@ 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/chunkorientedstep/creation/chunksize/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/TestJobConfig.kt index d085a503..6e810720 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/TestJobConfig.kt +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/chunkorientedstep/creation/chunksize/TestJobConfig.kt @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 1cb29456..e157549c 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 @@ -29,7 +29,6 @@ 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/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 982ecc53..a62367cc 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 @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 6d89b8d7..9ee88a45 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 @@ -29,7 +29,6 @@ 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/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 c9d027a4..b04cadb1 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 @@ -35,7 +35,6 @@ import org.springframework.core.retry.Retryable open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 e2ffc350..daa1842e 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 @@ -29,7 +29,6 @@ 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/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 127ee8e0..dd0e9d5a 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 @@ -31,7 +31,6 @@ import org.springframework.core.retry.RetryPolicy open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 c2b38fed..7482a2ff 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 @@ -29,7 +29,6 @@ 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/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 590ed765..7cc2e91b 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 @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 d9db36e2..3cecc75c 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 @@ -29,7 +29,6 @@ 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/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 35c6d5bc..14ae3cfe 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 @@ -31,7 +31,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 767b6a3c..96541bd8 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 @@ -29,7 +29,6 @@ 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/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 6bfa5214..ffebf4af 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 @@ -33,7 +33,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - class TestListener { @OnSkipInRead fun onSkipInRead(t: Throwable) { 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 fb79acd6..4c77d9a4 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 @@ -29,7 +29,6 @@ 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/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 d1437d21..353e946a 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 @@ -31,7 +31,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/creation/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 index ebf1e895..8744fe4d 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/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 @@ -29,7 +29,6 @@ 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/creation/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 index 3030c21e..442f6abb 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/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 @@ -31,7 +31,6 @@ 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/creation/init/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 index 5a80abd9..8d584edc 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/init/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 @@ -29,7 +29,6 @@ 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/creation/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 index 2d04d2e3..55ba6c1b 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/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 @@ -30,7 +30,6 @@ 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/creation/variable/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 index 840ad3f3..8ba26d59 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/variable/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 @@ -29,7 +29,6 @@ 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/creation/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 index 3b2d2d37..2c244549 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/flowstep/creation/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 @@ -31,7 +31,6 @@ 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/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 962cf496..781db97e 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,7 +29,6 @@ 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 dce102f3..c60714f1 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,7 +31,6 @@ 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/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 cfb28ac6..670d85b0 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,7 +29,6 @@ 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 5415068e..c4996f8f 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,7 +34,6 @@ 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/creation/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 index 291a4eb0..9ea311a4 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/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 @@ -29,7 +29,6 @@ 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/creation/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 index 018ae82f..7f35e46c 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/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 @@ -30,7 +30,6 @@ 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/creation/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 index 19432be0..7e33a188 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/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 @@ -29,7 +29,6 @@ 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/creation/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 index 8016b883..76f4968f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/jobstep/creation/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 @@ -30,7 +30,6 @@ 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/partitionstep/config/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 index e9f742ee..78696396 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/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 @@ -29,7 +29,6 @@ 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/config/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 index efaae672..6ac98e59 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/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 @@ -34,7 +34,6 @@ 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/partitionstep/config/splitter/builtin/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 index 7b2d1833..ebdef6a1 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/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 @@ -29,7 +29,6 @@ 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/config/splitter/builtin/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 index 8fdd12ed..a05c4b12 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/splitter/builtin/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 @@ -33,7 +33,6 @@ 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/partitionstep/config/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 index 9b387a3c..13a8ee1a 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/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 @@ -29,7 +29,6 @@ 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/config/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 index ec180f78..88303ded 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/config/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 @@ -36,7 +36,6 @@ open class TestJobConfig( private val jobRepository: JobRepository, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun testJob(): Job = batch { @@ -63,8 +62,7 @@ open class TestJobConfig( "$stepName:partition-$it", jobExecution, ) - } - .toSet() + }.toSet() } }, ) 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 index 6351719f..5f0f0a8c 100644 --- 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 @@ -29,7 +29,6 @@ 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/creation/builtinhandler/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 index 0f3e4769..943c978f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/builtinhandler/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 @@ -33,7 +33,6 @@ 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/partitionstep/creation/directhandler/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 index e1f50fc9..d765ba71 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/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 @@ -29,7 +29,6 @@ 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/creation/directhandler/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 index 6b2ac17d..9f7de924 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/partitionstep/creation/directhandler/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 @@ -34,7 +34,6 @@ 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/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 c88d3f55..aef0d190 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,7 +29,6 @@ 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 5d60f122..44d26a8d 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,7 +30,6 @@ 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 4339a7ee..366bf6ee 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,7 +29,6 @@ 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 c94b6f4a..e75bf97b 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,7 +33,6 @@ 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/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 8f2b0ec0..f590f68c 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 @@ -29,7 +29,6 @@ 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 index 7ae688c2..84119774 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 @@ -35,7 +35,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - class TestListener { @BeforeStep fun beforeStep() { 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 546ee1fe..3699538a 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,7 +29,6 @@ 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 24b33860..4fef2ec0 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,7 +33,6 @@ 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 99cd342d..1ebe8947 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,7 +29,6 @@ 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 eb854aba..7e2528d4 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,7 +34,6 @@ 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 39e3499d..fa40b7af 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,7 +29,6 @@ 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 d8055b82..d7e1e31c 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,7 +33,6 @@ 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 27cbca46..4b6d5064 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,7 +29,6 @@ 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 256a17d8..d0553fcb 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,7 +33,6 @@ 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 index 5eb79a29..9f15a113 100644 --- 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 @@ -29,7 +29,6 @@ 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/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 index cf96423c..39f47f74 100644 --- 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 @@ -31,7 +31,6 @@ 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/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 index eb51ee86..d430cf2b 100644 --- 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 @@ -29,7 +29,6 @@ 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/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 index 6e03a2e4..30e325c6 100644 --- 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 @@ -31,7 +31,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/beanwithtransactionmanager/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 index 1356df99..fec722c5 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/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 @@ -29,7 +29,6 @@ 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/creation/beanwithtransactionmanager/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 index eb99fdac..00f8b44f 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/beanwithtransactionmanager/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 @@ -33,7 +33,6 @@ 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 index 204326f6..6e140db7 100644 --- 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 @@ -29,7 +29,6 @@ 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/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 index 9867a710..efc2f687 100644 --- 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 @@ -29,7 +29,6 @@ import org.springframework.context.annotation.Configuration open class TestJobConfig( private val batch: BatchDsl, ) { - @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/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 index 06b875d7..10a3d8e4 100644 --- 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 @@ -29,7 +29,6 @@ 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/creation/variablewithtransactionmanager/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 index a1f17de1..57b7aec2 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/taskletstep/creation/variablewithtransactionmanager/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 @@ -31,7 +31,6 @@ open class TestJobConfig( private val batch: BatchDsl, private val transactionManager: PlatformTransactionManager, ) { - @Bean open fun testJob(): Job = batch { From 467c18d780488218fe527b1e255a3793a0e5b71d Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 12 Jul 2026 16:30:37 +0900 Subject: [PATCH 48/69] Polish stepBuilderDsl tests, samples Signed-off-by: Taeik Lim --- .../SimpleStepBuilderDslIntegrationTest.kt} | 76 +++++-------------- .../step/ChunkOrientedStepBuilderDsl.kt | 7 +- .../configuration/step/FlowStepBuilderDsl.kt | 3 + .../configuration/step/JobStepBuilderDsl.kt | 3 + .../step/PartitionStepBuilderDsl.kt | 7 +- .../step/SimpleStepBuilderDsl.kt | 3 + .../step/TaskletStepBuilderDsl.kt | 3 + ...DslHelperTest.kt => StepBuilderDslTest.kt} | 5 +- .../plus/sample/step/configuration/README.md | 6 ++ .../batch/plus/sample/step/creation/README.md | 6 ++ 10 files changed, 53 insertions(+), 66 deletions(-) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{StepBuilderDslIntegrationTest.kt => step/SimpleStepBuilderDslIntegrationTest.kt} (70%) rename spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{StepBuilderDslHelperTest.kt => StepBuilderDslTest.kt} (95%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/README.md 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/step/SimpleStepBuilderDslIntegrationTest.kt similarity index 70% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslIntegrationTest.kt index e29e25dc..d84c3159 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/step/SimpleStepBuilderDslIntegrationTest.kt @@ -16,15 +16,16 @@ * 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 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.policy.SimpleCompletionPolicy import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -37,15 +38,22 @@ 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 -internal class StepBuilderDslIntegrationTest { +/** + * Integration tests for deprecated simple chunk step entry points on the public Kotlin DSL. + */ +@Suppress("DEPRECATION") +internal class SimpleStepBuilderDslIntegrationTest { @Test fun testChunkWithCount() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() + val jobName = UUID.randomUUID().toString() + val stepName = UUID.randomUUID().toString() val readLimit = 20 val chunkSize = 3 var readCallCount = 0 @@ -54,8 +62,8 @@ internal class StepBuilderDslIntegrationTest { // when val job = batch { - job("testJob") { - step("testStep") { + job(jobName) { + step(stepName) { chunk(chunkSize, ResourcelessTransactionManager()) { reader { if (readCallCount < readLimit) { @@ -72,7 +80,7 @@ internal class StepBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -84,8 +92,10 @@ internal class StepBuilderDslIntegrationTest { fun testChunkWithCompletionPolicy() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() + val jobName = UUID.randomUUID().toString() + val stepName = UUID.randomUUID().toString() val readLimit = 20 val chunkSize = 3 var readCallCount = 0 @@ -94,8 +104,8 @@ internal class StepBuilderDslIntegrationTest { // when val job = batch { - job("testJob") { - step("testStep") { + job(jobName) { + step(stepName) { chunk(SimpleCompletionPolicy(chunkSize), ResourcelessTransactionManager()) { reader { if (readCallCount < readLimit) { @@ -112,51 +122,7 @@ internal class StepBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(readCallCount).isEqualTo(readLimit) - assertThat(writeCallCount).isEqualTo(7) // Ceil(20/3) - } - - @Test - fun testChunkOriented() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - val readLimit = 20 - val chunkSize = 3 - var readCallCount = 0 - var writeCallCount = 0 - - // when - val job = - batch { - job("testJob") { - step("testStep") { - chunk(chunkSize) { - transactionManager(ResourcelessTransactionManager()) - reader { - if (readCallCount < readLimit) { - ++readCallCount - 1 - } else { - null - } - } - writer { - ++writeCallCount - } - faultTolerant() - skip() - skipLimit(1L) - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) 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 index 38be4c89..ff3791a9 100644 --- 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 @@ -42,10 +42,9 @@ 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. + * Common step settings stay on + * [StepBuilderDsl][com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl]. + * [observationRegistry] stays here because `ChunkOrientedStepBuilder` redefines it. * * @since 2.0.0 */ 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 1d7b2876..ab673793 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 @@ -27,6 +27,9 @@ import org.springframework.batch.core.step.builder.FlowStepBuilder /** * A dsl for [FlowStepBuilder][org.springframework.batch.core.step.builder.FlowStepBuilder]. * + * Common step settings stay on + * [StepBuilderDsl][com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl]. + * * @since 0.1.0 */ @BatchDslMarker 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 9a73a7a6..11e531b5 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 @@ -29,6 +29,9 @@ import org.springframework.batch.core.step.job.JobParametersExtractor /** * A dsl for [JobStepBuilder][org.springframework.batch.core.step.builder.JobStepBuilder]. * + * Common step settings stay on + * [StepBuilderDsl][com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl]. + * * @since 0.1.0 */ @BatchDslMarker 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 95bfe782..53927b12 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,11 +33,8 @@ 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. + * Common step settings stay on + * [StepBuilderDsl][com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl]. * * @since 0.1.0 */ 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 35ad2865..707a1880 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 @@ -51,6 +51,9 @@ import kotlin.reflect.KClass /** * A dsl for [SimpleStepBuilder][org.springframework.batch.core.step.builder.SimpleStepBuilder]. * + * Common step settings stay on + * [StepBuilderDsl][com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl]. + * * @since 0.1.0 */ @BatchDslMarker 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 6eb85eca..bd51aa6f 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 @@ -34,6 +34,9 @@ import org.springframework.transaction.interceptor.TransactionAttribute /** * A dsl for [TaskletStepBuilder][org.springframework.batch.core.step.builder.TaskletStepBuilder]. * + * Common step settings stay on + * [StepBuilderDsl][com.navercorp.spring.batch.plus.kotlin.configuration.StepBuilderDsl]. + * * @since 0.1.0 */ @BatchDslMarker 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/StepBuilderDslTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslHelperTest.kt rename to spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslTest.kt index a3812784..4452841b 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/StepBuilderDslTest.kt @@ -29,9 +29,10 @@ import org.springframework.transaction.PlatformTransactionManager import java.util.concurrent.ThreadLocalRandom /** - * org.springframework.batch.core.step.builder.StepBuilderHelper related tests + * Unit tests for StepBuilderDsl's delegation of common step settings. + * Step creation entry points belong in step-specific tests, not here. */ -internal class StepBuilderDslHelperTest { +internal class StepBuilderDslTest { @Test fun testObservationRegistry() { // given diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/README.md new file mode 100644 index 00000000..30e6bb4d --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/configuration/README.md @@ -0,0 +1,6 @@ +# Step Config Samples + +## Invariants + +- Every common step configuration option exposed by `StepBuilderDsl` 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/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/README.md new file mode 100644 index 00000000..076d952a --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/step/creation/README.md @@ -0,0 +1,6 @@ +# Step Creation Samples + +## Invariants + +- Generic step creation examples from the Kotlin DSL step guide should have a + runnable sample in this package. From a8b75792a7c9086015dfa4dfae15cf4a5292372e Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 12 Jul 2026 16:54:50 +0900 Subject: [PATCH 49/69] Polish jobBuilderDsl tests, samples Signed-off-by: Taeik Lim --- .../kotlin/configuration/JobBuilderDsl.kt | 4 ++-- ...rDslHelperTest.kt => JobBuilderDslTest.kt} | 23 +++---------------- .../plus/sample/job/configuration/README.md | 6 +++++ .../batch/plus/sample/job/creation/README.md | 6 +++++ 4 files changed, 17 insertions(+), 22 deletions(-) rename spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{JobBuilderDslHelperTest.kt => JobBuilderDslTest.kt} (87%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md 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 5fdfa391..012bbc81 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 @@ -45,9 +45,9 @@ class JobBuilderDsl internal constructor( private val dslContext: DslContext, private val jobBuilder: JobBuilder, ) : FlowBuilderDsl { - private var lazyConfigurer = LazyConfigurer>() + private val lazyConfigurer = LazyConfigurer>() - private var lazyFlowConfigurer = LazyConfigurer>() + private val lazyFlowConfigurer = LazyConfigurer>() private var isFlowJob = false 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/JobBuilderDslTest.kt similarity index 87% rename from spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslHelperTest.kt rename to spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslTest.kt index 73bfe84d..b184a998 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/JobBuilderDslTest.kt @@ -31,9 +31,10 @@ import org.springframework.batch.core.listener.JobExecutionListener import java.util.UUID /** - * org.springframework.batch.core.job.builder.JobBuilderHelper related tests + * Unit tests for JobBuilderDsl's delegation of common job settings. + * Job creation entry points belong in job-specific tests, not here. */ -internal class JobBuilderDslHelperTest { +internal class JobBuilderDslTest { @Test fun testValidator() { // given @@ -137,24 +138,6 @@ internal class JobBuilderDslHelperTest { verify(exactly = 1) { jobBuilder.preventRestart() } } - @Test - fun testConfigurationAfterStep() { - // given - val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) - val jobBuilderDsl = jobBuilderDsl(jobBuilder) - - // when - val jobParametersValidator = mockk() - jobBuilderDsl - .apply { - step(mockk()) - validator(jobParametersValidator) - }.build() - - // then - verify(exactly = 1) { jobBuilder.validator(jobParametersValidator) } - } - private fun jobBuilderDsl(jobBuilder: JobBuilder): JobBuilderDsl { val dslContext = DslContext( diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/README.md new file mode 100644 index 00000000..1dff564c --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/configuration/README.md @@ -0,0 +1,6 @@ +# Job Config Samples + +## Invariants + +- Every common job configuration option exposed by `JobBuilderDsl` 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/job/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md new file mode 100644 index 00000000..35336d43 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md @@ -0,0 +1,6 @@ +# Job Creation Samples + +## Invariants + +- Generic job creation examples from the Kotlin DSL job guide should have a + runnable sample in this package. From 5f026281a47138a41c9c9fae96f635dff380c38a Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 12 Jul 2026 17:55:33 +0900 Subject: [PATCH 50/69] Document job and flow DSL boundaries Signed-off-by: Taeik Lim --- .../batch/plus/kotlin/configuration/ConcreteFlowBuilderDsl.kt | 3 ++- .../plus/kotlin/configuration/DeciderTransitionBuilderDsl.kt | 3 ++- .../spring/batch/plus/kotlin/configuration/FlowBuilderDsl.kt | 3 ++- .../batch/plus/kotlin/configuration/FlowJobBuilderDsl.kt | 3 ++- .../plus/kotlin/configuration/FlowTransitionBuilderDsl.kt | 3 ++- .../spring/batch/plus/kotlin/configuration/JobBuilderDsl.kt | 4 +++- .../batch/plus/kotlin/configuration/SimpleJobBuilderDsl.kt | 4 +++- .../plus/kotlin/configuration/SimpleJobBuilderDslAdapter.kt | 4 +++- .../spring/batch/plus/kotlin/configuration/SplitBuilderDsl.kt | 2 +- .../plus/kotlin/configuration/StepTransitionBuilderDsl.kt | 3 ++- .../batch/plus/kotlin/configuration/TransitionBuilderDsl.kt | 3 ++- .../kotlin/configuration/SimpleJobBuilderDslAdapterTest.kt | 3 +++ 12 files changed, 27 insertions(+), 11 deletions(-) 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 e9489c9e..cd454acb 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 @@ -29,7 +29,8 @@ import org.springframework.beans.factory.getBean import org.springframework.core.task.TaskExecutor /** - * A concrete implementation for [FlowBuilder][org.springframework.batch.core.job.builder.FlowBuilder]. + * Shared entry implementation for top-level, nested, split, and job flow declarations. + * Source-specific transition blocks are delegated so repeated `on` clauses branch from the same source. */ @BatchDslMarker internal class ConcreteFlowBuilderDsl internal constructor( 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 211351ad..08ee61bd 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 @@ -24,7 +24,8 @@ import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.JobExecutionDecider /** - * A dsl for decider transition. + * Collects transition clauses that start from a single decider state. + * The first clause continues from the incoming builder; additional clauses branch from the same decider. * * @since 0.1.0 */ 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 aa7f7899..8fb722f9 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 @@ -26,7 +26,8 @@ import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor /** - * A dsl for [FlowBuilder][org.springframework.batch.core.job.builder.FlowBuilder]. + * Declaration surface for flow-like builder targets. + * [T] is the type produced by the underlying Spring Batch [FlowBuilder]. * * @since 0.1.0 */ 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 30ee4cfe..294e73b2 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 @@ -24,7 +24,8 @@ import org.springframework.batch.core.job.Job import org.springframework.batch.core.job.builder.FlowJobBuilder /** - * A dsl for [FlowJobBuilder][org.springframework.batch.core.job.builder.FlowJobBuilder]. + * Builds jobs that require Spring Batch's flow-job path. + * The actual flow declaration operations are delegated to [ConcreteFlowBuilderDsl]. */ @BatchDslMarker internal class FlowJobBuilderDsl internal constructor( 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 1df4c780..4480ef5d 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 @@ -24,7 +24,8 @@ import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.job.flow.Flow /** - * A dsl for flow transition. + * Collects transition clauses that start from a single flow. + * The first clause continues from the incoming builder; additional clauses branch from the same flow. * * @since 0.1.0 */ 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 012bbc81..d24a1a5c 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 @@ -36,7 +36,9 @@ import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor /** - * A dsl for [JobBuilder][org.springframework.batch.core.job.builder.JobBuilder]. + * Entry DSL for a job block. + * Common job settings are applied to the parent [JobBuilder] before the block is + * replayed into either the simple-job or flow-job builder path. * * @since 0.1.0 */ 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 181c2ff7..adb55a71 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 @@ -27,7 +27,9 @@ import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.getBean /** - * A dsl for [SimpleJobBuilder][org.springframework.batch.core.job.builder.SimpleJobBuilder]. + * Builds sequential jobs whose declarations are limited to plain step entries. + * Flow and transition declarations are selected by [JobBuilderDsl] before this + * builder is used. */ @BatchDslMarker internal class SimpleJobBuilderDsl internal constructor( 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 95d45413..fd985abe 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 @@ -27,7 +27,9 @@ import org.springframework.batch.core.step.Step import org.springframework.core.task.TaskExecutor /** - * A dsl for [SimpleJobBuilder][org.springframework.batch.core.job.builder.SimpleJobBuilder]. + * Adapts the simple-job builder to the shared flow declaration replay path. + * Calls that require a flow job fail fast because a simple job can only replay + * plain step declarations. */ @BatchDslMarker internal class SimpleJobBuilderDslAdapter internal constructor( 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 dd5c0791..a2758996 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 @@ -25,7 +25,7 @@ import org.springframework.batch.core.job.flow.Flow import org.springframework.beans.factory.getBean /** - * A dsl for [FlowBuilder.SplitBuilder][org.springframework.batch.core.job.builder.FlowBuilder.SplitBuilder]. + * Collects flows for a split state before adding them to the underlying [FlowBuilder.SplitBuilder]. * * @since 0.1.0 */ 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 7a7ad921..187a857d 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 @@ -24,7 +24,8 @@ import org.springframework.batch.core.job.builder.FlowBuilder import org.springframework.batch.core.step.Step /** - * A dsl for step transition. + * Collects transition clauses that start from a single step. + * The first clause continues from the incoming builder; additional clauses branch from the same step. * * @since 0.1.0 */ 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 6dfdc4f7..417abbb8 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 @@ -28,7 +28,8 @@ import org.springframework.batch.core.step.builder.StepBuilder import org.springframework.beans.factory.getBean /** - * A dsl for [FlowBuilder.TransitionBuilder][org.springframework.batch.core.job.builder.FlowBuilder.TransitionBuilder]. + * Target DSL for a single transition pattern. + * A target step, flow, decider, or terminal action must be selected before build. * * @since 0.1.0 */ 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 4bed7b22..382f607f 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 @@ -27,6 +27,9 @@ import org.springframework.batch.core.step.Step import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager +/** + * Unit tests for SimpleJobBuilderDslAdapter's fail-fast boundary. + */ internal class SimpleJobBuilderDslAdapterTest { @Test fun testUnsupportedCall() { From 2f2cbf923211eafadb102cf453d028ba4c4af793 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 12 Jul 2026 19:04:40 +0900 Subject: [PATCH 51/69] Split transition DSL integration tests --- ...iderTransitionBuilderDslIntegrationTest.kt | 9 +- .../FlowJobBuilderDslIntegrationTest.kt | 61 +- ...FlowTransitionBuilderDslIntegrationTest.kt | 9 +- .../SimpleJobBuilderDslIntegrationTest.kt | 17 +- .../SplitBuilderDslIntegrationTest.kt | 17 +- ...tandaloneFlowBuilderDslIntegrationTest.kt} | 75 +- ...StepTransitionBuilderDslIntegrationTest.kt | 9 +- .../TransitionBuilderDslIntegrationTest.kt | 1985 ----------------- ...BuilderDslStopAndRestartIntegrationTest.kt | 935 ++++++++ ...uilderDslTargetSelectionIntegrationTest.kt | 1086 +++++++++ 10 files changed, 2130 insertions(+), 2073 deletions(-) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ConcreteFlowBuilderDslIntegrationTest.kt => StandaloneFlowBuilderDslIntegrationTest.kt} (94%) delete mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslStopAndRestartIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslTargetSelectionIntegrationTest.kt 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 e1aa1a66..34377713 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 @@ -29,7 +29,7 @@ import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepo 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean @@ -42,12 +42,15 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager import javax.sql.DataSource +/** + * Integration coverage for repeated transition clauses branching from the same decider source. + */ internal class DeciderTransitionBuilderDslIntegrationTest { @RepeatedTest(10) fun testDeciderWithMultipleTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() val expectedFlowExecutionStatus = randomFlowExecutionStatus() var testDeciderCallCount = 0 @@ -71,7 +74,7 @@ internal class DeciderTransitionBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(testDeciderCallCount).isEqualTo(1) 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 19031545..f5b3d8c8 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 @@ -27,7 +27,7 @@ import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepo 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -44,12 +44,15 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor import org.springframework.transaction.TransactionManager import javax.sql.DataSource +/** + * Integration coverage for job declarations that require Spring Batch's flow-job path. + */ internal class FlowJobBuilderDslIntegrationTest { @Test fun testStepBeanWithTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -123,7 +126,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -138,7 +141,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testStepWithInitAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -202,7 +205,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -217,7 +220,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testStepWithVariableAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -283,7 +286,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -298,7 +301,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testFlowBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -347,7 +350,7 @@ internal class FlowJobBuilderDslIntegrationTest { flowBean("testFlow2") } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -360,7 +363,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testFlowWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -393,7 +396,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -406,7 +409,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testFlowWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -447,7 +450,7 @@ internal class FlowJobBuilderDslIntegrationTest { flow(testFlow2) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -460,7 +463,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testFlowBeanWithTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -539,7 +542,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -554,7 +557,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testFlowWithInitAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -622,7 +625,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -637,7 +640,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testFlowWithVariableAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -707,7 +710,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -722,7 +725,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testDeciderBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 val testDecider = @@ -745,7 +748,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -757,7 +760,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testDeciderBeanNotFirst() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 @@ -790,7 +793,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -803,7 +806,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testDeciderWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 val decider = @@ -823,7 +826,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -835,7 +838,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testDeciderWithVariableNotFirst() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 @@ -865,7 +868,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -878,7 +881,7 @@ internal class FlowJobBuilderDslIntegrationTest { fun testSplit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var taskExecutorCallCount = 0 var testStep1CallCount = 0 @@ -924,7 +927,7 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) 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 f78e33fa..5642458a 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 @@ -27,7 +27,7 @@ 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -42,12 +42,15 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager import javax.sql.DataSource +/** + * Integration coverage for repeated transition clauses branching from the same flow source. + */ internal class FlowTransitionBuilderDslIntegrationTest { @RepeatedTest(10) fun testFlowWithMultipleTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() val expectedExitStatus = randomExitStatus() var testStep1CallCount = 0 @@ -81,7 +84,7 @@ internal class FlowTransitionBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(testStep1CallCount).isEqualTo(1) 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 f9fae3d2..524eef04 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 @@ -24,7 +24,7 @@ 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -40,13 +40,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager import javax.sql.DataSource +/** + * Integration coverage for sequential jobs built from plain step declarations. + */ internal class SimpleJobBuilderDslIntegrationTest { @Test fun testStepBean() { // given AnnotationConfigApplicationContext() val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -92,7 +95,7 @@ internal class SimpleJobBuilderDslIntegrationTest { stepBean("testStep2") } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -104,7 +107,7 @@ internal class SimpleJobBuilderDslIntegrationTest { fun testStepWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -133,7 +136,7 @@ internal class SimpleJobBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -145,7 +148,7 @@ internal class SimpleJobBuilderDslIntegrationTest { fun testStepWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -182,7 +185,7 @@ internal class SimpleJobBuilderDslIntegrationTest { step(testStep2) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) 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 1ae1bbdf..038d9f57 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 @@ -26,7 +26,7 @@ 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -43,12 +43,15 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor import org.springframework.transaction.TransactionManager import javax.sql.DataSource +/** + * Integration coverage for split declarations that attach multiple flows to one split state. + */ internal class SplitBuilderDslIntegrationTest { @Test fun testFlowBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() val callerThread = Thread.currentThread().name var taskExecutorCallCount = 0 @@ -110,7 +113,7 @@ internal class SplitBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -124,7 +127,7 @@ internal class SplitBuilderDslIntegrationTest { fun testFlowWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var taskExecutorCallCount = 0 var testStep1CallCount = 0 @@ -170,7 +173,7 @@ internal class SplitBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -184,7 +187,7 @@ internal class SplitBuilderDslIntegrationTest { fun testFlowWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() val callerThread = Thread.currentThread().name var taskExecutorCallCount = 0 @@ -238,7 +241,7 @@ internal class SplitBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) 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/StandaloneFlowBuilderDslIntegrationTest.kt similarity index 94% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/ConcreteFlowBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StandaloneFlowBuilderDslIntegrationTest.kt index cf3dc7e7..32a14e34 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/StandaloneFlowBuilderDslIntegrationTest.kt @@ -27,7 +27,7 @@ import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepo 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -44,12 +44,15 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor import org.springframework.transaction.TransactionManager import javax.sql.DataSource -internal class ConcreteFlowBuilderDslIntegrationTest { +/** + * Integration coverage for top-level flow declarations that build reusable flow instances. + */ +internal class StandaloneFlowBuilderDslIntegrationTest { @Test fun testStepBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -100,7 +103,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -113,7 +116,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testStepWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -148,7 +151,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -161,7 +164,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testStepWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -204,7 +207,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -217,7 +220,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testStepBeanWithTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -297,7 +300,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -312,7 +315,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testStepWithInitAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -382,7 +385,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -397,7 +400,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testStepWithVariableAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -469,7 +472,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -484,7 +487,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testFlowBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -539,7 +542,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -552,7 +555,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testFlowWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -591,7 +594,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -604,7 +607,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testFlowWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testStep2CallCount = 0 @@ -651,7 +654,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -664,7 +667,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testFlowBeanWithTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -748,7 +751,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -763,7 +766,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testFlowWithInitAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -837,7 +840,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -852,7 +855,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testFlowWithVariableAndTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var transitionStep1CallCount = 0 @@ -928,7 +931,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -943,7 +946,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testDeciderBean() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 val testDecider = @@ -972,7 +975,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -984,7 +987,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testDeciderBeanNotFirst() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 @@ -1023,7 +1026,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -1036,7 +1039,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testDeciderWithVariable() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testDeciderCallCount = 0 val decider = @@ -1062,7 +1065,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -1074,7 +1077,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testDeciderWithVariableNotFirst() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 var testDeciderCallCount = 0 @@ -1110,7 +1113,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) @@ -1123,7 +1126,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { fun testSplit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() var taskExecutorCallCount = 0 var testStep1CallCount = 0 @@ -1175,7 +1178,7 @@ internal class ConcreteFlowBuilderDslIntegrationTest { flow(testFlow) } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) 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 b3d5145b..48ff8a4c 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 @@ -27,7 +27,7 @@ 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.launch.JobOperator import org.springframework.batch.core.repository.JobRepository import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager @@ -42,12 +42,15 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType import org.springframework.transaction.TransactionManager import javax.sql.DataSource +/** + * Integration coverage for repeated transition clauses branching from the same step source. + */ internal class StepTransitionBuilderDslIntegrationTest { @RepeatedTest(10) fun testStepWithMultipleTransition() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() + val jobOperator = context.getBean() val batch = context.getBean() val expectedExitStatus = randomExitStatus() var testStep1CallCount = 0 @@ -79,7 +82,7 @@ internal class StepTransitionBuilderDslIntegrationTest { } } } - val jobExecution = jobLauncher.run(job, JobParameters()) + val jobExecution = jobOperator.start(job, JobParameters()) // then assertThat(testStep1CallCount).isEqualTo(1) 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 deleted file mode 100644 index 56da0b79..00000000 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslIntegrationTest.kt +++ /dev/null @@ -1,1985 +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.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.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 -import org.springframework.batch.core.launch.JobLauncher -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 - -/** - * Separated from FlowJobBuilderDslIntegrationTest since it's too big. - */ -internal class TransitionBuilderDslIntegrationTest { - @Test - fun testTransitionToStepBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepVariableWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("transitionFlow") { - transitionFlow - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flowBean("transitionFlow") - } - } - } - } - 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow(transitionFlow) - } - } - } - } - 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - 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 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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(), - ) - } - }, - ) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() - } - } - } - } - } - } - 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowWithVariableAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow(transitionFlow) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() - } - } - } - } - } - } - 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(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToDeciderBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - 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 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(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToDeciderVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - 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 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(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStop() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stop() - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("transitionFlow") { - transitionFlow - } - - // when - 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()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - 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()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowVariableWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - 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()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToDeciderBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - 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(), - ) - } - } - on("*") { - fail() - } - } - } - } - } - } - val firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(2) // always run on restart - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToDeciderVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - var transitionStepCallCount = 0 - 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(), - ) - } - } - on("*") { - fail() - } - } - } - } - } - } - val firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(2) // always run on restart - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.NOOP.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepVariableWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobLauncher.run(job, JobParameters()) - val secondJobExecution = jobLauncher.run(job, JobParameters()) - val thirdJobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(thirdJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(thirdJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToEnd() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - 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(), - ) - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("UNKNOWN") { - end() - } - } - } - } - 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) - } - - @Test - fun testTransitionToEndWithStatus() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - 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(), - ) - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("UNKNOWN") { - end("TEST") - } - on("*") { - end() - } - } - } - } - 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) - } - - @Test - fun testTransitionToFail() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobLauncher = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - fail() - } - } - } - } - val jobExecution = jobLauncher.run(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.FAILED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.FAILED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - } - - @Test - fun testNoTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - } - } - } - } - }.hasMessageContaining("should set transition") - } - - @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/TransitionBuilderDslStopAndRestartIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslStopAndRestartIntegrationTest.kt new file mode 100644 index 00000000..2837ca08 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslStopAndRestartIntegrationTest.kt @@ -0,0 +1,935 @@ +/* + * 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.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 +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 coverage for stop-and-restart transitions declared inside an `on` clause. + */ +internal class TransitionBuilderDslStopAndRestartIntegrationTest { + @Test + fun testTransitionToStopAndRestartToFlowBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("transitionFlow") { + transitionFlow + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlowBean("transitionFlow") + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToFlowWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToFlowVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow(transitionFlow) + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToFlowBeanWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToFlowWithInitAndTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToFlowVariableWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow(transitionFlow) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } + } + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToDeciderBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + 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(), + ) + } + } + on("*") { + fail() + } + } + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToDeciderVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + var transitionStepCallCount = 0 + 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(), + ) + } + } + on("*") { + fail() + } + } + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToStepBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToStepWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToStepVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToStepBeanWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToStepWithInitAndTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStopAndRestartToStepVariableWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).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/TransitionBuilderDslTargetSelectionIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslTargetSelectionIntegrationTest.kt new file mode 100644 index 00000000..321474e5 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslTargetSelectionIntegrationTest.kt @@ -0,0 +1,1086 @@ +/* + * 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.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.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 +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 coverage for transition target selection inside an `on` clause. + */ +internal class TransitionBuilderDslTargetSelectionIntegrationTest { + @Test + fun testTransitionToStepBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStepWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStepVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStepBeanWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStepWithInitAndTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStepVariableWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFlowBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("transitionFlow") { + transitionFlow + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flowBean("transitionFlow") + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFlowWithInit() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFlowVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow(transitionFlow) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFlowBeanWithTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFlowWithInitAndTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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(), + ) + } + }, + ) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFlowWithVariableAndTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow(transitionFlow) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToDeciderBean() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToDeciderVariable() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + } + + @Test + fun testTransitionToStop() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stop() + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + } + + @Test + fun testTransitionToEnd() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + } + + @Test + fun testTransitionToEndWithStatus() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + } + + @Test + fun testTransitionToFail() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + fail() + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.FAILED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.FAILED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + } + + @Test + fun testNoTransition() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + + // when, then + assertThatThrownBy { + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + } + } + } + } + }.hasMessageContaining("should set transition") + } + + @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() + } +} From da7f385444b327240d1a241bc5085ffd178fc418 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 13 Jul 2026 10:44:41 +0900 Subject: [PATCH 52/69] Cover taskletBean transaction manager paths --- .../TaskletStepBuilderDslIntegrationTest.kt | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) 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 8cc09c93..25050115 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 @@ -142,6 +142,86 @@ internal class TaskletStepBuilderDslIntegrationTest { assertThat(streamCloseCallCount).isEqualTo(1) } + @Test + fun testTaskletBeanWithTransactionManager() { + // 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", ResourcelessTransactionManager()) + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(taskletCallCount).isEqualTo(1) + } + + @Test + fun testTaskletBeanWithTransactionManagerAndInit() { + // 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", ResourcelessTransactionManager()) { + 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 From 82ebb289e57e8cf595b92f65007a79a2a20ee446 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 18:52:41 +0900 Subject: [PATCH 53/69] Polish Kotlin job DSL integration tests Signed-off-by: Taeik Lim --- ...StandaloneFlowBuilderDslIntegrationTest.kt | 1219 ----------------- ...BuilderDslStopAndRestartIntegrationTest.kt | 935 ------------- ...uilderDslTargetSelectionIntegrationTest.kt | 1086 --------------- ...uilderDslDeciderCreationIntegrationTest.kt | 235 ++++ ...iderTransitionBuilderDslIntegrationTest.kt | 10 +- ...bBuilderDslFlowCreationIntegrationTest.kt} | 495 +------ ...FlowTransitionBuilderDslIntegrationTest.kt | 10 +- ...bBuilderDslSplitCreationIntegrationTest.kt | 101 ++ .../SplitBuilderDslIntegrationTest.kt | 13 +- ...obBuilderDslStepCreationIntegrationTest.kt | 444 ++++++ ...nkOrientedStepBuilderDslIntegrationTest.kt | 10 +- .../FlowStepBuilderDslIntegrationTest.kt | 10 +- .../JobStepBuilderDslIntegrationTest.kt | 12 +- .../PartitionStepBuilderDslIntegrationTest.kt | 12 +- .../SimpleStepBuilderDslIntegrationTest.kt | 8 +- .../TaskletStepBuilderDslIntegrationTest.kt | 20 +- ...StepTransitionBuilderDslIntegrationTest.kt | 10 +- .../OnDeciderTargetIntegrationTest.kt | 194 +++ .../transition/OnFlowTargetIntegrationTest.kt | 429 ++++++ .../transition/OnStepTargetIntegrationTest.kt | 426 ++++++ .../OnTargetSelectionIntegrationTest.kt | 100 ++ .../OnTerminalActionIntegrationTest.kt} | 135 +- .../StopAndRestartToDeciderIntegrationTest.kt | 214 +++ .../StopAndRestartToFlowIntegrationTest.kt | 444 ++++++ .../StopAndRestartToStepIntegrationTest.kt | 432 ++++++ 25 files changed, 3168 insertions(+), 3836 deletions(-) delete mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StandaloneFlowBuilderDslIntegrationTest.kt delete mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslStopAndRestartIntegrationTest.kt delete mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslTargetSelectionIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/decider/JobBuilderDslDeciderCreationIntegrationTest.kt rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ => job/decider/transition}/DeciderTransitionBuilderDslIntegrationTest.kt (94%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{FlowJobBuilderDslIntegrationTest.kt => job/flow/JobBuilderDslFlowCreationIntegrationTest.kt} (50%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ => job/flow/transition}/FlowTransitionBuilderDslIntegrationTest.kt (94%) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/split/JobBuilderDslSplitCreationIntegrationTest.kt rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ => job/split/builder}/SplitBuilderDslIntegrationTest.kt (95%) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslStepCreationIntegrationTest.kt rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{step => job/step/builder}/ChunkOrientedStepBuilderDslIntegrationTest.kt (95%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{step => job/step/builder}/FlowStepBuilderDslIntegrationTest.kt (95%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{step => job/step/builder}/JobStepBuilderDslIntegrationTest.kt (95%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{step => job/step/builder}/PartitionStepBuilderDslIntegrationTest.kt (95%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{step => job/step/builder}/SimpleStepBuilderDslIntegrationTest.kt (94%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{step => job/step/builder}/TaskletStepBuilderDslIntegrationTest.kt (95%) rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{ => job/step/transition}/StepTransitionBuilderDslIntegrationTest.kt (94%) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnDeciderTargetIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnFlowTargetIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnStepTargetIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnTargetSelectionIntegrationTest.kt rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/{SimpleJobBuilderDslIntegrationTest.kt => job/transition/OnTerminalActionIntegrationTest.kt} (68%) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToDeciderIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToFlowIntegrationTest.kt create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToStepIntegrationTest.kt diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StandaloneFlowBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StandaloneFlowBuilderDslIntegrationTest.kt deleted file mode 100644 index 32a14e34..00000000 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StandaloneFlowBuilderDslIntegrationTest.kt +++ /dev/null @@ -1,1219 +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.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.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 -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.scheduling.concurrent.ThreadPoolTaskExecutor -import org.springframework.transaction.TransactionManager -import javax.sql.DataSource - -/** - * Integration coverage for top-level flow declarations that build reusable flow instances. - */ -internal class StandaloneFlowBuilderDslIntegrationTest { - @Test - fun testStepBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val testStep2 = - batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - context.apply { - registerBean("testStep1") { - testStep1 - } - registerBean("testStep2") { - testStep2 - } - } - - // when - val testFlow = - batch { - flow("testFlow") { - stepBean("testStep1") - stepBean("testStep2") - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testStepWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - - // when - 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 jobExecution = jobOperator.start(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 testStepWithVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - val testStep2 = - batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when - val testFlow = - batch { - flow("testFlow") { - step(testStep1) - step(testStep2) - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testStepBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - 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(), - ) - } - } - context.apply { - registerBean("testStep1") { - testStep1 - } - registerBean("testStep2") { - testStep2 - } - } - - // when - 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(), - ) - } - } - } - stepBean("testStep2") { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testStepWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStep1CallCount = 0 - var transitionStep2CallCount = 0 - var testStep2CallCount = 0 - - // when - val testFlow = - batch { - flow("testFlow") { - 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(), - ) - } - } - } - step( - "testStep2", - { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testStepWithVariableAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - 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 = jobOperator.start(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 jobOperator = 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(), - ) - } - } - } - 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 = jobOperator.start(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 testFlowWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testStep2CallCount = 0 - - // 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 = jobOperator.start(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 jobOperator = 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 job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testFlowBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStep1CallCount = 0 - var transitionStep2CallCount = 0 - var testStep2CallCount = 0 - 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(), - ) - } - } - } - context.apply { - registerBean("testFlow1") { - testFlow1 - } - registerBean("testFlow2") { - testFlow2 - } - } - - // when - 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(), - ) - } - } - } - flowBean("testFlow2") { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testFlowWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStep1CallCount = 0 - var transitionStep2CallCount = 0 - 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(), - ) - } - } - on("FAILED") { - step("transitionStep2") { - tasklet( - { _, _ -> - ++transitionStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - flow( - "testFlow2", - { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - }, - ) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testFlowWithVariableAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStep1CallCount = 0 - var transitionStep2CallCount = 0 - var testStep2CallCount = 0 - 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(), - ) - } - } - } - - // when - 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(), - ) - } - } - } - flow(testFlow2) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(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 testDeciderBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testDeciderCallCount = 0 - val testDecider = - JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } - context.registerBean("testDecider") { - testDecider - } - - // when - val testFlow = - batch { - flow("testFlow") { - deciderBean("testDecider") { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testDeciderBeanNotFirst() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - 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 job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testDeciderWithVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testDeciderCallCount = 0 - val decider = - JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } - - // when - val testFlow = - batch { - flow("testFlow") { - decider(decider) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testDeciderWithVariableNotFirst() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - 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 job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testSplit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var taskExecutorCallCount = 0 - 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() } - - // when - 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(), - ) - } - } - } - } - } - val job = - batch { - job("testJob") { - flow(testFlow) - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(taskExecutorCallCount).isEqualTo(2) - 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/TransitionBuilderDslStopAndRestartIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslStopAndRestartIntegrationTest.kt deleted file mode 100644 index 2837ca08..00000000 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslStopAndRestartIntegrationTest.kt +++ /dev/null @@ -1,935 +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.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.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 -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 coverage for stop-and-restart transitions declared inside an `on` clause. - */ -internal class TransitionBuilderDslStopAndRestartIntegrationTest { - @Test - fun testTransitionToStopAndRestartToFlowBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("transitionFlow") { - transitionFlow - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlowBean("transitionFlow") - } - } - } - } - val firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlow(transitionFlow) - } - } - } - } - val firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToFlowVariableWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stopAndRestartToFlow(transitionFlow) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() - } - } - } - } - } - } - val firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToDeciderBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - 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(), - ) - } - } - on("*") { - fail() - } - } - } - } - } - } - val firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToDeciderVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - var transitionStepCallCount = 0 - 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(), - ) - } - } - on("*") { - fail() - } - } - } - } - } - } - val firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStopAndRestartToStepVariableWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 firstJobExecution = jobOperator.start(job, JobParameters()) - val secondJobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).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/TransitionBuilderDslTargetSelectionIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslTargetSelectionIntegrationTest.kt deleted file mode 100644 index 321474e5..00000000 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/TransitionBuilderDslTargetSelectionIntegrationTest.kt +++ /dev/null @@ -1,1086 +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.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.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 -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 coverage for transition target selection inside an `on` clause. - */ -internal class TransitionBuilderDslTargetSelectionIntegrationTest { - @Test - fun testTransitionToStepBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStepVariableWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - context.registerBean("transitionFlow") { - transitionFlow - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flowBean("transitionFlow") - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowWithInit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow(transitionFlow) - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStepCallCount = 0 - 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(), - ) - } - }, - ) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() - } - } - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFlowWithVariableAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - 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") { - tasklet( - { _, _ -> - ++transitionStepCallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - flow(transitionFlow) { - on("COMPLETED") { - end("TEST") - } - on("*") { - stop() - } - } - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(transitionStepCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToDeciderBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToDeciderVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testTransitionToStop() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - stop() - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.STOPPED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - } - - @Test - fun testTransitionToEnd() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - } - - @Test - fun testTransitionToEndWithStatus() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - } - - @Test - fun testTransitionToFail() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when - val job = - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - fail() - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.FAILED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.FAILED.exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - } - - @Test - fun testNoTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val testStep1 = - batch { - step("testStep1") { - tasklet( - { _, _ -> - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - - // when, then - assertThatThrownBy { - batch { - job("testJob") { - step(testStep1) { - on("COMPLETED") { - } - } - } - } - }.hasMessageContaining("should set transition") - } - - @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/job/decider/JobBuilderDslDeciderCreationIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/decider/JobBuilderDslDeciderCreationIntegrationTest.kt new file mode 100644 index 00000000..26fa027c --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/decider/JobBuilderDslDeciderCreationIntegrationTest.kt @@ -0,0 +1,235 @@ +/* + * 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.job.decider + +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.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 +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 + +/** + * Covers the boundary where introducing a decider selects flow-job construction at any state position. + */ +internal class JobBuilderDslDeciderCreationIntegrationTest { + @Test + fun deciderBeanShouldExecuteAsFirstStateWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testDeciderCallCount = 0 + val testDecider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } + context.registerBean("testDecider") { + testDecider + } + + // when + val job = + batch { + job("testJob") { + deciderBean("testDecider") { + on("COMPLETED") { + end("TEST") + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testDeciderCallCount).isEqualTo(1) + } + + @Test + fun deciderBeanShouldExecuteAfterStepWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + } + + @Test + fun deciderShouldExecuteAsFirstStateWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testDeciderCallCount = 0 + val decider = + JobExecutionDecider { _, _ -> + ++testDeciderCallCount + FlowExecutionStatus.COMPLETED + } + + // when + val job = + batch { + job("testJob") { + decider(decider) { + on("COMPLETED") { + end("TEST") + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testDeciderCallCount).isEqualTo(1) + } + + @Test + fun deciderShouldExecuteAfterStepWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).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/DeciderTransitionBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/decider/transition/DeciderTransitionBuilderDslIntegrationTest.kt similarity index 94% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/DeciderTransitionBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/decider/transition/DeciderTransitionBuilderDslIntegrationTest.kt index 34377713..2504a310 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/job/decider/transition/DeciderTransitionBuilderDslIntegrationTest.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.job.decider.transition +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.RepeatedTest @@ -43,11 +44,11 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration coverage for repeated transition clauses branching from the same decider source. + * Covers source reselection after the first `on` clause. */ internal class DeciderTransitionBuilderDslIntegrationTest { @RepeatedTest(10) - fun testDeciderWithMultipleTransition() { + fun deciderShouldFollowMatchingTransitionWhenMultipleTransitionsAreConfigured() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -98,7 +99,7 @@ internal class DeciderTransitionBuilderDslIntegrationTest { } @Test - fun testStepWithNoTransition() { + fun deciderShouldThrowExceptionWhenTransitionBlockIsEmpty() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() @@ -112,7 +113,6 @@ internal class DeciderTransitionBuilderDslIntegrationTest { batch { job("testJob") { decider(testDecider) { - // no transition } } } 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/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt similarity index 50% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowJobBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt index f5b3d8c8..0eef983d 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/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt @@ -16,16 +16,16 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration +package com.navercorp.spring.batch.plus.kotlin.configuration.job.flow +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.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.flow.FlowJob import org.springframework.batch.core.job.parameters.JobParameters import org.springframework.batch.core.launch.JobOperator import org.springframework.batch.core.repository.JobRepository @@ -40,265 +40,15 @@ 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.scheduling.concurrent.ThreadPoolTaskExecutor import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration coverage for job declarations that require Spring Batch's flow-job path. + * Covers the boundary where introducing a flow selects flow-job construction. */ -internal class FlowJobBuilderDslIntegrationTest { +internal class JobBuilderDslFlowCreationIntegrationTest { @Test - fun testStepBeanWithTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - 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(), - ) - } - } - context.apply { - registerBean("testStep1") { - testStep1 - } - registerBean("testStep2") { - testStep2 - } - } - - // when - 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(), - ) - } - } - } - stepBean("testStep2") { - on("COMPLETED") { - end("TEST") - } - } - } - } - val jobExecution = jobOperator.start(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 testStepWithInitAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var transitionStep1CallCount = 0 - var transitionStep2CallCount = 0 - var testStep2CallCount = 0 - - // when - val job = - batch { - job("testJob") { - 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(), - ) - } - } - } - step( - "testStep2", - { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - }, - ) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val jobExecution = jobOperator.start(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 testStepWithVariableAndTransition() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - 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 job = - batch { - job("testJob") { - 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 jobExecution = jobOperator.start(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() { + fun flowBeanShouldCreateFlowJobWhenFlowBeanNamesAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -353,6 +103,7 @@ internal class FlowJobBuilderDslIntegrationTest { val jobExecution = jobOperator.start(job, JobParameters()) // then + assertThat(job).isInstanceOf(FlowJob::class.java) assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) assertThat(testStep1CallCount).isEqualTo(1) @@ -360,7 +111,7 @@ internal class FlowJobBuilderDslIntegrationTest { } @Test - fun testFlowWithInit() { + fun flowShouldCreateFlowJobWhenFlowsAreDeclaredWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -399,6 +150,7 @@ internal class FlowJobBuilderDslIntegrationTest { val jobExecution = jobOperator.start(job, JobParameters()) // then + assertThat(job).isInstanceOf(FlowJob::class.java) assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) assertThat(testStep1CallCount).isEqualTo(1) @@ -406,7 +158,7 @@ internal class FlowJobBuilderDslIntegrationTest { } @Test - fun testFlowWithVariable() { + fun flowShouldCreateFlowJobWhenFlowInstancesAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -453,6 +205,7 @@ internal class FlowJobBuilderDslIntegrationTest { val jobExecution = jobOperator.start(job, JobParameters()) // then + assertThat(job).isInstanceOf(FlowJob::class.java) assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) assertThat(testStep1CallCount).isEqualTo(1) @@ -460,7 +213,7 @@ internal class FlowJobBuilderDslIntegrationTest { } @Test - fun testFlowBeanWithTransition() { + fun flowBeanShouldCreateFlowJobWhenBeanNameAndTransitionAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -483,7 +236,6 @@ internal class FlowJobBuilderDslIntegrationTest { } } } - val testFlow2 = batch { flow("testFlow2") { @@ -545,6 +297,7 @@ internal class FlowJobBuilderDslIntegrationTest { val jobExecution = jobOperator.start(job, JobParameters()) // then + assertThat(job).isInstanceOf(FlowJob::class.java) assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) assertThat(testStep1CallCount).isEqualTo(1) @@ -554,7 +307,7 @@ internal class FlowJobBuilderDslIntegrationTest { } @Test - fun testFlowWithInitAndTransition() { + fun flowShouldCreateFlowJobWhenInitAndTransitionAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -628,6 +381,7 @@ internal class FlowJobBuilderDslIntegrationTest { val jobExecution = jobOperator.start(job, JobParameters()) // then + assertThat(job).isInstanceOf(FlowJob::class.java) assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) assertThat(testStep1CallCount).isEqualTo(1) @@ -637,7 +391,7 @@ internal class FlowJobBuilderDslIntegrationTest { } @Test - fun testFlowWithVariableAndTransition() { + fun flowShouldCreateFlowJobWhenInstanceAndTransitionAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -713,6 +467,7 @@ internal class FlowJobBuilderDslIntegrationTest { val jobExecution = jobOperator.start(job, JobParameters()) // then + assertThat(job).isInstanceOf(FlowJob::class.java) assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) assertThat(testStep1CallCount).isEqualTo(1) @@ -721,222 +476,6 @@ internal class FlowJobBuilderDslIntegrationTest { assertThat(testStep2CallCount).isEqualTo(1) } - @Test - fun testDeciderBean() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testDeciderCallCount = 0 - val testDecider = - JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } - context.registerBean("testDecider") { - testDecider - } - - // when - val job = - batch { - job("testJob") { - deciderBean("testDecider") { - on("COMPLETED") { - end("TEST") - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testDeciderBeanNotFirst() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testDeciderWithVariable() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testDeciderCallCount = 0 - val decider = - JobExecutionDecider { _, _ -> - ++testDeciderCallCount - FlowExecutionStatus.COMPLETED - } - - // when - val job = - batch { - job("testJob") { - decider(decider) { - on("COMPLETED") { - end("TEST") - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testDeciderWithVariableNotFirst() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var testStep1CallCount = 0 - var testDeciderCallCount = 0 - 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 jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testDeciderCallCount).isEqualTo(1) - } - - @Test - fun testSplit() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - var taskExecutorCallCount = 0 - 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() } - - // when - 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(), - ) - } - } - } - } - } - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) - assertThat(taskExecutorCallCount).isEqualTo(2) - assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) - } - @Configuration @EnableBatchProcessing @EnableJdbcJobRepository( 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/job/flow/transition/FlowTransitionBuilderDslIntegrationTest.kt similarity index 94% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/FlowTransitionBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/flow/transition/FlowTransitionBuilderDslIntegrationTest.kt index 5642458a..b1a5be6b 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/job/flow/transition/FlowTransitionBuilderDslIntegrationTest.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.job.flow.transition +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.RepeatedTest @@ -43,11 +44,11 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration coverage for repeated transition clauses branching from the same flow source. + * Covers source reselection after the first `on` clause. */ internal class FlowTransitionBuilderDslIntegrationTest { @RepeatedTest(10) - fun testFlowWithMultipleTransition() { + fun flowShouldFollowMatchingTransitionWhenMultipleTransitionsAreConfigured() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -102,7 +103,7 @@ internal class FlowTransitionBuilderDslIntegrationTest { } @Test - fun testStepWithNoTransition() { + fun flowShouldThrowExceptionWhenTransitionBlockIsEmpty() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() @@ -125,7 +126,6 @@ internal class FlowTransitionBuilderDslIntegrationTest { batch { job("testJob") { flow(testFlow1) { - // no transition } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/split/JobBuilderDslSplitCreationIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/split/JobBuilderDslSplitCreationIntegrationTest.kt new file mode 100644 index 00000000..35ae258c --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/split/JobBuilderDslSplitCreationIntegrationTest.kt @@ -0,0 +1,101 @@ +/* + * 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.job.split + +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.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.flow.FlowJob +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.core.task.SyncTaskExecutor +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 + +/** + * Covers the boundary where introducing a split selects flow-job construction. + */ +internal class JobBuilderDslSplitCreationIntegrationTest { + @Test + fun splitShouldCreateFlowJobWhenTaskExecutorAndFlowAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + + // when + val job = + batch { + job("testJob") { + split(SyncTaskExecutor()) { + flow("testFlow") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + } + } + + // then + assertThat(job).isInstanceOf(FlowJob::class.java) + } + + @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/SplitBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/split/builder/SplitBuilderDslIntegrationTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SplitBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/split/builder/SplitBuilderDslIntegrationTest.kt index 038d9f57..452ba87e 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/job/split/builder/SplitBuilderDslIntegrationTest.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.job.split.builder +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test @@ -44,11 +45,11 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration coverage for split declarations that attach multiple flows to one split state. + * Covers flow membership and validation inside an already-created split, rather than entry into split construction. */ internal class SplitBuilderDslIntegrationTest { @Test - fun testFlowBean() { + fun flowBeanShouldCreateSplitWhenFlowBeanNamesAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -124,7 +125,7 @@ internal class SplitBuilderDslIntegrationTest { } @Test - fun testFlowWithInit() { + fun flowShouldCreateSplitWhenFlowsAreDeclaredWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -184,7 +185,7 @@ internal class SplitBuilderDslIntegrationTest { } @Test - fun testFlowWithVariable() { + fun flowShouldCreateSplitWhenFlowInstancesAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -252,7 +253,7 @@ internal class SplitBuilderDslIntegrationTest { } @Test - fun testNoFlow() { + fun splitShouldThrowExceptionWhenNoFlowIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslStepCreationIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslStepCreationIntegrationTest.kt new file mode 100644 index 00000000..89342f8d --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslStepCreationIntegrationTest.kt @@ -0,0 +1,444 @@ +/* + * 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.job.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.ExitStatus +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.SimpleJob +import org.springframework.batch.core.job.flow.FlowJob +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.Step +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 + +/** + * Covers the boundary between sequential plain-step jobs and transition-bearing flow jobs. + */ +internal class JobBuilderDslStepCreationIntegrationTest { + @Test + fun stepBeanShouldCreateSimpleJobWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + val step = batch.createTaskletStep("testStep") + context.registerBean("testStep") { + step + } + + // when + val job = + batch { + job("testJob") { + stepBean("testStep") + } + } + + // then + assertThat(job).isInstanceOf(SimpleJob::class.java) + } + + @Test + fun stepShouldCreateSimpleJobWhenInitIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + + // when + val job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + + // then + assertThat(job).isInstanceOf(SimpleJob::class.java) + } + + @Test + fun stepShouldCreateSimpleJobWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + val step = batch.createTaskletStep("testStep") + + // when + val job = + batch { + job("testJob") { + step(step) + } + } + + // then + assertThat(job).isInstanceOf(SimpleJob::class.java) + } + + @Test + fun stepsShouldExecuteSequentiallyWhenPlainStepsAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + val executionOrder = mutableListOf() + + val job = + batch { + job("testJob") { + step("testStep1") { + tasklet( + { _, _ -> + executionOrder += "testStep1" + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + executionOrder += "testStep2" + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(executionOrder).containsExactly("testStep1", "testStep2") + } + + @Test + fun stepBeanShouldCreateFlowJobWhenBeanNameAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + 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(), + ) + } + } + context.apply { + registerBean("testStep1") { + testStep1 + } + registerBean("testStep2") { + testStep2 + } + } + + // when + 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(), + ) + } + } + } + stepBean("testStep2") { + on("COMPLETED") { + end("TEST") + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(job).isInstanceOf(FlowJob::class.java) + 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 stepShouldCreateFlowJobWhenInitAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStep1CallCount = 0 + var transitionStep2CallCount = 0 + var testStep2CallCount = 0 + + // when + val job = + batch { + job("testJob") { + 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(), + ) + } + } + } + step( + "testStep2", + { + tasklet( + { _, _ -> + ++testStep2CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + }, + ) { + on("COMPLETED") { + end("TEST") + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(job).isInstanceOf(FlowJob::class.java) + 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 stepShouldCreateFlowJobWhenInstanceAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + 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 job = + batch { + job("testJob") { + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(job).isInstanceOf(FlowJob::class.java) + 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) + } + + private fun BatchDsl.createTaskletStep(name: String): Step = + step(name) { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + + @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/ChunkOrientedStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/ChunkOrientedStepBuilderDslIntegrationTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/ChunkOrientedStepBuilderDslIntegrationTest.kt index 04e54599..47ea1b24 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/ChunkOrientedStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/ChunkOrientedStepBuilderDslIntegrationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration.step +package com.navercorp.spring.batch.plus.kotlin.configuration.job.step.builder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat @@ -49,11 +49,11 @@ import java.util.UUID import javax.sql.DataSource /** - * Integration tests for creating and executing chunk-oriented steps through the public Kotlin DSL. + * Covers the integration boundary from chunk declarations to actual chunk-oriented step execution. */ internal class ChunkOrientedStepBuilderDslIntegrationTest { @Test - fun testChunkOrientedStep() { + fun chunkShouldCreateChunkOrientedStepWhenItemComponentsAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -98,7 +98,7 @@ internal class ChunkOrientedStepBuilderDslIntegrationTest { } @Test - fun testChunkOrientedStepWithAnnotationListener() { + fun listenerShouldInvokeAnnotatedCallbacksWhenChunkOrientedStepRuns() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -168,7 +168,7 @@ internal class ChunkOrientedStepBuilderDslIntegrationTest { } @Test - fun testFaultTolerantChunkOrientedStepWithVariantItemComponentTypes() { + fun chunkShouldCreateFaultTolerantStepWhenItemComponentsUseVariantTypes() { // 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/FlowStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/FlowStepBuilderDslIntegrationTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/FlowStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/FlowStepBuilderDslIntegrationTest.kt index f54a5b45..7a1221b1 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/job/step/builder/FlowStepBuilderDslIntegrationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration.step +package com.navercorp.spring.batch.plus.kotlin.configuration.job.step.builder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat @@ -42,11 +42,11 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration tests for creating and executing flow steps through the public Kotlin DSL. + * Covers the integration boundary from flow declarations to actual flow-step execution. */ internal class FlowStepBuilderDslIntegrationTest { @Test - fun testFlowBean() { + fun flowBeanShouldCreateFlowStepWhenBeanNameIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -98,7 +98,7 @@ internal class FlowStepBuilderDslIntegrationTest { } @Test - fun testFlowWithLambda() { + fun flowShouldCreateFlowStepWhenFlowIsDeclaredWithInit() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -143,7 +143,7 @@ internal class FlowStepBuilderDslIntegrationTest { } @Test - fun testFlowWithVariable() { + fun flowShouldCreateFlowStepWhenFlowIsProvided() { // 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/JobStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/JobStepBuilderDslIntegrationTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/JobStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/JobStepBuilderDslIntegrationTest.kt index caa7aef9..85d07e59 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/job/step/builder/JobStepBuilderDslIntegrationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration.step +package com.navercorp.spring.batch.plus.kotlin.configuration.job.step.builder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat @@ -42,11 +42,11 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration tests for creating and executing job steps through the public Kotlin DSL. + * Covers the integration boundary from nested job declarations to actual job-step execution. */ internal class JobStepBuilderDslIntegrationTest { @Test - fun testJobBean() { + fun jobBeanShouldCreateJobStepWhenBeanNameIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -85,7 +85,7 @@ internal class JobStepBuilderDslIntegrationTest { } @Test - fun testJobBeanWithInit() { + fun jobBeanShouldCreateJobStepWhenBeanNameAndInitAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -131,7 +131,7 @@ internal class JobStepBuilderDslIntegrationTest { } @Test - fun testJobWithJobVariable() { + fun jobShouldCreateJobStepWhenJobIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -167,7 +167,7 @@ internal class JobStepBuilderDslIntegrationTest { } @Test - fun testJobWithJobVariableAndInit() { + fun jobShouldCreateJobStepWhenJobAndInitAreProvided() { // 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/PartitionStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/PartitionStepBuilderDslIntegrationTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/PartitionStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/PartitionStepBuilderDslIntegrationTest.kt index a25c0ee6..85824733 100644 --- 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/job/step/builder/PartitionStepBuilderDslIntegrationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration.step +package com.navercorp.spring.batch.plus.kotlin.configuration.job.step.builder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat @@ -48,11 +48,11 @@ import java.util.UUID import javax.sql.DataSource /** - * Integration tests for creating and executing partition steps through the public Kotlin DSL. + * Covers the integration boundary from partition declarations to actual partition-step execution. */ internal class PartitionStepBuilderDslIntegrationTest { @Test - fun testPartitionHandlerWithDirectOne() { + fun partitionerShouldCreatePartitionStepWhenPartitionHandlerIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -94,7 +94,7 @@ internal class PartitionStepBuilderDslIntegrationTest { } @Test - fun testPartitionHandlerWithBuiltInOne() { + fun partitionerShouldCreatePartitionStepWhenTaskExecutorPartitionHandlerIsConfigured() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -154,7 +154,7 @@ internal class PartitionStepBuilderDslIntegrationTest { @Nested inner class RedundancyCheck { @Test - fun testPartitionHandlerAndRedundantSettings() { + fun partitionHandlerShouldIgnoreTaskExecutorPartitionHandlerSettingsWhenBothAreConfigured() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -215,7 +215,7 @@ internal class PartitionStepBuilderDslIntegrationTest { } @Test - fun testSplitterAndRedundantSettings() { + fun splitterShouldIgnorePartitionerWhenBothAreConfigured() { // 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/SimpleStepBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/SimpleStepBuilderDslIntegrationTest.kt similarity index 94% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/SimpleStepBuilderDslIntegrationTest.kt index d84c3159..47461ad7 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/SimpleStepBuilderDslIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/SimpleStepBuilderDslIntegrationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration.step +package com.navercorp.spring.batch.plus.kotlin.configuration.job.step.builder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat @@ -42,12 +42,12 @@ import java.util.UUID import javax.sql.DataSource /** - * Integration tests for deprecated simple chunk step entry points on the public Kotlin DSL. + * Covers the integration boundary from deprecated chunk declarations to actual simple-step execution. */ @Suppress("DEPRECATION") internal class SimpleStepBuilderDslIntegrationTest { @Test - fun testChunkWithCount() { + fun chunkShouldCreateSimpleStepWhenChunkSizeIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -89,7 +89,7 @@ internal class SimpleStepBuilderDslIntegrationTest { } @Test - fun testChunkWithCompletionPolicy() { + fun chunkShouldCreateSimpleStepWhenCompletionPolicyIsProvided() { // 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/job/step/builder/TaskletStepBuilderDslIntegrationTest.kt similarity index 95% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/step/TaskletStepBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/builder/TaskletStepBuilderDslIntegrationTest.kt index 25050115..4bd8c8c6 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/job/step/builder/TaskletStepBuilderDslIntegrationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration.step +package com.navercorp.spring.batch.plus.kotlin.configuration.job.step.builder import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import io.mockk.mockk @@ -59,11 +59,11 @@ import java.util.concurrent.ThreadLocalRandom import javax.sql.DataSource /** - * Integration tests for creating and executing tasklet steps through the public Kotlin DSL. + * Covers the integration boundary from tasklet declarations to actual tasklet-step execution. */ internal class TaskletStepBuilderDslIntegrationTest { @Test - fun testTaskletBean() { + fun taskletBeanShouldCreateTaskletStepWhenBeanNameIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -95,7 +95,7 @@ internal class TaskletStepBuilderDslIntegrationTest { } @Test - fun testTaskletBeanWithInit() { + fun taskletBeanShouldCreateTaskletStepWhenBeanNameAndInitAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -143,7 +143,7 @@ internal class TaskletStepBuilderDslIntegrationTest { } @Test - fun testTaskletBeanWithTransactionManager() { + fun taskletBeanShouldCreateTaskletStepWhenBeanNameAndTransactionManagerAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -175,7 +175,7 @@ internal class TaskletStepBuilderDslIntegrationTest { } @Test - fun testTaskletBeanWithTransactionManagerAndInit() { + fun taskletBeanShouldCreateTaskletStepWhenBeanNameTransactionManagerAndInitAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -223,7 +223,7 @@ internal class TaskletStepBuilderDslIntegrationTest { } @Test - fun testTaskletWithLambda() { + fun taskletShouldCreateTaskletStepWhenLambdaIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -250,7 +250,7 @@ internal class TaskletStepBuilderDslIntegrationTest { } @Test - fun testTaskletWithLambdaAndInit() { + fun taskletShouldCreateTaskletStepWhenLambdaAndInitAreProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -295,7 +295,7 @@ internal class TaskletStepBuilderDslIntegrationTest { } @Test - fun testTaskletWithAnnotationListener() { + fun listenerShouldInvokeAnnotatedCallbacksWhenTaskletStepRuns() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -359,7 +359,7 @@ internal class TaskletStepBuilderDslIntegrationTest { inner class RedundancyCheck { @Suppress("DEPRECATION") @Test - fun testStepOperationsIgnoreTaskExecutorAndExceptionHandler() { + fun stepOperationsShouldIgnoreTaskExecutorAndExceptionHandlerWhenBothAreConfigured() { // given var iterateCount = 0 var taskExecutorCallCount = 0 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/job/step/transition/StepTransitionBuilderDslIntegrationTest.kt similarity index 94% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepTransitionBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/transition/StepTransitionBuilderDslIntegrationTest.kt index 48ff8a4c..7d780bef 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/job/step/transition/StepTransitionBuilderDslIntegrationTest.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.job.step.transition +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.RepeatedTest @@ -43,11 +44,11 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration coverage for repeated transition clauses branching from the same step source. + * Covers source reselection after the first `on` clause. */ internal class StepTransitionBuilderDslIntegrationTest { @RepeatedTest(10) - fun testStepWithMultipleTransition() { + fun stepShouldFollowMatchingTransitionWhenMultipleTransitionsAreConfigured() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() @@ -100,7 +101,7 @@ internal class StepTransitionBuilderDslIntegrationTest { } @Test - fun testStepWithNoTransition() { + fun stepShouldThrowExceptionWhenTransitionBlockIsEmpty() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val batch = context.getBean() @@ -121,7 +122,6 @@ internal class StepTransitionBuilderDslIntegrationTest { batch { job("testJob") { step(testStep1) { - // no transition } } } diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnDeciderTargetIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnDeciderTargetIntegrationTest.kt new file mode 100644 index 00000000..6141017c --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnDeciderTargetIntegrationTest.kt @@ -0,0 +1,194 @@ +/* + * 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.job.transition + +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.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 +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 + +/** + * Covers a decider as an immediate transition destination, distinct from branching from a decider source. + */ +internal class OnDeciderTargetIntegrationTest { + @Test + fun deciderBeanShouldExecuteAsTransitionTargetWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + } + + @Test + fun deciderShouldExecuteAsTransitionTargetWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).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/job/transition/OnFlowTargetIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnFlowTargetIntegrationTest.kt new file mode 100644 index 00000000..cfd0bd47 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnFlowTargetIntegrationTest.kt @@ -0,0 +1,429 @@ +/* + * 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.job.transition + +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.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.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 + +/** + * Covers a flow as an immediate transition destination, distinct from branching from a flow source. + */ +internal class OnFlowTargetIntegrationTest { + @Test + fun flowBeanShouldExecuteAsTransitionTargetWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("transitionFlow") { + transitionFlow + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flowBean("transitionFlow") + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun flowShouldExecuteAsTransitionTargetWhenInitIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun flowShouldExecuteAsTransitionTargetWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow(transitionFlow) + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun flowBeanShouldApplySubsequentTransitionWhenBeanNameAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun flowShouldApplySubsequentTransitionWhenInitAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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(), + ) + } + }, + ) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun flowShouldApplySubsequentTransitionWhenInstanceAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + flow(transitionFlow) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } + } + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).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/job/transition/OnStepTargetIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnStepTargetIntegrationTest.kt new file mode 100644 index 00000000..4007e44e --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnStepTargetIntegrationTest.kt @@ -0,0 +1,426 @@ +/* + * 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.job.transition + +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.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.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 + +/** + * Covers a step as an immediate transition destination, distinct from branching from a step source. + */ +internal class OnStepTargetIntegrationTest { + @Test + fun stepBeanShouldExecuteAsTransitionTargetWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stepShouldExecuteAsTransitionTargetWhenInitIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stepShouldExecuteAsTransitionTargetWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stepBeanShouldApplySubsequentTransitionWhenBeanNameAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stepShouldApplySubsequentTransitionWhenInitAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stepShouldApplySubsequentTransitionWhenInstanceAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + 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 jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).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/job/transition/OnTargetSelectionIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnTargetSelectionIntegrationTest.kt new file mode 100644 index 00000000..097295c4 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnTargetSelectionIntegrationTest.kt @@ -0,0 +1,100 @@ +/* + * 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.job.transition + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +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.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.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 + +/** + * Covers the requirement that every `on` clause select a transition target. + */ +internal class OnTargetSelectionIntegrationTest { + @Test + fun onShouldThrowExceptionWhenTransitionTargetIsNotConfigured() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + val testStep = + batch { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + + // when, then + assertThatThrownBy { + batch { + job("testJob") { + step(testStep) { + on("COMPLETED") { + } + } + } + } + }.hasMessageContaining("should set transition") + } + + @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/SimpleJobBuilderDslIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnTerminalActionIntegrationTest.kt similarity index 68% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/SimpleJobBuilderDslIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/OnTerminalActionIntegrationTest.kt index 524eef04..f80fe2bb 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/job/transition/OnTerminalActionIntegrationTest.kt @@ -16,11 +16,13 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.kotlin.configuration +package com.navercorp.spring.batch.plus.kotlin.configuration.job.transition +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.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 @@ -33,7 +35,6 @@ 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 @@ -41,19 +42,16 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Integration coverage for sequential jobs built from plain step declarations. + * Covers terminal actions as valid transition targets. */ -internal class SimpleJobBuilderDslIntegrationTest { +internal class OnTerminalActionIntegrationTest { @Test - fun testStepBean() { + fun stopShouldStopJobWhenTransitionMatches() { // given - AnnotationConfigApplicationContext() val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - var testStep2CallCount = 0 - val testStep1 = batch { step("testStep1") { @@ -66,73 +64,98 @@ internal class SimpleJobBuilderDslIntegrationTest { ) } } - val testStep2 = + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stop() + } + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + } + + @Test + fun endShouldCompleteJobWhenTransitionMatches() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + val testStep1 = batch { - step("testStep2") { + step("testStep1") { tasklet( - { _, _ -> - ++testStep2CallCount + { contribution, _ -> + ++testStep1CallCount + contribution.exitStatus = ExitStatus.UNKNOWN RepeatStatus.FINISHED }, ResourcelessTransactionManager(), ) } } - context.apply { - registerBean("testStep1") { - testStep1 - } - registerBean("testStep2") { - testStep2 - } - } // when val job = batch { job("testJob") { - stepBean("testStep1") - stepBean("testStep2") + step(testStep1) { + on("UNKNOWN") { + end() + } + } } } val jobExecution = jobOperator.start(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 testStepWithInit() { + fun endShouldCompleteJobWithCustomExitStatusWhenStatusIsProvided() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - var testStep2CallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { contribution, _ -> + ++testStep1CallCount + contribution.exitStatus = ExitStatus.UNKNOWN + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } // when val job = batch { job("testJob") { - step("testStep1") { - tasklet( - { _, _ -> - ++testStep1CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) + step(testStep1) { + on("UNKNOWN") { + end("TEST") + } + on("*") { + end() + } } } } @@ -140,18 +163,17 @@ internal class SimpleJobBuilderDslIntegrationTest { // then assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) } @Test - fun testStepWithVariable() { + fun failShouldFailJobWhenTransitionMatches() { // given val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) val jobOperator = context.getBean() val batch = context.getBean() var testStep1CallCount = 0 - var testStep2CallCount = 0 val testStep1 = batch { step("testStep1") { @@ -164,33 +186,24 @@ internal class SimpleJobBuilderDslIntegrationTest { ) } } - val testStep2 = - batch { - step("testStep2") { - tasklet( - { _, _ -> - ++testStep2CallCount - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } // when val job = batch { job("testJob") { - step(testStep1) - step(testStep2) + step(testStep1) { + on("COMPLETED") { + fail() + } + } } } val jobExecution = jobOperator.start(job, JobParameters()) // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.status).isEqualTo(BatchStatus.FAILED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.FAILED.exitCode) assertThat(testStep1CallCount).isEqualTo(1) - assertThat(testStep2CallCount).isEqualTo(1) } @Configuration diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToDeciderIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToDeciderIntegrationTest.kt new file mode 100644 index 00000000..15777843 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToDeciderIntegrationTest.kt @@ -0,0 +1,214 @@ +/* + * 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.job.transition + +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.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 +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 + +/** + * Covers a decider as the restart target after a stopped execution. + */ +internal class StopAndRestartToDeciderIntegrationTest { + @Test + fun stopAndRestartToDeciderBeanShouldRestartAtDeciderWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + 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(), + ) + } + } + on("*") { + fail() + } + } + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToDeciderShouldRestartAtDeciderWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var testDeciderCallCount = 0 + var transitionStepCallCount = 0 + 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(), + ) + } + } + on("*") { + fail() + } + } + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(testDeciderCallCount).isEqualTo(1) + assertThat(transitionStepCallCount).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/job/transition/StopAndRestartToFlowIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToFlowIntegrationTest.kt new file mode 100644 index 00000000..e337b681 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToFlowIntegrationTest.kt @@ -0,0 +1,444 @@ +/* + * 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.job.transition + +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.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.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 + +/** + * Covers a flow as the restart target after a stopped execution. + */ +internal class StopAndRestartToFlowIntegrationTest { + @Test + fun stopAndRestartToFlowBeanShouldRestartAtFlowWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + context.registerBean("transitionFlow") { + transitionFlow + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlowBean("transitionFlow") + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToFlowShouldRestartAtFlowWhenInitIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToFlowShouldRestartAtFlowWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow(transitionFlow) + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToFlowBeanShouldApplySubsequentTransitionAfterRestartWhenBeanNameAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToFlowShouldApplySubsequentTransitionAfterRestartWhenInitAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToFlowShouldApplySubsequentTransitionAfterRestartWhenInstanceAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + 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") { + tasklet( + { _, _ -> + ++transitionStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val job = + batch { + job("testJob") { + step(testStep1) { + on("COMPLETED") { + stopAndRestartToFlow(transitionFlow) { + on("COMPLETED") { + end("TEST") + } + on("*") { + stop() + } + } + } + } + } + } + val firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).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/job/transition/StopAndRestartToStepIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToStepIntegrationTest.kt new file mode 100644 index 00000000..4c684ae5 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/transition/StopAndRestartToStepIntegrationTest.kt @@ -0,0 +1,432 @@ +/* + * 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.job.transition + +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.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.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 + +/** + * Covers a step as the restart target after a stopped execution. + */ +internal class StopAndRestartToStepIntegrationTest { + @Test + fun stopAndRestartToStepBeanShouldRestartAtStepWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToStepShouldRestartAtStepWhenInitIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToStepShouldRestartAtStepWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToStepBeanShouldApplySubsequentTransitionAfterRestartWhenBeanNameAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToStepShouldApplySubsequentTransitionAfterRestartWhenInitAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).isEqualTo(1) + } + + @Test + fun stopAndRestartToStepShouldApplySubsequentTransitionAfterRestartWhenInstanceAndTransitionAreProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStep1CallCount = 0 + var transitionStepCallCount = 0 + val testStep1 = + batch { + step("testStep1") { + tasklet( + { _, _ -> + ++testStep1CallCount + 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 firstJobExecution = jobOperator.start(job, JobParameters()) + val secondJobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(firstJobExecution.status).isEqualTo(BatchStatus.STOPPED) + assertThat(firstJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.STOPPED.exitCode) + assertThat(secondJobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(secondJobExecution.exitStatus.exitCode).isEqualTo(ExitStatus("TEST").exitCode) + assertThat(testStep1CallCount).isEqualTo(1) + assertThat(transitionStepCallCount).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() + } +} From 87138718942b385c869b86098e713a1a1df6d83e Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 19:21:26 +0900 Subject: [PATCH 54/69] Polish Kotlin DSL unit tests Signed-off-by: Taeik Lim --- .../kotlin/configuration/JobBuilderDslTest.kt | 15 ++-- .../SimpleJobBuilderDslAdapterTest.kt | 70 ++++++++++++++++++- .../configuration/StepBuilderDslTest.kt | 13 ++-- .../step/ChunkOrientedStepBuilderDslTest.kt | 48 ++++++------- .../step/FaultTolerantStepBuilderDslTest.kt | 61 ++++++++-------- .../step/FlowStepBuilderDslTest.kt | 4 +- .../step/JobStepBuilderDslTest.kt | 8 +-- .../step/PartitionStepBuilderDslTest.kt | 20 +++--- .../step/SimpleStepBuilderDslTest.kt | 38 +++++----- .../step/TaskletStepBuilderDslTest.kt | 24 +++---- .../support/LazyConfigurerTest.kt | 12 ++-- 11 files changed, 192 insertions(+), 121 deletions(-) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslTest.kt index b184a998..ab4878d5 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/JobBuilderDslTest.kt @@ -31,12 +31,11 @@ import org.springframework.batch.core.listener.JobExecutionListener import java.util.UUID /** - * Unit tests for JobBuilderDsl's delegation of common job settings. - * Job creation entry points belong in job-specific tests, not here. + * Covers deferred application of common job settings when a job is built. */ internal class JobBuilderDslTest { @Test - fun testValidator() { + fun validatorShouldConfigureJobBuilderWhenValidatorIsProvided() { // given val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) val jobBuilderDsl = jobBuilderDsl(jobBuilder) @@ -53,7 +52,7 @@ internal class JobBuilderDslTest { } @Test - fun testIncrementer() { + fun incrementerShouldConfigureJobBuilderWhenIncrementerIsProvided() { // given val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) val jobBuilderDsl = jobBuilderDsl(jobBuilder) @@ -70,7 +69,7 @@ internal class JobBuilderDslTest { } @Test - fun testObservationRegistry() { + fun observationRegistryShouldConfigureJobBuilderWhenRegistryIsProvided() { // given val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) val jobBuilderDsl = jobBuilderDsl(jobBuilder) @@ -87,7 +86,7 @@ internal class JobBuilderDslTest { } @Test - fun testObjectListener() { + fun listenerShouldConfigureJobBuilderWhenObjectListenerIsProvided() { // given val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) val jobBuilderDsl = jobBuilderDsl(jobBuilder) @@ -106,7 +105,7 @@ internal class JobBuilderDslTest { } @Test - fun testJobExecutionListener() { + fun listenerShouldConfigureJobBuilderWhenJobExecutionListenerIsProvided() { // given val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) val jobBuilderDsl = jobBuilderDsl(jobBuilder) @@ -123,7 +122,7 @@ internal class JobBuilderDslTest { } @Test - fun testPreventRestart() { + fun preventRestartShouldConfigureJobBuilderWhenInvoked() { // given val jobBuilder = spyk(JobBuilder(UUID.randomUUID().toString(), mockk(relaxed = true))) val jobBuilderDsl = jobBuilderDsl(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 382f607f..922509bf 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 @@ -19,20 +19,86 @@ package com.navercorp.spring.batch.plus.kotlin.configuration 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.Test +import org.springframework.batch.core.job.Job 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 +import java.util.UUID /** - * Unit tests for SimpleJobBuilderDslAdapter's fail-fast boundary. + * Covers the adapter boundary between supported plain-step replay and rejected flow-job operations. */ internal class SimpleJobBuilderDslAdapterTest { @Test - fun testUnsupportedCall() { + fun stepBeanShouldDelegateToSimpleJobBuilderDslWhenBeanNameIsProvided() { + // given + val stepName = UUID.randomUUID().toString() + val simpleJobBuilderDsl = mockk(relaxed = true) + val simpleJobBuilderDslAdapter = SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) + + // when + simpleJobBuilderDslAdapter.stepBean(stepName) + + // then + verify(exactly = 1) { simpleJobBuilderDsl.stepBean(stepName) } + } + + @Test + fun stepShouldDelegateToSimpleJobBuilderDslWhenNameAndInitAreProvided() { + // given + val stepName = UUID.randomUUID().toString() + val step = mockk() + val stepInit: StepBuilderDsl.() -> Step = { step } + val simpleJobBuilderDsl = mockk(relaxed = true) + val simpleJobBuilderDslAdapter = SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) + + // when + simpleJobBuilderDslAdapter.step(stepName, stepInit) + + // then + verify(exactly = 1) { simpleJobBuilderDsl.step(stepName, stepInit) } + } + + @Test + fun stepShouldDelegateToSimpleJobBuilderDslWhenStepIsProvided() { + // given + val step = mockk() + val simpleJobBuilderDsl = mockk(relaxed = true) + val simpleJobBuilderDslAdapter = SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) + + // when + simpleJobBuilderDslAdapter.step(step) + + // then + verify(exactly = 1) { simpleJobBuilderDsl.step(step) } + } + + @Test + fun buildShouldReturnJobWhenSimpleJobBuilderDslBuildsJob() { + // given + val job = mockk() + val simpleJobBuilderDsl = + mockk { + every { build() } returns job + } + val simpleJobBuilderDslAdapter = SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) + + // when + val actual = simpleJobBuilderDslAdapter.build() + + // then + assertThat(actual).isSameAs(job) + } + + @Test + fun flowJobOperationShouldThrowUnsupportedOperationExceptionWhenSimpleJobAdapterIsUsed() { // given val simpleJobBuilderDsl = SimpleJobBuilderDsl(DslContext(mockk(), mockk()), mockk()) val simpleJobBuilderDslAdapter = SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) diff --git a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslTest.kt b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslTest.kt index 4452841b..1852d6b6 100644 --- a/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslTest.kt +++ b/spring-batch-plus-kotlin/src/test/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/StepBuilderDslTest.kt @@ -29,12 +29,11 @@ import org.springframework.transaction.PlatformTransactionManager import java.util.concurrent.ThreadLocalRandom /** - * Unit tests for StepBuilderDsl's delegation of common step settings. - * Step creation entry points belong in step-specific tests, not here. + * Covers deferred application of common step settings before specialized step creation. */ internal class StepBuilderDslTest { @Test - fun testObservationRegistry() { + fun observationRegistryShouldConfigureStepBuilderWhenRegistryIsProvided() { // given val stepBuilder = mockk(relaxed = true) val stepBuilderDsl = stepBuilderDsl(stepBuilder) @@ -51,7 +50,7 @@ internal class StepBuilderDslTest { } @Test - fun testStartLimit() { + fun startLimitShouldConfigureStepBuilderWhenLimitIsProvided() { // given val stepBuilder = mockk(relaxed = true) val stepBuilderDsl = stepBuilderDsl(stepBuilder) @@ -68,7 +67,7 @@ internal class StepBuilderDslTest { } @Test - fun testObjectListener() { + fun listenerShouldConfigureStepBuilderWhenObjectListenerIsProvided() { // given val stepBuilder = mockk(relaxed = true) val stepBuilderDsl = stepBuilderDsl(stepBuilder) @@ -87,7 +86,7 @@ internal class StepBuilderDslTest { } @Test - fun testStepExecutionListener() { + fun listenerShouldConfigureStepBuilderWhenStepExecutionListenerIsProvided() { // given val stepBuilder = mockk(relaxed = true) val stepBuilderDsl = stepBuilderDsl(stepBuilder) @@ -104,7 +103,7 @@ internal class StepBuilderDslTest { } @Test - fun testAllowStartIfComplete() { + fun allowStartIfCompleteShouldConfigureStepBuilderWhenFlagIsProvided() { // given val stepBuilder = mockk(relaxed = true) val stepBuilderDsl = stepBuilderDsl(stepBuilder) 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 index 87240491..b4a8bf7d 100644 --- 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 @@ -42,11 +42,11 @@ import org.springframework.transaction.interceptor.TransactionAttribute import java.util.concurrent.ThreadLocalRandom /** - * Unit tests for ChunkOrientedStepBuilderDsl's delegation to Spring Batch's ChunkOrientedStepBuilder. + * Covers the unit boundary between chunk-oriented step declarations and their underlying builder configuration. */ internal class ChunkOrientedStepBuilderDslTest { @Test - fun testReader() { + fun readerShouldConfigureChunkOrientedStepBuilderWhenReaderIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -62,7 +62,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testProcessor() { + fun processorShouldConfigureChunkOrientedStepBuilderWhenProcessorIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -78,7 +78,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testWriter() { + fun writerShouldConfigureChunkOrientedStepBuilderWhenWriterIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -94,7 +94,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testTransactionManager() { + fun transactionManagerShouldConfigureChunkOrientedStepBuilderWhenTransactionManagerIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -110,7 +110,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testTransactionAttribute() { + fun transactionAttributeShouldConfigureChunkOrientedStepBuilderWhenTransactionAttributeIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -126,7 +126,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testStream() { + fun streamShouldConfigureChunkOrientedStepBuilderWhenItemStreamIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -142,7 +142,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testStepListener() { + fun listenerShouldConfigureChunkOrientedStepBuilderWhenStepListenerIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -158,7 +158,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testObjectListener() { + fun listenerShouldConfigureChunkOrientedStepBuilderWhenObjectListenerIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -176,7 +176,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testInterruptionPolicy() { + fun interruptionPolicyShouldConfigureChunkOrientedStepBuilderWhenPolicyIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -192,7 +192,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testFaultTolerant() { + fun faultTolerantShouldEnableFaultToleranceWhenInvoked() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -207,7 +207,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testRetryPolicy() { + fun retryPolicyShouldConfigureChunkOrientedStepBuilderWhenPolicyIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -223,7 +223,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testRetryListener() { + fun retryListenerShouldConfigureChunkOrientedStepBuilderWhenListenerIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -239,7 +239,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testRetryWithReified() { + fun retryShouldConfigureChunkOrientedStepBuilderWhenReifiedExceptionTypeIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -254,7 +254,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testRetryWithKClass() { + fun retryShouldConfigureChunkOrientedStepBuilderWhenKClassIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -269,7 +269,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testRetryLimit() { + fun retryLimitShouldConfigureChunkOrientedStepBuilderWhenLimitIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -285,7 +285,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testSkipPolicy() { + fun skipPolicyShouldConfigureChunkOrientedStepBuilderWhenPolicyIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -301,7 +301,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testSkipListener() { + fun skipListenerShouldConfigureChunkOrientedStepBuilderWhenListenerIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -317,7 +317,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testSkipWithReified() { + fun skipShouldConfigureChunkOrientedStepBuilderWhenReifiedExceptionTypeIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -332,7 +332,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testSkipWithKClass() { + fun skipShouldConfigureChunkOrientedStepBuilderWhenKClassIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -347,7 +347,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testSkipLimit() { + fun skipLimitShouldConfigureChunkOrientedStepBuilderWhenLimitIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -363,7 +363,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testTaskExecutor() { + fun taskExecutorShouldConfigureChunkOrientedStepBuilderWhenExecutorIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -379,7 +379,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testObservationRegistry() { + fun observationRegistryShouldConfigureChunkOrientedStepBuilderWhenRegistryIsProvided() { // given val chunkOrientedStepBuilder = mockk>(relaxed = true) @@ -395,7 +395,7 @@ internal class ChunkOrientedStepBuilderDslTest { } @Test - fun testBuild() { + fun buildShouldReturnBuiltStepWhenInvoked() { // given val mockStep = mockk>() val chunkOrientedStepBuilder = 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 0af43ccd..fd3abab7 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 @@ -51,7 +51,7 @@ import org.springframework.retry.policy.SimpleRetryPolicy import org.springframework.transaction.interceptor.DefaultTransactionAttribute /** - * Separated from SimpleStepBuilderDslTest since it's too big. + * Covers fault-tolerant behavior retained by the deprecated simple-step DSL and ordering-sensitive builder overrides. */ internal class FaultTolerantStepBuilderDslTest { private val jobInstance = JobInstance(0L, "testJob") @@ -59,7 +59,7 @@ internal class FaultTolerantStepBuilderDslTest { private val jobParameters = JobParameters() @Test - fun testSkipListener() { + fun skipListenerShouldReceiveCallbackWhenSkippableReadFailureOccurs() { // given val chunkSize = 3 val readLimit = 20 @@ -123,7 +123,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testRetryListener() { + fun retryListenerShouldBeInvokedWhenWriterRetryOccurs() { // given val chunkSize = 3 val readLimit = 20 @@ -188,7 +188,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testKeyGenerator() { + fun keyGeneratorShouldBeInvokedWhenWriterRetryOccurs() { // given val chunkSize = 3 val readLimit = 20 @@ -230,7 +230,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testRetryLimit() { + fun retryLimitShouldBoundAttemptsWhenWriterKeepsFailing() { // given val chunkSize = 3 val readLimit = 20 @@ -269,7 +269,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testRetry() { + fun retryShouldRetryMatchingExceptionWhenWriterFails() { // given val chunkSize = 3 val readLimit = 20 @@ -308,7 +308,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testNoRetry() { + fun noRetryShouldPreventRetryWhenExceptionIsExcluded() { // given val chunkSize = 3 val readLimit = 20 @@ -348,7 +348,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testRetryPolicy() { + fun retryPolicyShouldControlAttemptsWhenWriterKeepsFailing() { // given val chunkSize = 3 val readLimit = 20 @@ -387,7 +387,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testBackoffPolicy() { + fun backOffPolicyShouldBeInvokedWhenWriterRetryOccurs() { // given val chunkSize = 3 val readLimit = 20 @@ -436,7 +436,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testRetryContextCache() { + fun retryContextCacheShouldBeUsedWhenWriterRetryOccurs() { // given val chunkSize = 3 val readLimit = 20 @@ -485,7 +485,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testSkipLimit() { + fun skipLimitShouldAllowConfiguredNumberOfReadFailuresWhenExceptionIsSkippable() { // given val chunkSize = 3 val readLimit = 20 @@ -526,7 +526,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testSkip() { + fun skipShouldSkipMatchingExceptionWhenReadFails() { // given val chunkSize = 3 val readLimit = 20 @@ -567,7 +567,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testNoSkip() { + fun noSkipShouldFailStepWithoutSkippingWhenExceptionIsExcluded() { // given val chunkSize = 3 val readLimit = 20 @@ -609,7 +609,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testSkipPolicy() { + fun skipPolicyShouldAllowReadFailuresWhenPolicyAcceptsException() { // given val chunkSize = 3 val readLimit = 20 @@ -654,7 +654,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testNoRollback() { + fun noRollbackShouldCompleteStepWhenWriterThrowsExcludedException() { // given val chunkSize = 3 val readLimit = 20 @@ -689,7 +689,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testProcessorNonTransactional() { + fun processorNonTransactionalShouldAvoidReprocessingItemsWhenWriterRetries() { // given val chunkSize = 3 val readLimit = 20 @@ -736,10 +736,13 @@ internal class FaultTolerantStepBuilderDslTest { assertThat(processCallCount).isEqualTo(readLimit) } + /** + * Covers ordering compatibility for options whose delegate changes after fault tolerance is enabled. + */ @Nested inner class OverriddenMethodTest { @Test - fun testObjectSkipListenerNotInvokedWhenCalledBeforeFaultTolerant() { + fun objectListenerShouldNotReceiveSkipCallbackWhenRegisteredBeforeFaultTolerantOnDelegate() { // given val chunkSize = 1 val readLimit = 3 @@ -794,7 +797,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testObjectSkipListenerInvokedWhenCalledAfterFaultTolerant() { + fun objectListenerShouldReceiveSkipCallbackWhenRegisteredAfterFaultTolerantOnDelegate() { // given val chunkSize = 1 val readLimit = 3 @@ -849,7 +852,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testObjectSkipListenerInvokedOnDslWhenCalledBeforeFaultTolerant() { + fun objectListenerShouldReceiveSkipCallbackWhenRegisteredBeforeFaultTolerantOnDsl() { // given val chunkSize = 1 val readLimit = 3 @@ -901,7 +904,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testObjectSkipListenerInvokedOnDslWhenCalledAfterFaultTolerant() { + fun objectListenerShouldReceiveSkipCallbackWhenRegisteredAfterFaultTolerantOnDsl() { // given val chunkSize = 1 val readLimit = 3 @@ -953,7 +956,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testDelegateListenerIsInvokedWhenCalledWithFaultTolerant() { + fun chunkListenerShouldBeInvokedWhenRegisteredAfterFaultTolerantOnDelegate() { // given val stepBuilder = StepBuilder("testStep", mockk(relaxed = true)) val simpleStepBuilder = TestBuilderBridge.simpleStepBuilder(stepBuilder) @@ -991,7 +994,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testDelegateListenerIsInvokedOnDslWhenCalledBeforeFaultTolerant() { + fun chunkListenerShouldBeInvokedWhenRegisteredBeforeFaultTolerantOnDsl() { // when val step = simpleStepBuilderDsl(3) { @@ -1025,7 +1028,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testDelegateListenerIsInvokedOnDslWhenCalledAfterFaultTolerant() { + fun chunkListenerShouldBeInvokedWhenRegisteredAfterFaultTolerantOnDsl() { // when val step = simpleStepBuilderDsl(3) { @@ -1059,7 +1062,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testTransactionAttributeIsWrappedWhenCalledWithFaultTolerant() { + fun transactionAttributeShouldHonorNoRollbackWhenConfiguredAfterFaultTolerantOnDelegate() { // given val chunkSize = 3 val readLimit = 20 @@ -1107,7 +1110,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testTransactionAttributeIsWrappedOnDslWhenCalledBeforeFaultTolerantIsCalled() { + fun transactionAttributeShouldHonorNoRollbackWhenConfiguredBeforeFaultTolerantOnDsl() { // given val chunkSize = 3 val readLimit = 20 @@ -1151,7 +1154,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testTransactionAttributeIsWrappedOnDslWhenCalledAfterFaultTolerantIsCalled() { + fun transactionAttributeShouldHonorNoRollbackWhenConfiguredAfterFaultTolerantOnDsl() { // given val chunkSize = 3 val readLimit = 20 @@ -1195,7 +1198,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testStreamIsDelegatedToChunkMonitorWhenCalledWithFaultTolerant() { + fun streamShouldRegisterWithChunkMonitorWhenConfiguredAfterFaultTolerantOnDelegate() { // given val chunkSize = 3 val readLimit = 20 @@ -1254,7 +1257,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testStreamIsDelegatedToChunkMonitorOnDslWhenCalledBeforeFaultTolerant() { + fun streamShouldRegisterWithChunkMonitorWhenConfiguredBeforeFaultTolerantOnDsl() { // given val chunkSize = 3 val readLimit = 20 @@ -1310,7 +1313,7 @@ internal class FaultTolerantStepBuilderDslTest { } @Test - fun testStreamIsDelegatedToChunkMonitorOnDslWhenCalledAfterFaultTolerant() { + fun streamShouldRegisterWithChunkMonitorWhenConfiguredAfterFaultTolerantOnDsl() { // given val chunkSize = 3 val readLimit = 20 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 68f32571..89954cd0 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,11 +26,11 @@ 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. + * Covers the delegation boundary between the flow-step DSL and its underlying builder. */ internal class FlowStepBuilderDslTest { @Test - fun testBuild() { + fun buildShouldReturnBuiltStepWhenInvoked() { // given val mockStep = mockk() val flowStepBuilder = 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 04cac525..f8c5a1f5 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 @@ -29,11 +29,11 @@ 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. + * Covers the delegation boundary between the job-step DSL and its underlying builder. */ internal class JobStepBuilderDslTest { @Test - fun testOperator() { + fun operatorShouldConfigureJobStepBuilderWhenJobOperatorIsProvided() { // given val jobStepBuilder = mockk(relaxed = true) @@ -49,7 +49,7 @@ internal class JobStepBuilderDslTest { } @Test - fun testParametersExtractor() { + fun parametersExtractorShouldConfigureJobStepBuilderWhenExtractorIsProvided() { // given val jobStepBuilder = mockk(relaxed = true) @@ -65,7 +65,7 @@ internal class JobStepBuilderDslTest { } @Test - fun testBuild() { + fun buildShouldReturnBuiltStepWhenInvoked() { // given val mockStep = mockk() val jobStepBuilder = 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 f1c0bedf..5c8bd847 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 @@ -36,11 +36,11 @@ import java.util.UUID import java.util.concurrent.ThreadLocalRandom /** - * Unit tests for PartitionStepBuilderDsl's delegation and DSL-owned preconditions. + * Covers partition builder delegation and the configuration required to build a partition step. */ internal class PartitionStepBuilderDslTest { @Test - fun testPartitionHandler() { + fun partitionHandlerShouldConfigurePartitionStepBuilderWhenHandlerIsProvided() { // given val partitionHandler = mockk() val splitter = mockk() @@ -61,7 +61,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testPartitionHandlerWithInit() { + fun partitionHandlerShouldConfigurePartitionStepBuilderWhenInitIsProvided() { // given val step = mockk() val taskExecutor = mockk() @@ -90,7 +90,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testSplitter() { + fun splitterShouldConfigurePartitionStepBuilderWhenSplitterIsProvided() { // given val partitionHandler = mockk() val splitter = mockk() @@ -111,7 +111,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testSplitterWithPartitioner() { + fun splitterShouldConfigurePartitionStepBuilderWhenStepNameAndPartitionerAreProvided() { // given val stepName = UUID.randomUUID().toString() val partitionHandler = mockk() @@ -133,7 +133,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testAggregator() { + fun aggregatorShouldConfigurePartitionStepBuilderWhenAggregatorIsProvided() { // given val aggregator = mockk() val partitionHandler = mockk() @@ -156,7 +156,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testBuild() { + fun buildShouldReturnBuiltStepWhenRequiredConfigurationIsProvided() { // given val partitionHandler = mockk() val splitter = mockk() @@ -178,7 +178,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testPartitionHandlerBuilderRequiresStep() { + fun partitionHandlerShouldThrowIllegalStateExceptionWhenStepIsNotConfigured() { // given val taskExecutor = mockk() val gridSize = ThreadLocalRandom.current().nextInt(1, 10) @@ -195,7 +195,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testWithoutPartitionHandler() { + fun buildShouldThrowIllegalStateExceptionWhenPartitionHandlerIsNotConfigured() { // given val splitter = mockk() val partitionStepBuilder = mockk(relaxed = true) @@ -210,7 +210,7 @@ internal class PartitionStepBuilderDslTest { } @Test - fun testWithoutSplitter() { + fun buildShouldThrowIllegalStateExceptionWhenSplitterIsNotConfigured() { // given val partitionHandler = mockk() val partitionStepBuilder = mockk(relaxed = true) 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 bed5c4ae..76534ff3 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 @@ -56,11 +56,11 @@ import java.util.UUID import java.util.concurrent.ThreadLocalRandom /** - * Tests for deprecated SimpleStepBuilderDsl, including its legacy execution-backed redundancy check. + * Covers the deprecated simple-step delegation boundary and its legacy repeat-operation precedence. */ internal class SimpleStepBuilderDslTest { @Test - fun testReader() { + fun readerShouldConfigureSimpleStepBuilderWhenReaderIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -76,7 +76,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testProcessor() { + fun processorShouldConfigureSimpleStepBuilderWhenProcessorIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -92,7 +92,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testWriter() { + fun writerShouldConfigureSimpleStepBuilderWhenWriterIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -108,7 +108,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testReaderIsTransactionalQueue() { + fun readerIsTransactionalQueueShouldConfigureSimpleStepBuilderWhenInvoked() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -123,7 +123,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testObjectListener() { + fun listenerShouldConfigureSimpleStepBuilderWhenObjectListenerIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -141,7 +141,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testReadListener() { + fun listenerShouldConfigureSimpleStepBuilderWhenItemReadListenerIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -157,7 +157,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testWriteListener() { + fun listenerShouldConfigureSimpleStepBuilderWhenItemWriteListenerIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -173,7 +173,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testProcessListener() { + fun listenerShouldConfigureSimpleStepBuilderWhenItemProcessListenerIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -189,7 +189,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testChunkListener() { + fun listenerShouldConfigureSimpleStepBuilderWhenChunkListenerIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -205,7 +205,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testStream() { + fun streamShouldConfigureSimpleStepBuilderWhenItemStreamIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -221,7 +221,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testTaskExecutor() { + fun taskExecutorShouldConfigureSimpleStepBuilderWhenExecutorIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -238,7 +238,7 @@ internal class SimpleStepBuilderDslTest { @Suppress("DEPRECATION") @Test - fun testExceptionHandler() { + fun exceptionHandlerShouldConfigureSimpleStepBuilderWhenHandlerIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -254,7 +254,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testStepOperations() { + fun stepOperationsShouldConfigureSimpleStepBuilderWhenRepeatOperationsAreProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -270,7 +270,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testTransactionAttribute() { + fun transactionAttributeShouldConfigureSimpleStepBuilderWhenTransactionAttributeIsProvided() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -286,7 +286,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testBuild() { + fun buildShouldReturnBuiltStepWhenInvoked() { // given val mockStep = mockk() val taskletStepBuilder = @@ -302,7 +302,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testBuildWithSettingStepOperationsAndTaskExecutor() { + fun buildShouldRejectTaskExecutorWhenStepOperationsAreConfigured() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -317,7 +317,7 @@ internal class SimpleStepBuilderDslTest { } @Test - fun testBuildWithSettingStepOperationsAndExceptionHandler() { + fun buildShouldRejectExceptionHandlerWhenStepOperationsAreConfigured() { // given val simpleStepBuilder = mockk>(relaxed = true) @@ -336,7 +336,7 @@ internal class SimpleStepBuilderDslTest { @Nested inner class RedundancyCheck { @Test - fun testStepOperationsIgnoreTaskExecutorAndExceptionHandler() { + fun stepOperationsShouldTakePrecedenceWhenTaskExecutorAndExceptionHandlerAreConfigured() { // given val chunkSize = 3 val readLimit = 20 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 eced8a0b..2e413ef0 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 @@ -35,11 +35,11 @@ import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.interceptor.TransactionAttribute /** - * Unit tests for TaskletStepBuilderDsl's delegation to Spring Batch's TaskletStepBuilder. + * Covers tasklet-step option delegation and mutually exclusive repeat-operation settings. */ internal class TaskletStepBuilderDslTest { @Test - fun testChunkListener() { + fun listenerShouldConfigureTaskletStepBuilderWhenChunkListenerIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -55,7 +55,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testObjectListener() { + fun listenerShouldConfigureTaskletStepBuilderWhenObjectListenerIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -73,7 +73,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testStream() { + fun streamShouldConfigureTaskletStepBuilderWhenItemStreamIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -90,7 +90,7 @@ internal class TaskletStepBuilderDslTest { @Suppress("DEPRECATION") @Test - fun testTaskExecutor() { + fun taskExecutorShouldConfigureTaskletStepBuilderWhenExecutorIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -106,7 +106,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testExceptionHandler() { + fun exceptionHandlerShouldConfigureTaskletStepBuilderWhenHandlerIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -122,7 +122,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testStepOperations() { + fun stepOperationsShouldConfigureTaskletStepBuilderWhenRepeatOperationsAreProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -138,7 +138,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testTransactionManager() { + fun transactionManagerShouldConfigureTaskletStepBuilderWhenTransactionManagerIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -154,7 +154,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testTransactionalAttribute() { + fun transactionAttributeShouldConfigureTaskletStepBuilderWhenTransactionAttributeIsProvided() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -170,7 +170,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testBuild() { + fun buildShouldReturnBuiltStepWhenInvoked() { // given val mockStep = mockk() val taskletStepBuilder = @@ -187,7 +187,7 @@ internal class TaskletStepBuilderDslTest { @Suppress("DEPRECATION") @Test - fun testBuildWithSettingStepOperationsAndTaskExecutor() { + fun buildShouldRejectTaskExecutorWhenStepOperationsAreConfigured() { // given val taskletStepBuilder = mockk(relaxed = true) @@ -204,7 +204,7 @@ internal class TaskletStepBuilderDslTest { } @Test - fun testBuildWithSettingStepOperationsAndExceptionHandler() { + fun buildShouldRejectExceptionHandlerWhenStepOperationsAreConfigured() { // given val taskletStepBuilder = mockk(relaxed = true) 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 893133ec..ab2c4456 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 @@ -20,10 +20,14 @@ package com.navercorp.spring.batch.plus.kotlin.configuration.support import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import java.util.UUID +/** + * Covers the invariant that composed deferred configurations execute each registered action exactly once. + */ internal class LazyConfigurerTest { @Test - fun testAdd() { + fun configurerShouldExecuteOnceWhenAppliedToTarget() { // given var configurerCallCount = 0 @@ -32,14 +36,14 @@ internal class LazyConfigurerTest { lazyConfigurer.add { ++configurerCallCount } - "test".apply(lazyConfigurer) + lazyConfigurer(UUID.randomUUID().toString()) // then assertThat(configurerCallCount).isEqualTo(1) } @Test - fun testAddOther() { + fun configurersShouldExecuteOnceEachWhenNestedConfigurerIsAppliedToTarget() { // given var configurer1CallCount = 0 var configurer2CallCount = 0 @@ -56,7 +60,7 @@ internal class LazyConfigurerTest { } }, ) - "test".apply(lazyConfigurer) + lazyConfigurer(UUID.randomUUID().toString()) // then assertThat(configurer1CallCount).isEqualTo(1) From 48455d491e7378d7139dd2d8a6d1ddf86d037e16 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 19:56:33 +0900 Subject: [PATCH 55/69] Clarify Kotlin job DSL builder construction Signed-off-by: Taeik Lim --- .../configuration/BatchBuilderBridge.java | 5 --- .../kotlin/configuration/FlowBuilderDsl.kt | 6 +-- .../kotlin/configuration/FlowJobBuilderDsl.kt | 8 ++-- .../kotlin/configuration/JobBuilderDsl.kt | 44 ++++++++++++------- 4 files changed, 36 insertions(+), 27 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 3e00bd3c..d3c6ccd8 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 @@ -22,7 +22,6 @@ 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 @@ -38,10 +37,6 @@ 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); } 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 8fb722f9..53d217da 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,16 +19,16 @@ package com.navercorp.spring.batch.plus.kotlin.configuration import com.navercorp.spring.batch.plus.kotlin.configuration.support.BatchDslMarker -import org.springframework.batch.core.job.builder.FlowBuilder +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 /** - * Declaration surface for flow-like builder targets. - * [T] is the type produced by the underlying Spring Batch [FlowBuilder]. + * Shared DSL for declaring either a standalone [Flow] or the flow of a job. * + * @param T [Flow] for standalone flow declarations, or [FlowJobBuilder] for flow-job declarations * @since 0.1.0 */ @BatchDslMarker 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 294e73b2..b1f65236 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 @@ -33,8 +33,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 { + val flowJobBuilder = this.delegate.build() + return flowJobBuilder.build() + } } 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 d24a1a5c..d7e505b7 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 @@ -37,7 +37,7 @@ import org.springframework.core.task.TaskExecutor /** * Entry DSL for a job block. - * Common job settings are applied to the parent [JobBuilder] before the block is + * Common job settings are applied to the base [JobBuilder] before the block is * replayed into either the simple-job or flow-job builder path. * * @since 0.1.0 @@ -51,7 +51,7 @@ class JobBuilderDsl internal constructor( private val lazyFlowConfigurer = LazyConfigurer>() - private var isFlowJob = false + private var requiresFlowJob = false /** * Set for [JobBuilder.validator][org.springframework.batch.core.job.builder.JobBuilderHelper.validator]. @@ -138,7 +138,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.stepBean(name, stepTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun step( @@ -149,7 +149,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.step(name, stepInit, stepTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun step( @@ -159,14 +159,14 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.step(step, stepTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun flowBean(name: String) { this.lazyFlowConfigurer.add { it.flowBean(name) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun flow( @@ -176,14 +176,14 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.flow(name, flowInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun flow(flow: Flow) { this.lazyFlowConfigurer.add { it.flow(flow) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun flowBean( @@ -193,7 +193,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.flowBean(name, flowTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun flow( @@ -204,7 +204,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.flow(name, flowInit, flowTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun flow( @@ -214,7 +214,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.flow(flow, flowTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun deciderBean( @@ -224,7 +224,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.deciderBean(name, deciderTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun decider( @@ -234,7 +234,7 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.decider(decider, deciderTransitionInit) } - this.isFlowJob = true + this.requiresFlowJob = true } override fun split( @@ -244,19 +244,33 @@ class JobBuilderDsl internal constructor( this.lazyFlowConfigurer.add { it.split(taskExecutor, splitInit) } - this.isFlowJob = true + this.requiresFlowJob = true } internal fun build(): Job { this.jobBuilder.apply(this.lazyConfigurer) - return if (!isFlowJob) { + /** + * A plain sequence of steps can use a simple job. A flow, decider, split, or explicit + * transition requires a flow job because it introduces a flow graph. + */ + return if (!requiresFlowJob) { + /** + * The first step is unknown until deferred declarations are replayed, so + * [JobBuilder.start] cannot be called yet. `SimpleJobBuilder(JobBuilderHelper)` leaves + * the step list open for replay. + */ val simpleJobBuilder = BatchBuilderBridge.toSimpleJobBuilder(this.jobBuilder) val simpleJobBuilderDsl = SimpleJobBuilderDsl(this.dslContext, simpleJobBuilder) SimpleJobBuilderDslAdapter(simpleJobBuilderDsl) .apply(this.lazyFlowConfigurer) .build() } else { + /** + * The first state is unknown until deferred declarations are replayed, so + * [JobBuilder.start] or [JobBuilder.flow] cannot be called yet. + * `JobFlowBuilder(FlowJobBuilder)` leaves the initial state open for replay. + */ val flowJobBuilder = BatchBuilderBridge.toFlowJobBuilder(this.jobBuilder) val jobFlowBuilder = JobFlowBuilder(flowJobBuilder) val delegate = ConcreteFlowBuilderDsl(this.dslContext, jobFlowBuilder) From a99f5e9425db45fe247a88e24d6bc57233cbe12d Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 21:03:38 +0900 Subject: [PATCH 56/69] Reorganize Kotlin DSL job samples Signed-off-by: Taeik Lim --- .../batch/plus/sample/job/creation/README.md | 4 +- .../batch/plus/sample/job/decider/README.md | 8 ++ .../decider/bean/SampleApplicationTest.kt | 2 +- .../{flow => }/decider/bean/TestDecider.kt | 2 +- .../{flow => }/decider/bean/TestJobConfig.kt | 2 +- .../variable}/SampleApplicationTest.kt | 2 +- .../decider/variable/TestJobConfig.kt | 2 +- .../batch/plus/sample/job/flow/README.md | 10 +++ .../plain/variable/SampleApplicationTest.kt | 46 ------------ .../transition/bean/SampleApplicationTest.kt | 46 ------------ .../transition/init/SampleApplicationTest.kt | 46 ------------ .../variable/SampleApplicationTest.kt | 46 ------------ .../bean/SampleApplicationTest.kt | 2 +- .../bean/TestJobConfig.kt | 2 +- .../init}/SampleApplicationTest.kt | 2 +- .../init/TestJobConfig.kt | 2 +- .../variable/SampleApplicationTest.kt | 46 ++++++++++++ .../variable/TestJobConfig.kt | 2 +- .../comparison/after/SampleApplicationTest.kt | 46 ------------ .../step/comparison/after/TestJobConfig.kt | 74 ------------------- .../before/SampleApplicationTest.kt | 46 ------------ .../step/comparison/before/TestJobConfig.kt | 72 ------------------ .../step/plain/init/SampleApplicationTest.kt | 46 ------------ .../plain/variable/SampleApplicationTest.kt | 46 ------------ .../transition/bean/SampleApplicationTest.kt | 46 ------------ .../transition/init/SampleApplicationTest.kt | 46 ------------ .../variable/SampleApplicationTest.kt | 46 ------------ .../{step => }/bean/SampleApplicationTest.kt | 2 +- .../transition/bean/TestJobConfig.kt | 2 +- .../decider/bean/SampleApplicationTest.kt | 46 ------------ .../decider/variable/SampleApplicationTest.kt | 46 ------------ .../finish/end/SampleApplicationTest.kt | 46 ------------ .../flow/bean/SampleApplicationTest.kt | 46 ------------ .../flow/nested/SampleApplicationTest.kt | 46 ------------ .../flow/variable/SampleApplicationTest.kt | 46 ------------ .../{flow => }/init/SampleApplicationTest.kt | 2 +- .../transition/init/TestJobConfig.kt | 2 +- .../step/nested/SampleApplicationTest.kt | 46 ------------ .../step/variable/SampleApplicationTest.kt | 46 ------------ .../SampleApplicationTest.kt | 2 +- .../transition/variable/TestJobConfig.kt | 2 +- .../batch/plus/sample/job/split/README.md | 6 ++ .../batch/plus/sample/job/step/README.md | 10 +++ .../sequential/bean/SampleApplicationTest.kt | 46 ++++++++++++ .../sequential}/bean/TestJobConfig.kt | 2 +- .../sequential/init/SampleApplicationTest.kt | 46 ++++++++++++ .../sequential}/init/TestJobConfig.kt | 2 +- .../variable/SampleApplicationTest.kt | 46 ++++++++++++ .../sequential}/variable/TestJobConfig.kt | 2 +- .../transition/bean/SampleApplicationTest.kt | 46 ++++++++++++ .../step/transition/bean/TestJobConfig.kt | 2 +- .../transition/init/SampleApplicationTest.kt | 46 ++++++++++++ .../step/transition/init/TestJobConfig.kt | 2 +- .../variable/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/variable}/TestJobConfig.kt | 2 +- .../plus/sample/job/transition/README.md | 18 +++++ .../decider/bean/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/decider/bean/TestJobConfig.kt | 2 +- .../decider/variable/SampleApplicationTest.kt | 46 ++++++++++++ .../decider/variable/TestJobConfig.kt | 2 +- .../flow/bean/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/flow/bean/TestJobConfig.kt | 2 +- .../flow/init/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/flow/init/TestJobConfig.kt | 2 +- .../flow/nested}/SampleApplicationTest.kt | 2 +- .../transition/flow/nested/TestJobConfig.kt | 2 +- .../flow/variable/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/flow/variable/TestJobConfig.kt | 2 +- .../step/bean/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/step/bean/TestJobConfig.kt | 2 +- .../step/init/SampleApplicationTest.kt | 46 ++++++++++++ .../step/init}/TestJobConfig.kt | 2 +- .../step/nested/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/step/nested/TestJobConfig.kt | 2 +- .../step/variable/SampleApplicationTest.kt | 46 ++++++++++++ .../transition/step/variable/TestJobConfig.kt | 2 +- .../decider/bean}/SampleApplicationTest.kt | 2 +- .../decider/bean/TestJobConfig.kt | 74 +++++++++++++++++++ .../decider/variable/SampleApplicationTest.kt | 51 +++++++++++++ .../decider/variable}/TestJobConfig.kt | 2 +- .../flow/bean}/SampleApplicationTest.kt | 2 +- .../stopandrestart/flow/bean/TestJobConfig.kt | 67 +++++++++++++++++ .../flow/init}/SampleApplicationTest.kt | 2 +- .../flow/init}/TestJobConfig.kt | 8 +- .../flow/variable/SampleApplicationTest.kt | 51 +++++++++++++ .../flow/variable/TestJobConfig.kt | 67 +++++++++++++++++ .../step/bean/SampleApplicationTest.kt | 51 +++++++++++++ .../stopandrestart/step/bean/TestJobConfig.kt | 64 ++++++++++++++++ .../step/init/SampleApplicationTest.kt | 51 +++++++++++++ .../step/init}/TestJobConfig.kt | 2 +- .../step/variable/SampleApplicationTest.kt | 51 +++++++++++++ .../step/variable/TestJobConfig.kt | 64 ++++++++++++++++ .../terminal/end/SampleApplicationTest.kt | 46 ++++++++++++ .../terminal}/end/TestJobConfig.kt | 2 +- .../terminal}/fail/SampleApplicationTest.kt | 2 +- .../terminal}/fail/TestJobConfig.kt | 2 +- .../terminal}/stop/SampleApplicationTest.kt | 2 +- .../terminal}/stop/TestJobConfig.kt | 2 +- 98 files changed, 1473 insertions(+), 1070 deletions(-) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/README.md rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/decider/bean/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/decider/bean/TestDecider.kt (94%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/decider/bean/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/flow/plain/init => decider/variable}/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/decider/variable/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/README.md delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{step/plain => sequential}/bean/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow/plain => sequential}/bean/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow/plain/bean => sequential/init}/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow/plain => sequential}/init/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow/plain => sequential}/variable/TestJobConfig.kt (96%) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/TestJobConfig.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/{step => }/bean/SampleApplicationTest.kt (99%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow => }/transition/bean/TestJobConfig.kt (96%) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/{flow => }/init/SampleApplicationTest.kt (99%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow => }/transition/init/TestJobConfig.kt (96%) delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/SampleApplicationTest.kt delete mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/{step/init => variable}/SampleApplicationTest.kt (99%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/{flow => }/transition/variable/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/bean/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/step/plain => step/sequential}/bean/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/init/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/step/plain => step/sequential}/init/TestJobConfig.kt (95%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/step/plain => step/sequential}/variable/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/bean/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/step/transition/bean/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/init/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/step/transition/init/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/step/init => step/transition/variable}/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/README.md create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/bean/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/decider/bean/TestJobConfig.kt (97%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/decider/variable/TestJobConfig.kt (97%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/bean/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/flow/bean/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/init/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/flow/init/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/decider/variable => transition/flow/nested}/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/flow/nested/TestJobConfig.kt (97%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/flow/variable/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/bean/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/step/bean/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/init/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/step/transition/variable => transition/step/init}/TestJobConfig.kt (96%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/nested/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/step/nested/TestJobConfig.kt (97%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow => }/transition/step/variable/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/stopandrestart/decider => transition/stopandrestart/decider/bean}/SampleApplicationTest.kt (95%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/bean/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/variable/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/stopandrestart/decider => transition/stopandrestart/decider/variable}/TestJobConfig.kt (96%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/stopandrestart/flow => transition/stopandrestart/flow/bean}/SampleApplicationTest.kt (95%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/bean/TestJobConfig.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/stopandrestart/step => transition/stopandrestart/flow/init}/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/stopandrestart/flow => transition/stopandrestart/flow/init}/TestJobConfig.kt (84%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/init/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/stopandrestart/step => transition/stopandrestart/step/init}/TestJobConfig.kt (95%) create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/SampleApplicationTest.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/TestJobConfig.kt create mode 100644 spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/end/SampleApplicationTest.kt rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/finish => transition/terminal}/end/TestJobConfig.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/finish => transition/terminal}/fail/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/finish => transition/terminal}/fail/TestJobConfig.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/finish => transition/terminal}/stop/SampleApplicationTest.kt (95%) rename spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/{flow/transition/finish => transition/terminal}/stop/TestJobConfig.kt (95%) diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md index 35336d43..28f53527 100644 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/creation/README.md @@ -2,5 +2,5 @@ ## Invariants -- Generic job creation examples from the Kotlin DSL job guide should have a - runnable sample in this package. +- Plain simple-job creation examples from the Kotlin DSL job guide 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/job/decider/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/README.md new file mode 100644 index 00000000..382c197c --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/README.md @@ -0,0 +1,8 @@ +# Job Decider Samples + +## Invariants + +- Job flow guide examples should cover deciders supplied by bean lookup and by + variable, including their required transitions. +- Transition DSL examples are covered in the sibling + [`transition`](../transition) package. 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/decider/bean/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/bean/SampleApplicationTest.kt index a61aa92f..afaf32a7 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/decider/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.decider.bean +package com.navercorp.spring.batch.plus.sample.job.decider.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/decider/bean/TestDecider.kt similarity index 94% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestDecider.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/bean/TestDecider.kt index c292a512..5429da0a 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/decider/bean/TestDecider.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.decider.bean +package com.navercorp.spring.batch.plus.sample.job.decider.bean import org.springframework.batch.core.job.JobExecution import org.springframework.batch.core.job.flow.FlowExecutionStatus 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/decider/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/bean/TestJobConfig.kt index 03e58204..8827c9bb 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/decider/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.decider.bean +package com.navercorp.spring.batch.plus.sample.job.decider.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/decider/variable/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/variable/SampleApplicationTest.kt index 4407cc38..965d6a0d 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/decider/variable/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.init +package com.navercorp.spring.batch.plus.sample.job.decider.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/decider/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/decider/variable/TestJobConfig.kt index a9d73dd7..975cf11b 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/decider/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.decider.variable +package com.navercorp.spring.batch.plus.sample.job.decider.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/README.md new file mode 100644 index 00000000..fcb41f3d --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/README.md @@ -0,0 +1,10 @@ +# Job Flow Selection Samples + +## Invariants + +- The [`sequential`](sequential) package should cover flow selections by bean + lookup, inline creation, and variable input without explicit transitions. +- The [`transition`](transition) package should cover the same input forms with + explicit transitions. +- General transition DSL examples are covered in the sibling + [`transition`](../transition) package. 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 deleted file mode 100644 index b0fd60ec..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/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.flow.flow.plain.variable - -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/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 deleted file mode 100644 index 94cfd86a..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/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.flow.flow.transition.bean - -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/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 deleted file mode 100644 index b40f2ca9..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/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.flow.flow.transition.init - -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/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 deleted file mode 100644 index 6f0fee5b..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/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.flow.flow.transition.variable - -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/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/sequential/bean/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/bean/SampleApplicationTest.kt index 60f200bd..7ce45ec7 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/sequential/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.bean +package com.navercorp.spring.batch.plus.sample.job.flow.sequential.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/sequential/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/bean/TestJobConfig.kt index d2782622..2d52600a 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/sequential/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.bean +package com.navercorp.spring.batch.plus.sample.job.flow.sequential.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/sequential/init/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/init/SampleApplicationTest.kt index c3a46699..219772fc 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/sequential/init/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.bean +package com.navercorp.spring.batch.plus.sample.job.flow.sequential.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/sequential/init/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/init/TestJobConfig.kt index 59a5e32f..1d423013 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/sequential/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.init +package com.navercorp.spring.batch.plus.sample.job.flow.sequential.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..65a68c34 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/variable/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.job.flow.sequential.variable + +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/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/sequential/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/plain/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/sequential/variable/TestJobConfig.kt index 1780aa24..6c0c6bb4 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/sequential/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.plain.variable +package com.navercorp.spring.batch.plus.sample.job.flow.sequential.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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 deleted file mode 100644 index 36281e07..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/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.flow.step.comparison.after - -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/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 deleted file mode 100644 index 41c83204..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/after/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.job.flow.step.comparison.after - -import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl -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 - -@Configuration -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) - } - } - on("*") { - stop() - } - } - } - } - - @Bean - 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) - } - } -} 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 deleted file mode 100644 index 6ee70699..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/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.flow.step.comparison.before - -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/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 deleted file mode 100644 index ca3a8d77..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/comparison/before/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.job.flow.step.comparison.before - -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.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 jobRepository: JobRepository, - private val transactionManager: PlatformTransactionManager, -) { - @Bean - 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 = - StepBuilder("testStep1", jobRepository) - .tasklet( - { _, _ -> - throw IllegalStateException("step failed") - }, - transactionManager, - ).build() - - @Bean - open fun successStep(): Step = - StepBuilder("successStep", jobRepository) - .tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - .build() - - @Bean - 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/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 deleted file mode 100644 index 613af7c1..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/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.flow.step.plain.init - -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/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 deleted file mode 100644 index ad792e0a..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/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.flow.step.plain.variable - -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/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 deleted file mode 100644 index 163ce2b8..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/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.flow.step.transition.bean - -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/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 deleted file mode 100644 index 6d0180be..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/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.flow.step.transition.init - -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/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 deleted file mode 100644 index e7e34cda..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/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.flow.step.transition.variable - -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/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/bean/SampleApplicationTest.kt similarity index 99% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/bean/SampleApplicationTest.kt index 87268c3a..00236b35 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/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.bean +package com.navercorp.spring.batch.plus.sample.job.flow.transition.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/bean/TestJobConfig.kt index 72d16924..d2dd5250 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/transition/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.bean +package com.navercorp.spring.batch.plus.sample.job.flow.transition.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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 deleted file mode 100644 index 00a676f9..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/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.flow.transition.decider.bean - -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/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 deleted file mode 100644 index 1bd1d7f7..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/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.flow.transition.decider.variable - -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/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 deleted file mode 100644 index 479039cd..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/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.flow.transition.finish.end - -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/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 deleted file mode 100644 index c60d7def..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/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.flow.transition.flow.bean - -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/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 deleted file mode 100644 index 1f57f61b..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/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.flow.transition.flow.nested - -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/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 deleted file mode 100644 index b1e3eef2..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/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.flow.transition.flow.variable - -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/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/init/SampleApplicationTest.kt similarity index 99% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/init/SampleApplicationTest.kt index cbab7f2a..379452bb 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/init/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.init +package com.navercorp.spring.batch.plus.sample.job.flow.transition.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/init/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/init/TestJobConfig.kt index 93129cb3..38ec98f9 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/transition/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.init +package com.navercorp.spring.batch.plus.sample.job.flow.transition.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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 deleted file mode 100644 index 2c1a577b..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/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.flow.transition.step.nested - -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/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 deleted file mode 100644 index e8a78b42..00000000 --- a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/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.flow.transition.step.variable - -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/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/variable/SampleApplicationTest.kt similarity index 99% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/variable/SampleApplicationTest.kt index 37f37753..c2e6f210 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/variable/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.init +package com.navercorp.spring.batch.plus.sample.job.flow.transition.variable import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/flow/transition/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/variable/TestJobConfig.kt index d230abed..5d7787c1 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/transition/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.flow.transition.variable +package com.navercorp.spring.batch.plus.sample.job.flow.transition.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/README.md new file mode 100644 index 00000000..9a65e3ed --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/split/README.md @@ -0,0 +1,6 @@ +# Job Split Samples + +## Invariants + +- Flow-job split examples from the Kotlin DSL job guide should have runnable + samples in this package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/README.md new file mode 100644 index 00000000..9a6152d5 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/README.md @@ -0,0 +1,10 @@ +# Job Step Selection Samples + +## Invariants + +- The [`sequential`](sequential) package should cover step selections by bean + lookup, inline creation, and variable input on the simple-job path. +- The [`transition`](transition) package should cover the same input forms on + the flow-job path. +- General transition DSL examples are covered in the sibling + [`transition`](../transition) package. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/bean/SampleApplicationTest.kt new file mode 100644 index 00000000..96ce96e9 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/bean/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.job.step.sequential.bean + +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/flow/step/plain/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/bean/TestJobConfig.kt index 8ee9ff31..6b498ac5 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/step/sequential/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.bean +package com.navercorp.spring.batch.plus.sample.job.step.sequential.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/init/SampleApplicationTest.kt new file mode 100644 index 00000000..6eece17b --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/init/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.job.step.sequential.init + +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/flow/step/plain/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/init/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/init/TestJobConfig.kt index 5304a421..a06e1df6 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/step/sequential/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.init +package com.navercorp.spring.batch.plus.sample.job.step.sequential.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..0533e853 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/variable/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.job.step.sequential.variable + +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/flow/step/plain/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/plain/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/sequential/variable/TestJobConfig.kt index 6e5bab39..4d3d48f8 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/step/sequential/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.plain.variable +package com.navercorp.spring.batch.plus.sample.job.step.sequential.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/bean/SampleApplicationTest.kt new file mode 100644 index 00000000..e6b6747c --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/bean/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.job.step.transition.bean + +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/flow/step/transition/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/bean/TestJobConfig.kt index f3c3aac7..14332d6e 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/step/transition/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.bean +package com.navercorp.spring.batch.plus.sample.job.step.transition.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/init/SampleApplicationTest.kt new file mode 100644 index 00000000..710ea86e --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/init/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.job.step.transition.init + +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/flow/step/transition/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/init/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/init/TestJobConfig.kt index 812393cd..89affff1 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/step/transition/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.init +package com.navercorp.spring.batch.plus.sample.job.step.transition.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..6e19b9ef --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/variable/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.job.step.transition.variable + +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/flow/transition/step/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/step/transition/variable/TestJobConfig.kt index 08e2f259..5fa0af53 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/step/transition/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.init +package com.navercorp.spring.batch.plus.sample.job.step.transition.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/README.md b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/README.md new file mode 100644 index 00000000..46abe3bf --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/README.md @@ -0,0 +1,18 @@ +# Job Transition Samples + +## Invariants + +- Every transition scenario documented by the Kotlin DSL job flow guide should + have a runnable sample in this package. + +## Packages + +- [`step`](step) demonstrates selecting a step as the next state and continuing + from it. +- [`flow`](flow) demonstrates selecting a flow as the next state and continuing + from it. +- [`decider`](decider) demonstrates routing execution through a decision state. +- [`terminal`](terminal) demonstrates completing a transition without selecting + another state. +- [`stopandrestart`](stopandrestart) demonstrates stopping a job while defining + where the next execution resumes. diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/bean/SampleApplicationTest.kt new file mode 100644 index 00000000..d3294d20 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/bean/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.job.transition.decider.bean + +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/flow/transition/decider/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/bean/TestJobConfig.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/bean/TestJobConfig.kt index f2c83115..517e3a8d 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/transition/decider/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.decider.bean +package com.navercorp.spring.batch.plus.sample.job.transition.decider.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..8290f320 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/variable/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.job.transition.decider.variable + +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/flow/transition/decider/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/variable/TestJobConfig.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/decider/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/decider/variable/TestJobConfig.kt index 0d05b9fd..7c0cea0d 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/transition/decider/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.decider.variable +package com.navercorp.spring.batch.plus.sample.job.transition.decider.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/bean/SampleApplicationTest.kt new file mode 100644 index 00000000..0a9a8d5b --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/bean/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.job.transition.flow.bean + +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/flow/transition/flow/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/bean/TestJobConfig.kt index 01460c46..e8bbf41a 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/transition/flow/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.bean +package com.navercorp.spring.batch.plus.sample.job.transition.flow.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/init/SampleApplicationTest.kt new file mode 100644 index 00000000..99daa5f7 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/init/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.job.transition.flow.init + +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/flow/transition/flow/init/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/init/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/init/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/init/TestJobConfig.kt index 7b24b9ae..477b2f08 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/transition/flow/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.init +package com.navercorp.spring.batch.plus.sample.job.transition.flow.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/transition/flow/nested/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/decider/variable/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/nested/SampleApplicationTest.kt index 41473092..e16c990d 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/transition/flow/nested/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.decider.variable +package com.navercorp.spring.batch.plus.sample.job.transition.flow.nested import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/flow/nested/TestJobConfig.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/nested/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/nested/TestJobConfig.kt index d8e49ebd..5e928aa0 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/transition/flow/nested/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.nested +package com.navercorp.spring.batch.plus.sample.job.transition.flow.nested import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..fbb3bc7f --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/variable/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.job.transition.flow.variable + +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/flow/transition/flow/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/flow/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/flow/variable/TestJobConfig.kt index 4719f0bc..25f0c2a3 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/transition/flow/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.flow.variable +package com.navercorp.spring.batch.plus.sample.job.transition.flow.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/bean/SampleApplicationTest.kt new file mode 100644 index 00000000..9d1686d3 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/bean/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.job.transition.step.bean + +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/flow/transition/step/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/bean/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/bean/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/bean/TestJobConfig.kt index 60286bd9..d4139ac2 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/transition/step/bean/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.bean +package com.navercorp.spring.batch.plus.sample.job.transition.step.bean import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/init/SampleApplicationTest.kt new file mode 100644 index 00000000..32703a70 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/init/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.job.transition.step.init + +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/flow/step/transition/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/init/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/step/transition/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/init/TestJobConfig.kt index df6c3238..f2c57128 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/transition/step/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.step.transition.variable +package com.navercorp.spring.batch.plus.sample.job.transition.step.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/nested/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/nested/SampleApplicationTest.kt new file mode 100644 index 00000000..3d6d00ae --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/nested/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.job.transition.step.nested + +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/flow/transition/step/nested/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/nested/TestJobConfig.kt similarity index 97% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/nested/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/nested/TestJobConfig.kt index fbb70555..575ee439 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/transition/step/nested/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.nested +package com.navercorp.spring.batch.plus.sample.job.transition.step.nested import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..2adf4e48 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/variable/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.job.transition.step.variable + +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/flow/transition/step/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/step/variable/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/step/variable/TestJobConfig.kt index daa975e2..8a0057f5 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/transition/step/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.step.variable +package com.navercorp.spring.batch.plus.sample.job.transition.step.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/transition/stopandrestart/decider/bean/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/bean/SampleApplicationTest.kt index 2e8c384f..e606a4f8 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/transition/stopandrestart/decider/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.decider +package com.navercorp.spring.batch.plus.sample.job.transition.stopandrestart.decider.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/bean/TestJobConfig.kt new file mode 100644 index 00000000..50249e0f --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/bean/TestJobConfig.kt @@ -0,0 +1,74 @@ +/* + * 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.transition.stopandrestart.decider.bean + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +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.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 + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, + private val transactionManager: PlatformTransactionManager, +) { + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stopAndRestartToDeciderBean("testDecider") { + on("COMPLETED") { + end() + } + on("BATCH TEST") { + fail() + } + on("*") { + end() + } + } + } + on("*") { + stop() + } + } + } + } + + @Bean + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + + @Bean + 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/transition/stopandrestart/decider/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..8562fc03 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/variable/SampleApplicationTest.kt @@ -0,0 +1,51 @@ +/* + * 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.transition.stopandrestart.decider.variable + +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 firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.STOPPED == firstJobExecution.status) + println("firstJobExecution: $firstJobExecution") + + assert(BatchStatus.FAILED == secondJobExecution.status) + println("secondJobExecution: $secondJobExecution") + } +} 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/transition/stopandrestart/decider/variable/TestJobConfig.kt similarity index 96% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/decider/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/decider/variable/TestJobConfig.kt index 038911b7..47b47f04 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/transition/stopandrestart/decider/variable/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.decider +package com.navercorp.spring.batch.plus.sample.job.transition.stopandrestart.decider.variable import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/transition/stopandrestart/flow/bean/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/bean/SampleApplicationTest.kt index 76cd9baa..e40a68bd 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/transition/stopandrestart/flow/bean/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.flow +package com.navercorp.spring.batch.plus.sample.job.transition.stopandrestart.flow.bean import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/bean/TestJobConfig.kt new file mode 100644 index 00000000..a1b40722 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/bean/TestJobConfig.kt @@ -0,0 +1,67 @@ +/* + * 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.transition.stopandrestart.flow.bean + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.job.Job +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.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()) { + on("COMPLETED") { + stopAndRestartToFlowBean("restartFlow") + } + on("*") { + stop() + } + } + } + } + + @Bean + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + + @Bean + open fun restartFlow(): Flow = + batch { + flow("restartFlow") { + step("restartStep") { + 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/transition/stopandrestart/flow/init/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/init/SampleApplicationTest.kt index 05ba6709..1a369a73 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/transition/stopandrestart/flow/init/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.step +package com.navercorp.spring.batch.plus.sample.job.transition.stopandrestart.flow.init import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/stopandrestart/flow/init/TestJobConfig.kt similarity index 84% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/flow/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/init/TestJobConfig.kt index 2d036a4b..2abf062e 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/transition/stopandrestart/flow/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.flow +package com.navercorp.spring.batch.plus.sample.job.transition.stopandrestart.flow.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job @@ -38,10 +38,8 @@ open class TestJobConfig( step(testStep()) { on("COMPLETED") { stopAndRestartToFlow("restartFlow") { - flow("restartFlow") { - step("restartStep") { - tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) - } + step("restartStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) } } } diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..2fbf0de1 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/SampleApplicationTest.kt @@ -0,0 +1,51 @@ +/* + * 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.transition.stopandrestart.flow.variable + +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 firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.STOPPED == firstJobExecution.status) + println("firstJobExecution: $firstJobExecution") + + assert(BatchStatus.COMPLETED == secondJobExecution.status) + println("secondJobExecution: $secondJobExecution") + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/TestJobConfig.kt new file mode 100644 index 00000000..03af63f4 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/flow/variable/TestJobConfig.kt @@ -0,0 +1,67 @@ +/* + * 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.transition.stopandrestart.flow.variable + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +import org.springframework.batch.core.job.Job +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.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()) { + on("COMPLETED") { + stopAndRestartToFlow(restartFlow()) + } + on("*") { + stop() + } + } + } + } + + @Bean + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + + @Bean + open fun restartFlow(): Flow = + batch { + flow("restartFlow") { + step("restartStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/SampleApplicationTest.kt new file mode 100644 index 00000000..3fda164d --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/SampleApplicationTest.kt @@ -0,0 +1,51 @@ +/* + * 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.transition.stopandrestart.step.bean + +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 firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.STOPPED == firstJobExecution.status) + println("firstJobExecution: $firstJobExecution") + + assert(BatchStatus.COMPLETED == secondJobExecution.status) + println("secondJobExecution: $secondJobExecution") + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/TestJobConfig.kt new file mode 100644 index 00000000..7df70e1c --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/bean/TestJobConfig.kt @@ -0,0 +1,64 @@ +/* + * 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.transition.stopandrestart.step.bean + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +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 + +@Configuration +open class TestJobConfig( + private val batch: BatchDsl, + private val transactionManager: PlatformTransactionManager, +) { + @Bean + open fun testJob(): Job = + batch { + job("testJob") { + step(testStep()) { + on("COMPLETED") { + stopAndRestartToStepBean("restartStep") + } + on("*") { + stop() + } + } + } + } + + @Bean + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + + @Bean + open fun restartStep(): Step = + batch { + step("restartStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/init/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/init/SampleApplicationTest.kt new file mode 100644 index 00000000..9d490978 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/init/SampleApplicationTest.kt @@ -0,0 +1,51 @@ +/* + * 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.transition.stopandrestart.step.init + +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 firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.STOPPED == firstJobExecution.status) + println("firstJobExecution: $firstJobExecution") + + assert(BatchStatus.COMPLETED == secondJobExecution.status) + println("secondJobExecution: $secondJobExecution") + } +} 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/transition/stopandrestart/step/init/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/stopandrestart/step/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/init/TestJobConfig.kt index 879f1e92..52c25520 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/transition/stopandrestart/step/init/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.stopandrestart.step +package com.navercorp.spring.batch.plus.sample.job.transition.stopandrestart.step.init import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/SampleApplicationTest.kt new file mode 100644 index 00000000..9f400fad --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/SampleApplicationTest.kt @@ -0,0 +1,51 @@ +/* + * 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.transition.stopandrestart.step.variable + +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 firstJobExecution = jobOperator.start(job, jobParameters) + val secondJobExecution = jobOperator.start(job, jobParameters) + + assert(BatchStatus.STOPPED == firstJobExecution.status) + println("firstJobExecution: $firstJobExecution") + + assert(BatchStatus.COMPLETED == secondJobExecution.status) + println("secondJobExecution: $secondJobExecution") + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/TestJobConfig.kt new file mode 100644 index 00000000..94c999e8 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/stopandrestart/step/variable/TestJobConfig.kt @@ -0,0 +1,64 @@ +/* + * 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.transition.stopandrestart.step.variable + +import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl +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 + +@Configuration +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()) + } + on("*") { + stop() + } + } + } + } + + @Bean + open fun testStep(): Step = + batch { + step("testStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } + + @Bean + open fun restartStep(): Step = + batch { + step("restartStep") { + tasklet({ _, _ -> RepeatStatus.FINISHED }, transactionManager) + } + } +} diff --git a/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/end/SampleApplicationTest.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/end/SampleApplicationTest.kt new file mode 100644 index 00000000..7a326733 --- /dev/null +++ b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/end/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.job.transition.terminal.end + +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/flow/transition/finish/end/TestJobConfig.kt b/spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/end/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/end/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/end/TestJobConfig.kt index 3388eede..daa386ee 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/transition/terminal/end/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.end +package com.navercorp.spring.batch.plus.sample.job.transition.terminal.end import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/transition/terminal/fail/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/fail/SampleApplicationTest.kt index f93b0a33..6704aec5 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/transition/terminal/fail/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.fail +package com.navercorp.spring.batch.plus.sample.job.transition.terminal.fail import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/terminal/fail/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/fail/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/fail/TestJobConfig.kt index 8ae66ae3..38588743 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/transition/terminal/fail/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.fail +package com.navercorp.spring.batch.plus.sample.job.transition.terminal.fail import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job 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/transition/terminal/stop/SampleApplicationTest.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/SampleApplicationTest.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/stop/SampleApplicationTest.kt index 0570e6ee..d9d9e301 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/transition/terminal/stop/SampleApplicationTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.stop +package com.navercorp.spring.batch.plus.sample.job.transition.terminal.stop import org.junit.jupiter.api.Test import org.springframework.batch.core.BatchStatus 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/transition/terminal/stop/TestJobConfig.kt similarity index 95% rename from spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/flow/transition/finish/stop/TestJobConfig.kt rename to spring-batch-plus-sample/kotlin-dsl-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/job/transition/terminal/stop/TestJobConfig.kt index a829bdfd..f2c604bf 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/transition/terminal/stop/TestJobConfig.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.navercorp.spring.batch.plus.sample.job.flow.transition.finish.stop +package com.navercorp.spring.batch.plus.sample.job.transition.terminal.stop import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl import org.springframework.batch.core.job.Job From 19065d3aa006dffc98eebc129a195f4aeb253b94 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 21:05:28 +0900 Subject: [PATCH 57/69] Split job step creation integration tests Signed-off-by: Taeik Lim --- ...slSequentialStepCreationIntegrationTest.kt | 190 ++++++++++++++++++ ...lTransitionStepCreationIntegrationTest.kt} | 118 +---------- 2 files changed, 192 insertions(+), 116 deletions(-) create mode 100644 spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslSequentialStepCreationIntegrationTest.kt rename spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/{JobBuilderDslStepCreationIntegrationTest.kt => JobBuilderDslTransitionStepCreationIntegrationTest.kt} (77%) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslSequentialStepCreationIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslSequentialStepCreationIntegrationTest.kt new file mode 100644 index 00000000..95d915b3 --- /dev/null +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslSequentialStepCreationIntegrationTest.kt @@ -0,0 +1,190 @@ +/* + * 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.job.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.configuration.annotation.EnableBatchProcessing +import org.springframework.batch.core.configuration.annotation.EnableJdbcJobRepository +import org.springframework.batch.core.job.SimpleJob +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.Step +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 + +/** + * Covers step declarations that keep job construction on the sequential simple-job path. + */ +internal class JobBuilderDslSequentialStepCreationIntegrationTest { + @Test + fun stepBeanShouldCreateSimpleJobWhenBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + val step = batch.createTaskletStep("testStep") + context.registerBean("testStep") { + step + } + + // when + val job = + batch { + job("testJob") { + stepBean("testStep") + } + } + + // then + assertThat(job).isInstanceOf(SimpleJob::class.java) + } + + @Test + fun stepShouldCreateSimpleJobWhenInitIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + + // when + val job = + batch { + job("testJob") { + step("testStep") { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + } + } + + // then + assertThat(job).isInstanceOf(SimpleJob::class.java) + } + + @Test + fun stepShouldCreateSimpleJobWhenInstanceIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val batch = context.getBean() + val step = batch.createTaskletStep("testStep") + + // when + val job = + batch { + job("testJob") { + step(step) + } + } + + // then + assertThat(job).isInstanceOf(SimpleJob::class.java) + } + + @Test + fun stepsShouldExecuteSequentiallyWhenTransitionsAreNotProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + val executionOrder = mutableListOf() + + val job = + batch { + job("testJob") { + step("testStep1") { + tasklet( + { _, _ -> + executionOrder += "testStep1" + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + step("testStep2") { + tasklet( + { _, _ -> + executionOrder += "testStep2" + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + } + + // when + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(executionOrder).containsExactly("testStep1", "testStep2") + } + + private fun BatchDsl.createTaskletStep(name: String): Step = + step(name) { + tasklet( + { _, _ -> RepeatStatus.FINISHED }, + ResourcelessTransactionManager(), + ) + } + + @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/job/step/JobBuilderDslStepCreationIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslTransitionStepCreationIntegrationTest.kt similarity index 77% rename from spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslStepCreationIntegrationTest.kt rename to spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslTransitionStepCreationIntegrationTest.kt index 89342f8d..74d775f7 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslStepCreationIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/step/JobBuilderDslTransitionStepCreationIntegrationTest.kt @@ -25,12 +25,10 @@ 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.SimpleJob import org.springframework.batch.core.job.flow.FlowJob 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.Step import org.springframework.batch.infrastructure.repeat.RepeatStatus import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager import org.springframework.beans.factory.BeanFactory @@ -46,113 +44,9 @@ import org.springframework.transaction.TransactionManager import javax.sql.DataSource /** - * Covers the boundary between sequential plain-step jobs and transition-bearing flow jobs. + * Covers step declarations whose explicit transitions require flow-job construction. */ -internal class JobBuilderDslStepCreationIntegrationTest { - @Test - fun stepBeanShouldCreateSimpleJobWhenBeanNameIsProvided() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val step = batch.createTaskletStep("testStep") - context.registerBean("testStep") { - step - } - - // when - val job = - batch { - job("testJob") { - stepBean("testStep") - } - } - - // then - assertThat(job).isInstanceOf(SimpleJob::class.java) - } - - @Test - fun stepShouldCreateSimpleJobWhenInitIsProvided() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - - // when - val job = - batch { - job("testJob") { - step("testStep") { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) - } - } - } - - // then - assertThat(job).isInstanceOf(SimpleJob::class.java) - } - - @Test - fun stepShouldCreateSimpleJobWhenInstanceIsProvided() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val batch = context.getBean() - val step = batch.createTaskletStep("testStep") - - // when - val job = - batch { - job("testJob") { - step(step) - } - } - - // then - assertThat(job).isInstanceOf(SimpleJob::class.java) - } - - @Test - fun stepsShouldExecuteSequentiallyWhenPlainStepsAreProvided() { - // given - val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) - val jobOperator = context.getBean() - val batch = context.getBean() - val executionOrder = mutableListOf() - - val job = - batch { - job("testJob") { - step("testStep1") { - tasklet( - { _, _ -> - executionOrder += "testStep1" - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - step("testStep2") { - tasklet( - { _, _ -> - executionOrder += "testStep2" - RepeatStatus.FINISHED - }, - ResourcelessTransactionManager(), - ) - } - } - } - - // when - val jobExecution = jobOperator.start(job, JobParameters()) - - // then - assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) - assertThat(executionOrder).containsExactly("testStep1", "testStep2") - } - +internal class JobBuilderDslTransitionStepCreationIntegrationTest { @Test fun stepBeanShouldCreateFlowJobWhenBeanNameAndTransitionAreProvided() { // given @@ -405,14 +299,6 @@ internal class JobBuilderDslStepCreationIntegrationTest { assertThat(testStep2CallCount).isEqualTo(1) } - private fun BatchDsl.createTaskletStep(name: String): Step = - step(name) { - tasklet( - { _, _ -> RepeatStatus.FINISHED }, - ResourcelessTransactionManager(), - ) - } - @Configuration @EnableBatchProcessing @EnableJdbcJobRepository( From 84f234603c3be31e3a52e330806540ae63188cd2 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 21:46:09 +0900 Subject: [PATCH 58/69] Clarify adapter contracts Signed-off-by: Taeik Lim --- .../batch/plus/item/adapter/ItemProcessorAdapter.java | 4 ++-- .../batch/plus/item/adapter/ItemProcessorDelegate.java | 3 +-- .../batch/plus/item/adapter/ItemStreamReaderAdapter.java | 8 +++++--- .../plus/item/adapter/StepScopeItemStreamReader.java | 3 ++- .../batch/plus/step/adapter/ItemProcessorAdapter.java | 3 ++- .../batch/plus/step/adapter/ItemProcessorDelegate.java | 3 +-- .../plus/step/adapter/ItemStreamFluxReaderAdapter.java | 8 +++++--- .../plus/step/adapter/ItemStreamFluxReaderProcessor.java | 4 ++-- .../step/adapter/ItemStreamFluxReaderProcessorWriter.java | 4 ++-- .../plus/step/adapter/ItemStreamFluxReaderWriter.java | 4 ++-- .../step/adapter/ItemStreamIterableReaderAdapter.java | 7 ++++--- .../step/adapter/ItemStreamIterableReaderProcessor.java | 4 ++-- .../adapter/ItemStreamIterableReaderProcessorWriter.java | 4 ++-- .../plus/step/adapter/ItemStreamIterableReaderWriter.java | 4 ++-- .../step/adapter/ItemStreamIteratorReaderAdapter.java | 5 +++-- .../step/adapter/ItemStreamIteratorReaderProcessor.java | 4 ++-- .../adapter/ItemStreamIteratorReaderProcessorWriter.java | 4 ++-- .../plus/step/adapter/ItemStreamIteratorReaderWriter.java | 4 ++-- .../plus/step/adapter/ItemStreamSimpleReaderAdapter.java | 3 ++- .../plus/step/adapter/ItemStreamSimpleReaderDelegate.java | 3 +-- .../step/adapter/ItemStreamSimpleReaderProcessor.java | 4 ++-- .../adapter/ItemStreamSimpleReaderProcessorWriter.java | 4 ++-- .../plus/step/adapter/ItemStreamSimpleReaderWriter.java | 4 ++-- .../plus/step/adapter/StepScopeItemStreamReader.java | 3 ++- 24 files changed, 54 insertions(+), 47 deletions(-) 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 47ad9eca..e0620c51 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,6 +20,7 @@ import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ItemProcessor; /** @@ -49,9 +50,8 @@ protected ItemProcessorAdapter(ItemProcessorDelegate delegate) { this.delegate = Objects.requireNonNull(delegate, "Delegate processor must not be null"); } - @SuppressWarnings("NullableProblems") @Override - public O process(I item) { + public @Nullable O process(I item) { return this.delegate.process(item); } } 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 faa23684..1e7209c4 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 @@ -36,6 +36,5 @@ public interface ItemProcessorDelegate { * @param item an item to process * @return processed item */ - @Nullable - O process(I item); + @Nullable 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 59d5abd1..a94e84b1 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,6 +21,7 @@ import java.util.Iterator; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; @@ -48,13 +49,14 @@ public static ItemStreamReader of(ItemStreamReaderDelegate delegate) { return new ItemStreamReaderAdapter<>(delegate); } + // Prevent the reactive source from advancing beyond the item requested by ItemReader.read(). protected static final int DEFAULT_BATCH_SIZE = 1; protected final ItemStreamReaderDelegate delegate; - protected Flux flux = null; + protected @Nullable Flux flux = null; - protected Iterator iterator = null; + protected @Nullable Iterator iterator = null; protected ItemStreamReaderAdapter(ItemStreamReaderDelegate delegate) { this.delegate = Objects.requireNonNull(delegate, "Delegate reader must not be null"); @@ -68,7 +70,7 @@ public void open(ExecutionContext executionContext) { } @Override - public T read() { + public @Nullable T read() { if (this.iterator == null) { Objects.requireNonNull(this.flux, "Flux isn't set. Call 'open' first."); this.iterator = this.flux.toIterable(DEFAULT_BATCH_SIZE).iterator(); 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 2288810e..515debd4 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 @@ -23,6 +23,7 @@ import java.util.Objects; import java.util.function.Supplier; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.springframework.batch.core.scope.StepScope; import org.springframework.batch.core.scope.context.StepContext; @@ -69,7 +70,7 @@ public void open(ExecutionContext executionContext) throws ItemStreamException { } @Override - public T read() throws Exception { + public @Nullable T read() throws Exception { return getDelegate().read(); } 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 75b31f86..cab8f6d6 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,6 +20,7 @@ import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ItemProcessor; /** @@ -48,7 +49,7 @@ protected ItemProcessorAdapter(ItemProcessorDelegate delegate) { } @Override - public O process(I item) { + public @Nullable 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 69b118c5..fd7d38b5 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 @@ -34,6 +34,5 @@ public interface ItemProcessorDelegate { * @param item an item to process * @return processed item */ - @Nullable - O process(I item); + @Nullable 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 4a3ead46..0fa9a39c 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,6 +22,7 @@ import java.util.Objects; import java.util.Optional; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; @@ -45,13 +46,14 @@ public static ItemStreamReader of(ItemStreamFluxReaderDelegate delegat return new ItemStreamFluxReaderAdapter<>(delegate); } + // Prevent the reactive source from advancing beyond the item requested by ItemReader.read(). protected static final int DEFAULT_BATCH_SIZE = 1; protected final ItemStreamFluxReaderDelegate delegate; - protected Flux flux = null; + protected @Nullable Flux flux = null; - protected Iterator iterator = null; + protected @Nullable Iterator iterator = null; protected ItemStreamFluxReaderAdapter(ItemStreamFluxReaderDelegate delegate) { this.delegate = Objects.requireNonNull(delegate, "Delegate reader must not be null"); @@ -64,7 +66,7 @@ public void open(ExecutionContext executionContext) { } @Override - public T read() { + public @Nullable T read() { Iterator iterator = getIterator(); if (iterator.hasNext()) { return iterator.next(); 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 318848a7..f86cc692 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 @@ -24,8 +24,8 @@ import reactor.core.publisher.Flux; /** - * A {@link Flux} based adapter for stream reader, processor. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemProcessor}, with reader input supplied as a {@link Flux}. * * @since 1.2.0 */ 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 a56b36e7..19c548de 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 @@ -25,8 +25,8 @@ import reactor.core.publisher.Flux; /** - * A {@link Flux} based adapter for stream reader, processor, writer. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader}, + * {@link ItemProcessor}, and {@link ItemStreamWriter}, with reader input supplied as a {@link Flux}. * * @since 1.1.0 */ 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 5763d148..43d408d5 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 @@ -24,8 +24,8 @@ import reactor.core.publisher.Flux; /** - * A {@link Flux} based adapter for stream reader, writer. It can represent - * {@link ItemStreamReader}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemStreamWriter}, with reader input supplied as a {@link Flux}. * * @since 1.1.0 */ 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 eed63e1a..5c687cc1 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,6 +22,7 @@ import java.util.Objects; import java.util.Optional; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; @@ -45,9 +46,9 @@ public static ItemStreamReader of(ItemStreamIterableReaderDelegate del protected final ItemStreamIterableReaderDelegate delegate; - protected Iterable iterable = null; + protected @Nullable Iterable iterable = null; - protected Iterator iterator = null; + protected @Nullable Iterator iterator = null; protected ItemStreamIterableReaderAdapter(ItemStreamIterableReaderDelegate delegate) { this.delegate = Objects.requireNonNull(delegate, "Delegate reader must not be null"); @@ -60,7 +61,7 @@ public void open(ExecutionContext executionContext) { } @Override - public T read() { + public @Nullable T read() { Iterator iterator = getIterator(); if (iterator.hasNext()) { return iterator.next(); 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 4a3d2697..fdfc753a 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 @@ -22,8 +22,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamReader; /** - * An {@link Iterable} based adapter for stream reader, processor. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemProcessor}, with reader input supplied as an {@link Iterable}. * * @since 1.2.0 */ 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 5d9f24ed..5bb91fdf 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 @@ -23,8 +23,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** - * An {@link Iterable} based adapter for stream reader, processor, writer. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader}, + * {@link ItemProcessor}, and {@link ItemStreamWriter}, with reader input supplied as an {@link Iterable}. * * @since 1.1.0 */ 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 4fe75243..07da0f61 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 @@ -22,8 +22,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** - * An {@link Iterable} based adapter for stream reader, writer. It can represent - * {@link ItemStreamReader}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemStreamWriter}, with reader input supplied as an {@link Iterable}. * * @since 1.1.0 */ 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 c8023064..43283c33 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,6 +21,7 @@ import java.util.Iterator; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; @@ -44,7 +45,7 @@ public static ItemStreamReader of(ItemStreamIteratorReaderDelegate del protected final ItemStreamIteratorReaderDelegate delegate; - protected Iterator iterator = null; + protected @Nullable Iterator iterator = null; protected ItemStreamIteratorReaderAdapter(ItemStreamIteratorReaderDelegate delegate) { this.delegate = Objects.requireNonNull(delegate, "Delegate reader must not be null"); @@ -57,7 +58,7 @@ public void open(ExecutionContext executionContext) { } @Override - public T read() { + public @Nullable T read() { Iterator iterator = getIterator(); if (iterator.hasNext()) { return iterator.next(); 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 9c99dccc..bc011c22 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 @@ -24,8 +24,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamReader; /** - * An {@link Iterator} based adapter for stream reader, processor. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemProcessor}, with reader input supplied as an {@link Iterator}. * * @since 1.2.0 */ 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 dfb54415..b9c63e4c 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 @@ -25,8 +25,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** - * An {@link Iterator} based adapter for stream reader, processor, writer. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader}, + * {@link ItemProcessor}, and {@link ItemStreamWriter}, with reader input supplied as an {@link Iterator}. * * @since 1.1.0 */ 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 a41b4df6..fbb70963 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 @@ -24,8 +24,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** - * An {@link Iterator} based adapter for stream reader, writer. It can represent - * {@link ItemStreamReader}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemStreamWriter}, with reader input supplied as an {@link Iterator}. * * @since 1.1.0 */ 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 b8517b2d..2f0ec7ae 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,6 +20,7 @@ import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; @@ -53,7 +54,7 @@ public void open(ExecutionContext executionContext) { } @Override - public T read() { + public @Nullable T read() { return this.delegate.read(); } 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 78c569d2..06a402cd 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 @@ -42,8 +42,7 @@ default void onOpenRead(ExecutionContext executionContext) { * @return an item to read. null if it's end of data. * Return contract is same as {@link org.springframework.batch.infrastructure.item.ItemReader} */ - @Nullable - T read(); + @Nullable T read(); /** * A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. 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 d569d4e2..f3b18b9a 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 @@ -22,8 +22,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamReader; /** - * An item ({@link I}) based adapter for stream reader, processor. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemProcessor}, with the reader supplying one item per call. * * @since 1.2.0 */ 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 11bc86f8..7ae9aa6a 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 @@ -23,8 +23,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** - * An item ({@link I}) based adapter for stream reader, processor, writer. It can represent - * {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader}, + * {@link ItemProcessor}, and {@link ItemStreamWriter}, with the reader supplying one item per call. * * @since 1.1.0 */ 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 2696e884..5c7ea969 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 @@ -22,8 +22,8 @@ import org.springframework.batch.infrastructure.item.ItemStreamWriter; /** - * An item ({@link T}) based adapter for stream reader, writer. It can represent - * {@link ItemStreamReader}, {@link ItemStreamWriter} in a single class. + * Combines the delegate contracts required to adapt one object into an {@link ItemStreamReader} and + * {@link ItemStreamWriter}, with the reader supplying one item per call. * * @since 1.1.0 */ 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 1d5f067e..584eb089 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 @@ -23,6 +23,7 @@ import java.util.Objects; import java.util.function.Supplier; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.springframework.batch.core.scope.StepScope; import org.springframework.batch.core.scope.context.StepContext; @@ -66,7 +67,7 @@ public void open(ExecutionContext executionContext) throws ItemStreamException { } @Override - public T read() throws Exception { + public @Nullable T read() throws Exception { return getDelegate().read(); } From 090cf7427909d32e8cb1c4627015f0ac036b2b12 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 22:30:24 +0900 Subject: [PATCH 59/69] Polish adapter tests Signed-off-by: Taeik Lim --- .../kotlin/step/adapter/ItemDelegatesTest.kt | 27 +++++++------------ ...amFluxReaderProcessorIntegrationTest.java} | 15 +++++------ ...ReaderProcessorWriterIntegrationTest.java} | 15 +++++------ ...treamFluxReaderWriterIntegrationTest.java} | 15 +++++------ ...erableReaderProcessorIntegrationTest.java} | 15 +++++------ ...ReaderProcessorWriterIntegrationTest.java} | 15 +++++------ ...mIterableReaderWriterIntegrationTest.java} | 15 +++++------ ...eratorReaderProcessorIntegrationTest.java} | 15 +++++------ ...ReaderProcessorWriterIntegrationTest.java} | 15 +++++------ ...mIteratorReaderWriterIntegrationTest.java} | 15 +++++------ ...SimpleReaderProcessorIntegrationTest.java} | 13 +++++---- ...ReaderProcessorWriterIntegrationTest.java} | 13 +++++---- ...eamSimpleReaderWriterIntegrationTest.java} | 13 +++++---- .../plus/step/adapter/AdapterFactoryTest.java | 17 +++++++----- .../adapter/ItemProcessorAdapterTest.java | 7 +++-- .../ItemStreamFluxReaderAdapterTest.java | 15 ++++++----- .../ItemStreamIterableReaderAdapterTest.java | 15 ++++++----- .../ItemStreamIteratorReaderAdapterTest.java | 15 ++++++----- .../ItemStreamSimpleReaderAdapterTest.java | 13 +++++---- .../adapter/ItemStreamWriterAdapterTest.java | 13 +++++---- .../StepScopeItemStreamReaderTest.java | 15 ++++++----- 21 files changed, 148 insertions(+), 163 deletions(-) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamFluxReaderProcessorIT.java => ItemStreamFluxReaderProcessorIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamFluxReaderProcessorWriterIT.java => ItemStreamFluxReaderProcessorWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamFluxReaderWriterIT.java => ItemStreamFluxReaderWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamIterableReaderProcessorIT.java => ItemStreamIterableReaderProcessorIntegrationTest.java} (94%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamIterableReaderProcessorWriterIT.java => ItemStreamIterableReaderProcessorWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamIterableReaderWriterIT.java => ItemStreamIterableReaderWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamIteratorReaderProcessorIT.java => ItemStreamIteratorReaderProcessorIntegrationTest.java} (94%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamIteratorReaderProcessorWriterIT.java => ItemStreamIteratorReaderProcessorWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamIteratorReaderWriterIT.java => ItemStreamIteratorReaderWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamSimpleReaderProcessorIT.java => ItemStreamSimpleReaderProcessorIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamSimpleReaderProcessorWriterIT.java => ItemStreamSimpleReaderProcessorWriterIntegrationTest.java} (95%) rename spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/{ItemStreamSimpleReaderWriterIT.java => ItemStreamSimpleReaderWriterIntegrationTest.java} (96%) 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 ed9023c1..eb0f10c4 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 @@ -31,64 +31,55 @@ import io.mockk.mockk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +/** + * Covers the Kotlin extension boundary that converts item delegates into Spring Batch adapters. + */ internal class ItemDelegatesTest { @Test - fun testAsItemStreamReaderOnItemStreamFluxReaderDelegate() { - // when + fun asItemStreamReaderShouldReturnStepScopedReaderWhenFluxDelegateIsProvided() { val delegate = mockk>() val itemStreamReader = delegate.asItemStreamReader() - // then assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java) } @Test - fun testAsItemStreamReaderOnItemStreamIterableReaderDelegate() { - // when + fun asItemStreamReaderShouldReturnStepScopedReaderWhenIterableDelegateIsProvided() { val delegate = mockk>() val itemStreamReader = delegate.asItemStreamReader() - // then assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java) } @Test - fun testAsItemStreamReaderOnItemStreamIteratorReaderDelegate() { - // when + fun asItemStreamReaderShouldReturnStepScopedReaderWhenIteratorDelegateIsProvided() { val delegate = mockk>() val itemStreamReader = delegate.asItemStreamReader() - // then assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java) } @Test - fun testAsItemStreamReaderOnItemStreamSimpleReaderDelegate() { - // when + fun asItemStreamReaderShouldReturnStepScopedReaderWhenSimpleDelegateIsProvided() { val delegate = mockk>() val itemStreamReader = delegate.asItemStreamReader() - // then assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java) } @Test - fun testAsItemProcessor() { - // when + fun asItemProcessorShouldReturnItemProcessorAdapterWhenDelegateIsProvided() { val delegate = mockk>() val itemProcessor = delegate.asItemProcessor() - // then assertThat(itemProcessor).isInstanceOf(ItemProcessorAdapter::class.java) } @Test - fun testAsItemStreamWriter() { - // when + fun asItemStreamWriterShouldReturnItemStreamWriterAdapterWhenDelegateIsProvided() { val delegate = mockk>() val itemStreamWriter = delegate.asItemStreamWriter() - // then assertThat(itemStreamWriter).isInstanceOf(ItemStreamWriterAdapter::class.java) } } 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/ItemStreamFluxReaderProcessorIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorIntegrationTest.java index 3c73329c..2deac3d7 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/ItemStreamFluxReaderProcessorIntegrationTest.java @@ -53,13 +53,16 @@ import reactor.core.publisher.Flux; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamFluxReaderProcessorIT { +class ItemStreamFluxReaderProcessorIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void fluxReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -96,19 +99,16 @@ void fluxReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); } @RepeatedTest(TEST_REPEAT_COUNT) - void fluxReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -145,13 +145,10 @@ void fluxReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); } 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/ItemStreamFluxReaderProcessorWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderProcessorWriterIntegrationTest.java index b3fe852f..aea80cd3 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/ItemStreamFluxReaderProcessorWriterIntegrationTest.java @@ -55,13 +55,16 @@ import reactor.core.publisher.Flux; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamFluxReaderProcessorWriterIT { +class ItemStreamFluxReaderProcessorWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void fluxReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -97,23 +100,20 @@ void fluxReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exceptio } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void fluxReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -149,16 +149,13 @@ void fluxReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exceptio } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); 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/ItemStreamFluxReaderWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamFluxReaderWriterIntegrationTest.java index aa95a8c0..07a9066a 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/ItemStreamFluxReaderWriterIntegrationTest.java @@ -54,13 +54,16 @@ import reactor.core.publisher.Flux; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamFluxReaderWriterIT { +class ItemStreamFluxReaderWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void fluxReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -95,22 +98,19 @@ void fluxReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void fluxReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -145,16 +145,13 @@ void fluxReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } 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/ItemStreamIterableReaderProcessorIntegrationTest.java similarity index 94% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorIntegrationTest.java index 26f06278..598f672e 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/ItemStreamIterableReaderProcessorIntegrationTest.java @@ -52,13 +52,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamIterableReaderProcessorIT { +class ItemStreamIterableReaderProcessorIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void iterableReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -95,19 +98,16 @@ void iterableReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); } @RepeatedTest(TEST_REPEAT_COUNT) - void iterableReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -144,13 +144,10 @@ void iterableReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); } 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/ItemStreamIterableReaderProcessorWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderProcessorWriterIntegrationTest.java index c38e293e..d3e5f72c 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/ItemStreamIterableReaderProcessorWriterIntegrationTest.java @@ -54,13 +54,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamIterableReaderProcessorWriterIT { +class ItemStreamIterableReaderProcessorWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void iterableReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -96,23 +99,20 @@ void iterableReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exce } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void iterableReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -148,16 +148,13 @@ void iterableReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); 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/ItemStreamIterableReaderWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIterableReaderWriterIntegrationTest.java index 700f3307..3e3fe71c 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/ItemStreamIterableReaderWriterIntegrationTest.java @@ -53,13 +53,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamIterableReaderWriterIT { +class ItemStreamIterableReaderWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void iterableReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -94,22 +97,19 @@ void iterableReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void iterableReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -144,16 +144,13 @@ void iterableReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } 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/ItemStreamIteratorReaderProcessorIntegrationTest.java similarity index 94% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorIntegrationTest.java index c2a2e64b..bc3bcef2 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/ItemStreamIteratorReaderProcessorIntegrationTest.java @@ -52,13 +52,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamIteratorReaderProcessorIT { +class ItemStreamIteratorReaderProcessorIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void iteratorReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -95,18 +98,15 @@ void iteratorReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); } @RepeatedTest(TEST_REPEAT_COUNT) - void iteratorReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -143,13 +143,10 @@ void iteratorReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); } 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/ItemStreamIteratorReaderProcessorWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderProcessorWriterIntegrationTest.java index b3b5f0d1..b9573e5a 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/ItemStreamIteratorReaderProcessorWriterIntegrationTest.java @@ -54,13 +54,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamIteratorReaderProcessorWriterIT { +class ItemStreamIteratorReaderProcessorWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void iteratorReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -96,23 +99,20 @@ void iteratorReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exce } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void iteratorReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -148,16 +148,13 @@ void iteratorReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exce } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); 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/ItemStreamIteratorReaderWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamIteratorReaderWriterIntegrationTest.java index 5f311914..5361ae0a 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/ItemStreamIteratorReaderWriterIntegrationTest.java @@ -53,13 +53,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamIteratorReaderWriterIT { +class ItemStreamIteratorReaderWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void iteratorReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -94,22 +97,19 @@ void iteratorReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void iteratorReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -144,16 +144,13 @@ void iteratorReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // read context should be invoked assertThat(invokeCountContext.readContextCallCount).isEqualTo(repeatCount); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } 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/ItemStreamSimpleReaderProcessorIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorIntegrationTest.java index 41654303..d46c38b9 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/ItemStreamSimpleReaderProcessorIntegrationTest.java @@ -51,13 +51,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamSimpleReaderProcessorIT { +class ItemStreamSimpleReaderProcessorIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void simpleReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -94,16 +97,14 @@ void simpleReaderProcessorShouldNotKeepCountWhenStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); } @RepeatedTest(TEST_REPEAT_COUNT) - void simpleReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -140,11 +141,9 @@ void simpleReaderProcessorShouldKeepCountWhenNotStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); } 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/ItemStreamSimpleReaderProcessorWriterIntegrationTest.java similarity index 95% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderProcessorWriterIntegrationTest.java index d0c1cfd1..e3511edc 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/ItemStreamSimpleReaderProcessorWriterIntegrationTest.java @@ -53,13 +53,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamSimpleReaderProcessorWriterIT { +class ItemStreamSimpleReaderProcessorWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void simpleReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -95,21 +98,19 @@ void simpleReaderProcessorWriterShouldNotKeepCountWhenStepScoped() throws Except } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances assertThat(invokeCountContext.processCallCount).isEqualTo(repeatCount * itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void simpleReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -145,14 +146,12 @@ void simpleReaderProcessorWriterShouldKeepCountWhenNotStepScoped() throws Except } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // process, write should be invoked only once per iteration assertThat(invokeCountContext.processCallCount).isEqualTo(itemCount); int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); 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/ItemStreamSimpleReaderWriterIntegrationTest.java similarity index 96% rename from spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIT.java rename to spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/step/adapter/ItemStreamSimpleReaderWriterIntegrationTest.java index 09cf9b91..a9dfa9c2 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/ItemStreamSimpleReaderWriterIntegrationTest.java @@ -52,13 +52,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.TransactionManager; +/** + * Covers how delegate scope controls state isolation across step executions. + */ @SuppressWarnings({"unchecked", "unused"}) -class ItemStreamSimpleReaderWriterIT { +class ItemStreamSimpleReaderWriterIntegrationTest { private static final int TEST_REPEAT_COUNT = 5; @RepeatedTest(TEST_REPEAT_COUNT) - void simpleReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { + void stepScopedDelegateShouldUseFreshStateForEachStepExecution() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -93,20 +96,18 @@ void simpleReaderWriterShouldNotKeepCountWhenStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // 'count' field is isolated per job instances since it is step scoped. so count is 0 for all job instances int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(repeatCount * writeCountPerIteration); } @RepeatedTest(TEST_REPEAT_COUNT) - void simpleReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { + void singletonDelegateShouldReuseStateAcrossStepExecutions() throws Exception { int itemCount = ThreadLocalRandom.current().nextInt(10, 100); int chunkCount = ThreadLocalRandom.current().nextInt(1, 10); InvokeCountContext invokeCountContext = new InvokeCountContext(); @@ -141,14 +142,12 @@ void simpleReaderWriterShouldKeepCountWhenNotStepScoped() throws Exception { } assertThat(jobExecutions).allSatisfy(it -> assertThat(it.getStatus()).isEqualTo(BatchStatus.COMPLETED)); - // stream callback should be invoked assertThat(invokeCountContext.onOpenReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateReadCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseReadCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onOpenWriteCallCount).isEqualTo(repeatCount); assertThat(invokeCountContext.onUpdateWriteCallCount).isGreaterThanOrEqualTo(repeatCount); assertThat(invokeCountContext.onCloseWriteCallCount).isEqualTo(repeatCount); - // write should be invoked only once per iteration int writeCountPerIteration = (int)Math.ceil((double)itemCount / (double)chunkCount); assertThat(invokeCountContext.writeCallCount).isEqualTo(writeCountPerIteration); } 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 f48cb4c0..93600980 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 @@ -31,10 +31,13 @@ import reactor.core.publisher.Flux; +/** + * Covers delegate conversion and step-scoped reader wrapping across Spring Batch item components. + */ class AdapterFactoryTest { @Test - void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithFluxDelegate() { + void itemStreamReaderShouldReturnStepScopedReaderWhenFluxDelegateIsProvided() { ItemStreamFluxReaderDelegate delegate = executionContext -> Flux.empty(); ItemStreamReader actual = AdapterFactory.itemStreamReader(delegate); @@ -42,7 +45,7 @@ void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithFluxDeleg } @Test - void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithIterableDelegate() { + void itemStreamReaderShouldReturnStepScopedReaderWhenIterableDelegateIsProvided() { ItemStreamIterableReaderDelegate delegate = executionContext -> List.of(); ItemStreamReader actual = AdapterFactory.itemStreamReader(delegate); @@ -50,7 +53,7 @@ void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithIterableD } @Test - void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithIteratorDelegate() { + void itemStreamReaderShouldReturnStepScopedReaderWhenIteratorDelegateIsProvided() { ItemStreamIteratorReaderDelegate delegate = executionContext -> Collections.emptyIterator(); ItemStreamReader actual = AdapterFactory.itemStreamReader(delegate); @@ -58,7 +61,7 @@ void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithIteratorD } @Test - void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithSimpleDelegate() { + void itemStreamReaderShouldReturnStepScopedReaderWhenSimpleDelegateIsProvided() { ItemStreamSimpleReaderDelegate delegate = () -> null; ItemStreamReader actual = AdapterFactory.itemStreamReader(delegate); @@ -66,7 +69,7 @@ void itemStreamReaderShouldReturnStepScopedOneWhenPassingItemReaderWithSimpleDel } @Test - void itemProcessorShouldReturnAdapterWhenPassingProcessorDelegate() { + void itemProcessorShouldReturnProcessorAdapterWhenDelegateIsProvided() { ItemProcessorDelegate delegate = item -> null; ItemProcessor actual = AdapterFactory.itemProcessor(delegate); @@ -74,7 +77,7 @@ void itemProcessorShouldReturnAdapterWhenPassingProcessorDelegate() { } @Test - void itemStreamWriterShouldReturnAdapterWhenPassingWriterDelegate() { + void itemStreamWriterShouldReturnWriterAdapterWhenDelegateIsProvided() { ItemStreamWriterDelegate delegate = items -> { }; ItemStreamWriter actual = AdapterFactory.itemStreamWriter(delegate); @@ -84,7 +87,7 @@ void itemStreamWriterShouldReturnAdapterWhenPassingWriterDelegate() { @SuppressWarnings({"ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void adapterCreationShouldRejectNullDelegate() { assertThatThrownBy(() -> AdapterFactory.itemStreamReader((ItemStreamFluxReaderDelegate)null)); assertThatThrownBy(() -> AdapterFactory.itemStreamReader((ItemStreamIterableReaderDelegate)null)); assertThatThrownBy(() -> AdapterFactory.itemStreamReader((ItemStreamIteratorReaderDelegate)null)); 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 ef5ef66e..71b04669 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 @@ -29,11 +29,14 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.infrastructure.item.ItemProcessor; +/** + * Covers preservation of the processing delegate contract through its Spring Batch adapter. + */ @SuppressWarnings("unchecked") class ItemProcessorAdapterTest { @Test - void processShouldReturnValueFromDelegate() throws Exception { + void processShouldReturnDelegateResult() throws Exception { Integer expected = ThreadLocalRandom.current().nextInt(); ItemProcessorDelegate delegate = mock(ItemProcessorDelegate.class); when(delegate.process(any())).thenReturn(expected); @@ -46,7 +49,7 @@ void processShouldReturnValueFromDelegate() throws Exception { @SuppressWarnings({"ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegate() { assertThatThrownBy(() -> ItemProcessorAdapter.of(null)); } } 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 3508a950..6fbbb7e1 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 @@ -35,11 +35,14 @@ import reactor.core.publisher.Flux; +/** + * Covers the blocking reader contract over a Flux-backed stream delegate. + */ @SuppressWarnings("unchecked") class ItemStreamFluxReaderAdapterTest { @Test - void openShouldInvokeProperDelegateMethods() { + void openShouldInitializeFromDelegate() { ItemStreamFluxReaderDelegate delegate = mock(ItemStreamFluxReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamFluxReaderAdapter.of(delegate); @@ -50,7 +53,7 @@ void openShouldInvokeProperDelegateMethods() { } @Test - void readShouldReturnValuesFromDelegate() throws Exception { + void readShouldReturnAllSourceItems() throws Exception { List expected = List.of(1, 2, 3); ItemStreamFluxReaderDelegate delegate = mock(ItemStreamFluxReaderDelegate.class); when(delegate.readFlux(any())).thenAnswer($ -> Flux.fromIterable(expected)); @@ -67,7 +70,7 @@ void readShouldReturnValuesFromDelegate() throws Exception { } @Test - void readShouldThrowExceptionWhenNoOpenInvoked() { + void readShouldFailWhenAdapterIsNotOpened() { ItemStreamFluxReaderDelegate delegate = mock(ItemStreamFluxReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamFluxReaderAdapter.of(delegate); @@ -75,7 +78,7 @@ void readShouldThrowExceptionWhenNoOpenInvoked() { } @Test - void updateShouldInvokeProperDelegateMethod() { + void updateShouldForwardExecutionContextToDelegate() { ItemStreamFluxReaderDelegate delegate = mock(ItemStreamFluxReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamFluxReaderAdapter.of(delegate); @@ -85,7 +88,7 @@ void updateShouldInvokeProperDelegateMethod() { } @Test - void closeShouldInvokeProperDelegateMethod() { + void closeShouldNotifyDelegate() { ItemStreamFluxReaderDelegate delegate = mock(ItemStreamFluxReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamFluxReaderAdapter.of(delegate); @@ -96,7 +99,7 @@ void closeShouldInvokeProperDelegateMethod() { @SuppressWarnings({"ResultOfMethodCallIgnored", "ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegate() { assertThatThrownBy(() -> ItemStreamFluxReaderAdapter.of(null)); } } 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 2ccaabf8..a0bdec12 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 @@ -33,11 +33,14 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; +/** + * Covers the blocking reader contract over an Iterable-backed stream delegate. + */ @SuppressWarnings("unchecked") class ItemStreamIterableReaderAdapterTest { @Test - void openShouldInvokeProperDelegateMethods() { + void openShouldInitializeFromDelegate() { ItemStreamIterableReaderDelegate delegate = mock(ItemStreamIterableReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIterableReaderAdapter.of(delegate); @@ -48,7 +51,7 @@ void openShouldInvokeProperDelegateMethods() { } @Test - void readShouldReturnValuesFromDelegate() throws Exception { + void readShouldReturnAllSourceItems() throws Exception { List expected = List.of(1, 2, 3); ItemStreamIterableReaderDelegate delegate = mock(ItemStreamIterableReaderDelegate.class); when(delegate.readIterable(any())).thenAnswer($ -> expected); @@ -65,7 +68,7 @@ void readShouldReturnValuesFromDelegate() throws Exception { } @Test - void readShouldThrowExceptionWhenNoOpenInvoked() { + void readShouldFailWhenAdapterIsNotOpened() { ItemStreamIterableReaderDelegate delegate = mock(ItemStreamIterableReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIterableReaderAdapter.of(delegate); @@ -73,7 +76,7 @@ void readShouldThrowExceptionWhenNoOpenInvoked() { } @Test - void updateShouldInvokeProperDelegateMethod() { + void updateShouldForwardExecutionContextToDelegate() { ItemStreamIterableReaderDelegate delegate = mock(ItemStreamIterableReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIterableReaderAdapter.of(delegate); @@ -83,7 +86,7 @@ void updateShouldInvokeProperDelegateMethod() { } @Test - void closeShouldInvokeProperDelegateMethod() { + void closeShouldNotifyDelegate() { ItemStreamIterableReaderDelegate delegate = mock(ItemStreamIterableReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIterableReaderAdapter.of(delegate); @@ -94,7 +97,7 @@ void closeShouldInvokeProperDelegateMethod() { @SuppressWarnings({"ResultOfMethodCallIgnored", "ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegate() { assertThatThrownBy(() -> ItemStreamIterableReaderAdapter.of(null)); } } 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 87a737da..2280f0c9 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 @@ -33,11 +33,14 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; +/** + * Covers the blocking reader contract over an Iterator-backed stream delegate. + */ @SuppressWarnings("unchecked") class ItemStreamIteratorReaderAdapterTest { @Test - void openShouldInvokeProperDelegateMethods() { + void openShouldInitializeFromDelegate() { ItemStreamIteratorReaderDelegate delegate = mock(ItemStreamIteratorReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIteratorReaderAdapter.of(delegate); @@ -48,7 +51,7 @@ void openShouldInvokeProperDelegateMethods() { } @Test - void readShouldReturnValuesFromDelegate() throws Exception { + void readShouldReturnAllSourceItems() throws Exception { List expected = List.of(1, 2, 3); ItemStreamIteratorReaderDelegate delegate = mock(ItemStreamIteratorReaderDelegate.class); when(delegate.readIterator(any())).thenAnswer($ -> expected.iterator()); @@ -65,7 +68,7 @@ void readShouldReturnValuesFromDelegate() throws Exception { } @Test - void readShouldThrowExceptionWhenNoOpenInvoked() { + void readShouldFailWhenAdapterIsNotOpened() { ItemStreamIteratorReaderDelegate delegate = mock(ItemStreamIteratorReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIteratorReaderAdapter.of(delegate); @@ -73,7 +76,7 @@ void readShouldThrowExceptionWhenNoOpenInvoked() { } @Test - void updateShouldInvokeProperDelegateMethod() { + void updateShouldForwardExecutionContextToDelegate() { ItemStreamIteratorReaderDelegate delegate = mock(ItemStreamIteratorReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIteratorReaderAdapter.of(delegate); @@ -83,7 +86,7 @@ void updateShouldInvokeProperDelegateMethod() { } @Test - void closeShouldInvokeProperDelegateMethod() { + void closeShouldNotifyDelegate() { ItemStreamIteratorReaderDelegate delegate = mock(ItemStreamIteratorReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamIteratorReaderAdapter.of(delegate); @@ -94,7 +97,7 @@ void closeShouldInvokeProperDelegateMethod() { @SuppressWarnings({"ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegate() { assertThatThrownBy(() -> ItemStreamIteratorReaderAdapter.of(null)); } } 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 ccd8798d..e6a82df9 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 @@ -32,11 +32,14 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamReader; +/** + * Covers the blocking reader contract over a delegate that supplies one item per call. + */ @SuppressWarnings("unchecked") class ItemStreamSimpleReaderAdapterTest { @Test - void openShouldInvokeProperDelegateMethod() { + void openShouldNotifyDelegate() { ItemStreamSimpleReaderDelegate delegate = mock(ItemStreamSimpleReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamSimpleReaderAdapter.of(delegate); @@ -46,7 +49,7 @@ void openShouldInvokeProperDelegateMethod() { } @Test - void readShouldReturnValuesFromDelegate() throws Exception { + void readShouldReturnDelegateItem() throws Exception { Integer expected = ThreadLocalRandom.current().nextInt(); ItemStreamSimpleReaderDelegate delegate = mock(ItemStreamSimpleReaderDelegate.class); when(delegate.read()).thenReturn(expected); @@ -58,7 +61,7 @@ void readShouldReturnValuesFromDelegate() throws Exception { } @Test - void updateShouldInvokeProperDelegateMethod() { + void updateShouldForwardExecutionContextToDelegate() { ItemStreamSimpleReaderDelegate delegate = mock(ItemStreamSimpleReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamSimpleReaderAdapter.of(delegate); @@ -68,7 +71,7 @@ void updateShouldInvokeProperDelegateMethod() { } @Test - void closeShouldInvokeProperDelegateMethod() { + void closeShouldNotifyDelegate() { ItemStreamSimpleReaderDelegate delegate = mock(ItemStreamSimpleReaderDelegate.class); ItemStreamReader itemStreamReader = ItemStreamSimpleReaderAdapter.of(delegate); @@ -79,7 +82,7 @@ void closeShouldInvokeProperDelegateMethod() { @SuppressWarnings({"ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegate() { assertThatThrownBy(() -> ItemStreamSimpleReaderAdapter.of(null)); } } 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 cb210af4..91d129f6 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 @@ -29,11 +29,14 @@ import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamWriter; +/** + * Covers the stream lifecycle and chunk-writing contract exposed by the writer adapter. + */ @SuppressWarnings("unchecked") class ItemStreamWriterAdapterTest { @Test - void openShouldInvokeProperDelegateMethod() { + void openShouldNotifyDelegate() { ItemStreamWriterDelegate delegate = mock(ItemStreamWriterDelegate.class); ItemStreamWriter itemStreamWriterAdaptor = ItemStreamWriterAdapter.of(delegate); @@ -43,7 +46,7 @@ void openShouldInvokeProperDelegateMethod() { } @Test - void writeShouldInvokeProperDelegateMethod() throws Exception { + void writeShouldForwardChunkToDelegate() throws Exception { ItemStreamWriterDelegate delegate = mock(ItemStreamWriterDelegate.class); ItemStreamWriter itemStreamWriterAdaptor = ItemStreamWriterAdapter.of(delegate); @@ -53,7 +56,7 @@ void writeShouldInvokeProperDelegateMethod() throws Exception { } @Test - void updateShouldInvokeProperDelegateMethod() { + void updateShouldForwardExecutionContextToDelegate() { ItemStreamWriterDelegate delegate = mock(ItemStreamWriterDelegate.class); ItemStreamWriter itemStreamWriterAdaptor = ItemStreamWriterAdapter.of(delegate); @@ -63,7 +66,7 @@ void updateShouldInvokeProperDelegateMethod() { } @Test - void closeShouldInvokeProperDelegateMethod() { + void closeShouldNotifyDelegate() { ItemStreamWriterDelegate delegate = mock(ItemStreamWriterDelegate.class); ItemStreamWriter itemStreamWriterAdaptor = ItemStreamWriterAdapter.of(delegate); @@ -74,7 +77,7 @@ void closeShouldInvokeProperDelegateMethod() { @SuppressWarnings({"ConstantConditions"}) @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegate() { assertThatThrownBy(() -> ItemStreamWriterAdapter.of(null)); } } 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 fa40072a..daf06c55 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 @@ -35,11 +35,14 @@ import org.springframework.batch.test.MetaDataInstanceFactory; import org.springframework.batch.test.StepScopeTestUtils; +/** + * Covers delegate creation and reuse within an active Spring Batch step scope. + */ @SuppressWarnings("unchecked") class StepScopeItemStreamReaderTest { @Test - void openShouldInvokeProperDelegateMethod() throws Exception { + void openShouldDelegateToScopedReader() throws Exception { ItemStreamReader delegate = mock(ItemStreamReader.class); ItemStreamReader itemStreamReader = StepScopeItemStreamReader.of(() -> delegate); @@ -53,7 +56,7 @@ void openShouldInvokeProperDelegateMethod() throws Exception { } @Test - void readShouldReturnValueFromDelegate() throws Exception { + void readShouldReturnScopedDelegateItem() throws Exception { Integer expected = ThreadLocalRandom.current().nextInt(); ItemStreamReader delegate = mock(ItemStreamReader.class); when(delegate.read()).thenReturn(expected); @@ -66,7 +69,7 @@ void readShouldReturnValueFromDelegate() throws Exception { } @Test - void updateShouldInvokeProperDelegateMethod() throws Exception { + void updateShouldDelegateToScopedReader() throws Exception { ItemStreamReader delegate = mock(ItemStreamReader.class); ItemStreamReader itemStreamReader = StepScopeItemStreamReader.of(() -> delegate); @@ -80,7 +83,7 @@ void updateShouldInvokeProperDelegateMethod() throws Exception { } @Test - void closeShouldInvokeProperDelegateMethod() throws Exception { + void closeShouldDelegateToScopedReader() throws Exception { ItemStreamReader delegate = mock(ItemStreamReader.class); ItemStreamReader itemStreamReader = StepScopeItemStreamReader.of(() -> delegate); @@ -94,7 +97,7 @@ void closeShouldInvokeProperDelegateMethod() throws Exception { } @Test - void invokeShouldThrowExceptionWhenNoStepScope() { + void operationsShouldFailWhenCalledOutsideStepScope() { ItemStreamReader delegate = mock(ItemStreamReader.class); ItemStreamReader itemStreamReader = StepScopeItemStreamReader.of(() -> delegate); @@ -113,7 +116,7 @@ void invokeShouldThrowExceptionWhenNoStepScope() { } @Test - void createShouldThrowExceptionWhenPassingNull() { + void ofShouldRejectNullDelegateSupplier() { assertThatThrownBy(() -> StepScopeItemStreamReader.of(null)); } } From fd41377b027014cd5c1ccd7c350b39549985b55e Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 23:00:56 +0900 Subject: [PATCH 60/69] Cover optional delegate lifecycles Signed-off-by: Taeik Lim --- .../adapter/ItemStreamFluxReaderAdapterTest.java | 14 ++++++++++++++ .../ItemStreamIterableReaderAdapterTest.java | 14 ++++++++++++++ .../ItemStreamIteratorReaderAdapterTest.java | 14 ++++++++++++++ .../ItemStreamSimpleReaderAdapterTest.java | 14 ++++++++++++++ .../step/adapter/ItemStreamWriterAdapterTest.java | 15 +++++++++++++++ 5 files changed, 71 insertions(+) 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 6fbbb7e1..6cd80963 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 @@ -19,6 +19,7 @@ package com.navercorp.spring.batch.plus.step.adapter; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -97,6 +98,19 @@ void closeShouldNotifyDelegate() { verify(delegate, times(1)).onCloseRead(); } + @Test + void lifecycleShouldBeOptional() { + ItemStreamFluxReaderDelegate delegate = $ -> Flux.empty(); + ItemStreamReader itemStreamReader = ItemStreamFluxReaderAdapter.of(delegate); + ExecutionContext executionContext = new ExecutionContext(); + + assertThatCode(() -> { + itemStreamReader.open(executionContext); + itemStreamReader.update(executionContext); + itemStreamReader.close(); + }).doesNotThrowAnyException(); + } + @SuppressWarnings({"ResultOfMethodCallIgnored", "ConstantConditions"}) @Test void ofShouldRejectNullDelegate() { 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 a0bdec12..66022f1f 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 @@ -19,6 +19,7 @@ package com.navercorp.spring.batch.plus.step.adapter; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -95,6 +96,19 @@ void closeShouldNotifyDelegate() { verify(delegate, times(1)).onCloseRead(); } + @Test + void lifecycleShouldBeOptional() { + ItemStreamIterableReaderDelegate delegate = $ -> List.of(); + ItemStreamReader itemStreamReader = ItemStreamIterableReaderAdapter.of(delegate); + ExecutionContext executionContext = new ExecutionContext(); + + assertThatCode(() -> { + itemStreamReader.open(executionContext); + itemStreamReader.update(executionContext); + itemStreamReader.close(); + }).doesNotThrowAnyException(); + } + @SuppressWarnings({"ResultOfMethodCallIgnored", "ConstantConditions"}) @Test void ofShouldRejectNullDelegate() { 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 2280f0c9..bf248f25 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 @@ -19,6 +19,7 @@ package com.navercorp.spring.batch.plus.step.adapter; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -95,6 +96,19 @@ void closeShouldNotifyDelegate() { verify(delegate, times(1)).onCloseRead(); } + @Test + void lifecycleShouldBeOptional() { + ItemStreamIteratorReaderDelegate delegate = $ -> List.of().iterator(); + ItemStreamReader itemStreamReader = ItemStreamIteratorReaderAdapter.of(delegate); + ExecutionContext executionContext = new ExecutionContext(); + + assertThatCode(() -> { + itemStreamReader.open(executionContext); + itemStreamReader.update(executionContext); + itemStreamReader.close(); + }).doesNotThrowAnyException(); + } + @SuppressWarnings({"ConstantConditions"}) @Test void ofShouldRejectNullDelegate() { 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 e6a82df9..c8617ba6 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 @@ -18,6 +18,7 @@ package com.navercorp.spring.batch.plus.step.adapter; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -80,6 +81,19 @@ void closeShouldNotifyDelegate() { verify(delegate, times(1)).onCloseRead(); } + @Test + void lifecycleShouldBeOptional() { + ItemStreamSimpleReaderDelegate delegate = () -> null; + ItemStreamReader itemStreamReader = ItemStreamSimpleReaderAdapter.of(delegate); + ExecutionContext executionContext = new ExecutionContext(); + + assertThatCode(() -> { + itemStreamReader.open(executionContext); + itemStreamReader.update(executionContext); + itemStreamReader.close(); + }).doesNotThrowAnyException(); + } + @SuppressWarnings({"ConstantConditions"}) @Test void ofShouldRejectNullDelegate() { 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 91d129f6..5c880832 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 @@ -19,6 +19,7 @@ package com.navercorp.spring.batch.plus.step.adapter; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -75,6 +76,20 @@ void closeShouldNotifyDelegate() { verify(delegate, times(1)).onCloseWrite(); } + @Test + void lifecycleShouldBeOptional() { + ItemStreamWriterDelegate delegate = $ -> { + }; + ItemStreamWriter itemStreamWriter = ItemStreamWriterAdapter.of(delegate); + ExecutionContext executionContext = new ExecutionContext(); + + assertThatCode(() -> { + itemStreamWriter.open(executionContext); + itemStreamWriter.update(executionContext); + itemStreamWriter.close(); + }).doesNotThrowAnyException(); + } + @SuppressWarnings({"ConstantConditions"}) @Test void ofShouldRejectNullDelegate() { From ef7e9fead029de1b15da7627739e44c4651d8773 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 23:23:40 +0900 Subject: [PATCH 61/69] Cover flow initial step bean selection Signed-off-by: Taeik Lim --- ...obBuilderDslFlowCreationIntegrationTest.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt index 0eef983d..b1eef206 100644 --- a/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt +++ b/spring-batch-plus-kotlin/src/integrationTest/kotlin/com/navercorp/spring/batch/plus/kotlin/configuration/job/flow/JobBuilderDslFlowCreationIntegrationTest.kt @@ -157,6 +157,47 @@ internal class JobBuilderDslFlowCreationIntegrationTest { assertThat(testStep2CallCount).isEqualTo(1) } + @Test + fun flowShouldCreateFlowJobWhenInitialStepBeanNameIsProvided() { + // given + val context = AnnotationConfigApplicationContext(TestConfiguration::class.java) + val jobOperator = context.getBean() + val batch = context.getBean() + var testStepCallCount = 0 + val testStep = + batch { + step("testStep") { + tasklet( + { _, _ -> + ++testStepCallCount + RepeatStatus.FINISHED + }, + ResourcelessTransactionManager(), + ) + } + } + context.registerBean("testStep") { + testStep + } + + // when + val job = + batch { + job("testJob") { + flow("testFlow") { + stepBean("testStep") + } + } + } + val jobExecution = jobOperator.start(job, JobParameters()) + + // then + assertThat(job).isInstanceOf(FlowJob::class.java) + assertThat(jobExecution.status).isEqualTo(BatchStatus.COMPLETED) + assertThat(jobExecution.exitStatus.exitCode).isEqualTo(ExitStatus.COMPLETED.exitCode) + assertThat(testStepCallCount).isEqualTo(1) + } + @Test fun flowShouldCreateFlowJobWhenFlowInstancesAreProvided() { // given From 83f07ca211dfc421840b605c764a858527cceede Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sun, 6 Sep 2026 23:55:45 +0900 Subject: [PATCH 62/69] Polish adapter samples for Spring Batch 6 Signed-off-by: Taeik Lim --- .../spring/batch/plus/sample/flux/README.md | 8 ++++++++ .../plus/sample/flux/callback/SampleTasklet.kt | 2 +- .../plus/sample/flux/callback/TestJobConfig.kt | 5 +++-- .../flux/readerprocessor/SampleTasklet.kt | 2 +- .../flux/readerprocessor/TestJobConfig.kt | 3 ++- .../readerprocessorwriter/SampleTasklet.kt | 2 +- .../readerprocessorwriter/TestJobConfig.kt | 5 +++-- .../sample/flux/readerwriter/SampleTasklet.kt | 2 +- .../sample/flux/readerwriter/TestJobConfig.kt | 5 +++-- .../batch/plus/sample/iterable/README.md | 9 +++++++++ .../sample/iterable/callback/SampleTasklet.kt | 2 +- .../sample/iterable/callback/TestJobConfig.kt | 5 +++-- .../iterable/readerprocessor/SampleTasklet.kt | 2 +- .../iterable/readerprocessor/TestJobConfig.kt | 3 ++- .../readerprocessorwriter/SampleTasklet.kt | 2 +- .../readerprocessorwriter/TestJobConfig.kt | 5 +++-- .../iterable/readerwriter/SampleTasklet.kt | 2 +- .../iterable/readerwriter/TestJobConfig.kt | 5 +++-- .../batch/plus/sample/iterator/README.md | 9 +++++++++ .../sample/iterator/callback/SampleTasklet.kt | 2 +- .../sample/iterator/callback/TestJobConfig.kt | 5 +++-- .../iterator/readerprocessor/SampleTasklet.kt | 2 +- .../iterator/readerprocessor/TestJobConfig.kt | 3 ++- .../readerprocessorwriter/SampleTasklet.kt | 2 +- .../readerprocessorwriter/TestJobConfig.kt | 5 +++-- .../iterator/readerwriter/SampleTasklet.kt | 2 +- .../iterator/readerwriter/TestJobConfig.kt | 5 +++-- .../spring/batch/plus/sample/simple/README.md | 9 +++++++++ .../sample/simple/callback/SampleTasklet.kt | 2 +- .../sample/simple/callback/TestJobConfig.kt | 5 +++-- .../simple/readerprocessor/SampleTasklet.kt | 2 +- .../simple/readerprocessor/TestJobConfig.kt | 3 ++- .../readerprocessorwriter/SampleTasklet.kt | 2 +- .../readerprocessorwriter/TestJobConfig.kt | 5 +++-- .../simple/readerwriter/SampleTasklet.kt | 2 +- .../simple/readerwriter/TestJobConfig.kt | 5 +++-- .../spring/batch/plus/sample/flux/README.md | 8 ++++++++ .../flux/callback/SampleApplicationTest.java | 6 +++--- .../sample/flux/callback/SampleTasklet.java | 18 ++++++++---------- .../sample/flux/callback/TestJobConfig.java | 3 ++- .../readerprocessor/SampleApplicationTest.java | 6 +++--- .../flux/readerprocessor/SampleTasklet.java | 6 ++---- .../flux/readerprocessor/TestJobConfig.java | 3 ++- .../SampleApplicationTest.java | 6 +++--- .../readerprocessorwriter/SampleTasklet.java | 8 +++----- .../readerprocessorwriter/TestJobConfig.java | 3 ++- .../readerwriter/SampleApplicationTest.java | 6 +++--- .../flux/readerwriter/SampleTasklet.java | 6 ++---- .../flux/readerwriter/TestJobConfig.java | 3 ++- .../batch/plus/sample/iterable/README.md | 9 +++++++++ .../callback/SampleApplicationTest.java | 6 +++--- .../iterable/callback/SampleTasklet.java | 18 ++++++++---------- .../iterable/callback/TestJobConfig.java | 3 ++- .../readerprocessor/SampleApplicationTest.java | 6 +++--- .../readerprocessor/SampleTasklet.java | 6 ++---- .../readerprocessor/TestJobConfig.java | 3 ++- .../SampleApplicationTest.java | 6 +++--- .../readerprocessorwriter/SampleTasklet.java | 8 +++----- .../readerprocessorwriter/TestJobConfig.java | 3 ++- .../readerwriter/SampleApplicationTest.java | 6 +++--- .../iterable/readerwriter/SampleTasklet.java | 6 ++---- .../iterable/readerwriter/TestJobConfig.java | 3 ++- .../batch/plus/sample/iterator/README.md | 9 +++++++++ .../callback/SampleApplicationTest.java | 6 +++--- .../iterator/callback/SampleTasklet.java | 18 ++++++++---------- .../iterator/callback/TestJobConfig.java | 3 ++- .../readerprocessor/SampleApplicationTest.java | 6 +++--- .../readerprocessor/SampleTasklet.java | 6 ++---- .../readerprocessor/TestJobConfig.java | 3 ++- .../SampleApplicationTest.java | 6 +++--- .../readerprocessorwriter/SampleTasklet.java | 8 +++----- .../readerprocessorwriter/TestJobConfig.java | 3 ++- .../readerwriter/SampleApplicationTest.java | 6 +++--- .../iterator/readerwriter/SampleTasklet.java | 6 ++---- .../iterator/readerwriter/TestJobConfig.java | 3 ++- .../spring/batch/plus/sample/simple/README.md | 9 +++++++++ .../simple/callback/SampleApplicationTest.java | 6 +++--- .../sample/simple/callback/SampleTasklet.java | 15 +++++++-------- .../sample/simple/callback/TestJobConfig.java | 3 ++- .../readerprocessor/SampleApplicationTest.java | 6 +++--- .../simple/readerprocessor/SampleTasklet.java | 3 +-- .../simple/readerprocessor/TestJobConfig.java | 3 ++- .../SampleApplicationTest.java | 6 +++--- .../readerprocessorwriter/SampleTasklet.java | 5 ++--- .../readerprocessorwriter/TestJobConfig.java | 5 +++-- .../readerwriter/SampleApplicationTest.java | 6 +++--- .../simple/readerwriter/SampleTasklet.java | 3 +-- .../simple/readerwriter/TestJobConfig.java | 3 ++- 88 files changed, 267 insertions(+), 193 deletions(-) create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/README.md create mode 100644 spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/README.md diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/README.md new file mode 100644 index 00000000..02f0ac45 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/flux/README.md @@ -0,0 +1,8 @@ +# Flux Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces items as a `Flux`. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 4211468c..004ac1a0 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 @@ -29,7 +29,7 @@ import reactor.core.publisher.Flux @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamFluxReaderProcessorWriter { private var count = 0 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 e4c2c86b..6d533545 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.callback.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 bf313d85..c997f729 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 @@ -28,7 +28,7 @@ import reactor.core.publisher.Flux @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamFluxReaderProcessor { private var count = 0 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 7732e1d8..ba9b9db0 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 @@ -36,7 +36,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 b03f7d8b..e664f436 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 @@ -29,7 +29,7 @@ import reactor.core.publisher.Flux @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamFluxReaderProcessorWriter { private var count = 0 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 6b3d01e2..9c2cb02d 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 bc05e71b..e3254c73 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 @@ -29,7 +29,7 @@ import reactor.core.publisher.Flux @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamFluxReaderWriter { private var count = 0 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 8152a456..e7e9f720 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 @@ -32,11 +32,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.flux.readerwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/README.md new file mode 100644 index 00000000..694c7631 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterable/README.md @@ -0,0 +1,9 @@ +# Iterable Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces items as an + `Iterable`. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 15e92038..090c8a4a 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIterableReaderProcessorWriter { private var count = 0 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 a146d9a2..2b74bcc2 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.callback.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 ce87a17a..199fe8a4 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 @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIterableReaderProcessor { private var count = 0 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 c5fba493..37bc6fbc 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 @@ -36,7 +36,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 bb515f4c..dae95f9b 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIterableReaderProcessorWriter { private var count = 0 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 1af7a768..be2345a0 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.readerprocessorwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 c0170aec..4d8c625e 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIterableReaderWriter { private var count = 0 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 ca9b7c4a..c296deb2 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 @@ -32,11 +32,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterable.readerwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/README.md new file mode 100644 index 00000000..f6bc3d38 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/iterator/README.md @@ -0,0 +1,9 @@ +# Iterator Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces items as an + `Iterator`. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 405aa48c..f6e79ad4 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIteratorReaderProcessorWriter { private var count = 0 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 f4121e90..a4580934 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.callback.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 f8291329..30fef3b0 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 @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIteratorReaderProcessor { private var count = 0 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 0556652d..e1231b5b 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 @@ -36,7 +36,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 bb31cd17..10650abc 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIteratorReaderProcessorWriter { private var count = 0 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 1f5f5671..926c11fe 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.readerprocessorwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 f284c7b0..605a935b 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamIteratorReaderWriter { private var count = 0 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 51b24c52..c9d97fb0 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 @@ -32,11 +32,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.iterator.readerwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/README.md new file mode 100644 index 00000000..ec6d05d3 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/simple/README.md @@ -0,0 +1,9 @@ +# Simple Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces one item at a + time. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 ec113673..c77b5091 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 @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamSimpleReaderProcessorWriter { private var count = 0 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 9446a6e5..6c4e5c7d 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.callback.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 7d64b41b..ddbef77d 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 @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamSimpleReaderProcessor { private var count = 0 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 4c2a6299..d0c9346d 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 @@ -36,7 +36,8 @@ open class TestJobConfig( batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 3c827486..5c240d2c 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 @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamSimpleReaderProcessorWriter { private var count = 0 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 f67a4f93..f9ed7175 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 @@ -33,11 +33,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(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/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 f43870c6..858479b5 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 @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component @Component @StepScope open class SampleTasklet( - @Value("#{jobParameters['totalCount']}") private var totalCount: Long, + @param:Value("#{jobParameters['totalCount']}") private var totalCount: Long, ) : ItemStreamSimpleReaderWriter { private var count = 0 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 a9e7cb3b..7be4f8c3 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 @@ -32,11 +32,12 @@ open class TestJobConfig( private val transactionManager: PlatformTransactionManager, ) { @Bean - open fun testJob(sampleTasklet: com.navercorp.spring.batch.plus.sample.simple.readerwriter.SampleTasklet): Job = + open fun testJob(sampleTasklet: SampleTasklet): Job = batch { job("testJob") { step("testStep") { - chunk(3, transactionManager) { + chunk(3) { + transactionManager(transactionManager) reader(sampleTasklet.asItemStreamReader()) writer(sampleTasklet.asItemStreamWriter()) } diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/README.md new file mode 100644 index 00000000..02f0ac45 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/flux/README.md @@ -0,0 +1,8 @@ +# Flux Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces items as a `Flux`. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 0ca69d3b..dadb7e81 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 6554230c..fec235d9 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 @@ -22,7 +22,6 @@ 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; import reactor.core.publisher.Flux; @@ -39,13 +38,12 @@ public class SampleTasklet implements ItemStreamFluxReaderProcessorWriter readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return Flux.generate(sink -> { if (count < totalCount) { @@ -58,7 +56,7 @@ public Flux readFlux(@NonNull ExecutionContext executionConte } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { System.out.println("onUpdateRead"); } @@ -68,24 +66,24 @@ public void onCloseRead() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { System.out.println("onOpenWrite"); } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { System.out.println("onUpdateWrite"); - executionContext.putString("samplekey", "samplevlaue"); + executionContext.putString("samplekey", "samplevalue"); } @Override 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 df47010d..5b64ec5f 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 2ebcd96c..f249ae5e 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 86ab461e..72ab47e6 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 @@ -21,7 +21,6 @@ import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; -import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; @@ -37,9 +36,8 @@ class SampleTasklet implements ItemStreamFluxReaderProcessor { private int count = 0; - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return Flux.generate(sink -> { if (count < totalCount) { @@ -52,7 +50,7 @@ public Flux readFlux(@NonNull ExecutionContext executionConte } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } } 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 ebfb5865..ee828edc 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(chunk -> System.out.println(chunk.getItems())) 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 65537f4b..bcd10806 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 e0410cd3..4bb0f35f 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 @@ -22,7 +22,6 @@ 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; import reactor.core.publisher.Flux; @@ -38,9 +37,8 @@ class SampleTasklet implements ItemStreamFluxReaderProcessorWriter readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return Flux.generate(sink -> { if (count < totalCount) { @@ -53,12 +51,12 @@ public Flux readFlux(@NonNull ExecutionContext executionConte } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 de9bc5bd..51aeafda 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 25aa00dd..2364c5a1 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 816ed0d4..ccbe2c05 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 @@ -22,7 +22,6 @@ 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; import reactor.core.publisher.Flux; @@ -38,9 +37,8 @@ class SampleTasklet implements ItemStreamFluxReaderWriter { private int count = 0; - @NonNull @Override - public Flux readFlux(@NonNull ExecutionContext executionContext) { + public Flux readFlux(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return Flux.generate(sink -> { if (count < totalCount) { @@ -53,7 +51,7 @@ public Flux readFlux(@NonNull ExecutionContext executionConte } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 43b8c65a..7cc46ab9 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) .build() diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/README.md new file mode 100644 index 00000000..694c7631 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterable/README.md @@ -0,0 +1,9 @@ +# Iterable Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces items as an + `Iterable`. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 514e0f34..e47b3169 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 76781bda..dd30a9c7 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 @@ -24,7 +24,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessorWriter; @@ -39,13 +38,12 @@ public class SampleTasklet implements ItemStreamIterableReaderProcessorWriter readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return () -> new Iterator<>() { @Override @@ -61,7 +59,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { System.out.println("onUpdateRead"); } @@ -71,24 +69,24 @@ public void onCloseRead() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { System.out.println("onOpenWrite"); } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { System.out.println("onUpdateWrite"); - executionContext.putString("samplekey", "samplevlaue"); + executionContext.putString("samplekey", "samplevalue"); } @Override 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 52a7c60c..756bb06a 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 27156ad8..96c06164 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 bfef6a4b..4cceea1c 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 @@ -23,7 +23,6 @@ import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; -import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessor; @@ -37,9 +36,8 @@ class SampleTasklet implements ItemStreamIterableReaderProcessor readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return () -> new Iterator<>() { @Override @@ -55,7 +53,7 @@ public Integer next() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } } 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 c135dd07..1d9f4610 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(chunk -> System.out.println(chunk.getItems())) 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 19eb7cf8..5cbace7c 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 e753a623..6adafc5a 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 @@ -24,7 +24,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessorWriter; @@ -38,9 +37,8 @@ class SampleTasklet implements ItemStreamIterableReaderProcessorWriter readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return () -> new Iterator<>() { @Override @@ -56,12 +54,12 @@ public Integer next() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 ae40c645..81dfa5ae 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 f82b91e3..601a63ec 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 0f6d1de3..004ed7cd 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 @@ -24,7 +24,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderWriter; @@ -38,9 +37,8 @@ class SampleTasklet implements ItemStreamIterableReaderWriter { private int count = 0; - @NonNull @Override - public Iterable readIterable(@NonNull ExecutionContext executionContext) { + public Iterable readIterable(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return () -> new Iterator<>() { @Override @@ -56,7 +54,7 @@ public Integer next() { } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 5b21cea5..f965c556 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) .build() diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/README.md new file mode 100644 index 00000000..f6bc3d38 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/iterator/README.md @@ -0,0 +1,9 @@ +# Iterator Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces items as an + `Iterator`. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 3c2a47aa..58ee139c 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 1538329e..68608834 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 @@ -24,7 +24,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderProcessorWriter; @@ -39,13 +38,12 @@ public class SampleTasklet implements ItemStreamIteratorReaderProcessorWriter readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return new Iterator<>() { @Override @@ -61,7 +59,7 @@ public Integer next() { } @Override - public void onUpdateRead(@NonNull ExecutionContext executionContext) { + public void onUpdateRead(ExecutionContext executionContext) { System.out.println("onUpdateRead"); } @@ -71,24 +69,24 @@ public void onCloseRead() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void onOpenWrite(@NonNull ExecutionContext executionContext) { + public void onOpenWrite(ExecutionContext executionContext) { System.out.println("onOpenWrite"); } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { System.out.println("onUpdateWrite"); - executionContext.putString("samplekey", "samplevlaue"); + executionContext.putString("samplekey", "samplevalue"); } @Override 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 faf5f942..1d903172 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 dbee6355..b5a781d1 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 13ebf972..d8889a5f 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 @@ -23,7 +23,6 @@ import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.beans.factory.annotation.Value; -import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderProcessor; @@ -37,9 +36,8 @@ class SampleTasklet implements ItemStreamIteratorReaderProcessor readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return new Iterator<>() { @Override @@ -55,7 +53,7 @@ public Integer next() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } } 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 e11d8eed..c2bf2cd1 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(chunk -> System.out.println(chunk.getItems())) 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 27e78cea..bcc22b75 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 0e4583b0..3c1e1dd4 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 @@ -24,7 +24,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderProcessorWriter; @@ -38,9 +37,8 @@ class SampleTasklet implements ItemStreamIteratorReaderProcessorWriter readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return new Iterator<>() { @Override @@ -56,12 +54,12 @@ public Integer next() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 5dd14205..8b13a891 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 ead90946..828a3b01 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 55ffa776..8c370dc0 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 @@ -24,7 +24,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderWriter; @@ -38,9 +37,8 @@ class SampleTasklet implements ItemStreamIteratorReaderWriter { private int count = 0; - @NonNull @Override - public Iterator readIterator(@NonNull ExecutionContext executionContext) { + public Iterator readIterator(ExecutionContext executionContext) { System.out.println("totalCount: " + totalCount); return new Iterator<>() { @Override @@ -56,7 +54,7 @@ public Integer next() { } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 ca8778fb..d611b4f5 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) .build() diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/README.md b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/README.md new file mode 100644 index 00000000..ec6d05d3 --- /dev/null +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/README.md @@ -0,0 +1,9 @@ +# Simple Reader Adapter Samples + +## Invariants + +- Samples should cover a single delegate whose reader produces one item at a + time. +- Every supported combination of reader, processor, and writer roles should have + a runnable sample. +- Lifecycle callback support should have a runnable sample. 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 5f5c65b3..1d3f8a0c 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 7504071d..6307f3ff 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 @@ -22,7 +22,6 @@ 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; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderProcessorWriter; @@ -37,7 +36,7 @@ public class SampleTasklet implements ItemStreamSimpleReaderProcessorWriter chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } @Override - public void onUpdateWrite(@NonNull ExecutionContext executionContext) { + public void onUpdateWrite(ExecutionContext executionContext) { System.out.println("onUpdateWrite"); - executionContext.putString("samplekey", "samplevlaue"); + executionContext.putString("samplekey", "samplevalue"); } @Override 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 b689920e..1f79ae47 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 @@ -42,7 +42,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 673a5b2f..5480c890 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); diff --git a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.java b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.java index c91c95e1..882419a3 100644 --- a/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.java +++ b/spring-batch-plus-sample/single-class-reader-processor-writer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/simple/readerprocessor/SampleTasklet.java @@ -20,7 +20,6 @@ import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.beans.factory.annotation.Value; -import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderProcessor; @@ -44,7 +43,7 @@ public Integer read() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } } 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 ddd2011a..37469c16 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(chunk -> System.out.println(chunk.getItems())) 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 864ed133..13488bb9 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 e45ec7d4..16cd3f07 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 @@ -21,7 +21,6 @@ import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.beans.factory.annotation.Value; -import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderProcessorWriter; @@ -45,12 +44,12 @@ public Integer read() { } @Override - public String process(@NonNull Integer item) { + public String process(Integer item) { return "'" + item.toString() + "'"; } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 3efb2b69..0a5c4037 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 @@ -35,14 +35,15 @@ public class TestJobConfig { @Bean public Job testJob( - com.navercorp.spring.batch.plus.sample.simple.readerprocessorwriter.SampleTasklet sampleTasklet, + SampleTasklet sampleTasklet, JobRepository jobRepository, PlatformTransactionManager transactionManager ) { return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .processor(itemProcessor(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) 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 2e16ae2b..dd02c3e8 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 @@ -24,7 +24,7 @@ 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.batch.core.launch.JobOperator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -34,13 +34,13 @@ public class SampleApplicationTest { @Test void run() throws Exception { ApplicationContext applicationContext = SpringApplication.run(SampleApplicationTest.class); - JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class); + JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean("testJob", Job.class); JobParameters jobParameters = new JobParametersBuilder() .addLong("totalCount", 20L) .toJobParameters(); - JobExecution jobExecution = jobLauncher.run(job, jobParameters); + JobExecution jobExecution = jobOperator.start(job, jobParameters); assert BatchStatus.COMPLETED.equals(jobExecution.getStatus()); System.out.printf("%s%n", jobExecution); 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 25195a98..702e7c86 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 @@ -21,7 +21,6 @@ import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.beans.factory.annotation.Value; -import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderWriter; @@ -45,7 +44,7 @@ public Integer read() { } @Override - public void write(@NonNull Chunk chunk) { + public void write(Chunk chunk) { System.out.println(chunk.getItems()); } } 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 34e7e5a3..fa25327f 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 @@ -41,7 +41,8 @@ public Job testJob( return new JobBuilder("testJob", jobRepository) .start( new StepBuilder("testStep", jobRepository) - .chunk(3, transactionManager) + .chunk(3) + .transactionManager(transactionManager) .reader(itemStreamReader(sampleTasklet)) .writer(itemStreamWriter(sampleTasklet)) .build() From 47104ed0dfe302e4364a5998ca70b81ce8d30916 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 18:38:15 +0900 Subject: [PATCH 63/69] Polish ClearRunIdIncrementer Signed-off-by: Taeik Lim --- .../ClearRunIdIncrementerIntegrationTest.java | 163 ++++++++++++++++++ .../batch/plus/job/ClearRunIdIncrementer.java | 18 +- .../plus/job/ClearRunIdIncrementerTest.java | 14 +- 3 files changed, 181 insertions(+), 14 deletions(-) create mode 100644 spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerIntegrationTest.java diff --git a/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerIntegrationTest.java b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerIntegrationTest.java new file mode 100644 index 00000000..83569847 --- /dev/null +++ b/spring-batch-plus/src/integrationTest/java/com/navercorp/spring/batch/plus/job/ClearRunIdIncrementerIntegrationTest.java @@ -0,0 +1,163 @@ +/* + * 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.job; + +import static org.assertj.core.api.Assertions.*; + +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +import javax.sql.DataSource; + +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.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +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.job.parameters.JobParametersIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; +import org.springframework.batch.core.launch.JobOperator; +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.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.repeat.RepeatStatus; +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; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.transaction.TransactionManager; + +/** + * Covers the next-instance parameter propagation difference between the standard and clearing incrementers. + */ +class ClearRunIdIncrementerIntegrationTest { + + @Test + void startNextInstanceShouldCarryPreviousNonRunIdParametersForwardWhenRunIdIncrementerIsUsed() { + long previousRunId = ThreadLocalRandom.current().nextLong(1, Long.MAX_VALUE); + String previousParameterName = UUID.randomUUID().toString(); + String previousParameterValue = UUID.randomUUID().toString(); + JobParametersIncrementer incrementer = new RunIdIncrementer(); + + JobExecution jobExecution = startNextInstanceAfterCompletedExecution(incrementer, previousRunId, + previousParameterName, previousParameterValue); + + JobParameters actual = jobExecution.getJobParameters(); + + assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); + assertThat(actual.getLong("run.id")).isEqualTo(previousRunId + 1); + assertThat(actual.getString(previousParameterName)).isEqualTo(previousParameterValue); + assertThat(actual.parameters()).hasSize(2); + } + + @Test + void startNextInstanceShouldDiscardPreviousNonRunIdParametersWhenClearRunIdIncrementerIsUsed() { + long previousRunId = ThreadLocalRandom.current().nextLong(1, Long.MAX_VALUE); + String previousParameterName = UUID.randomUUID().toString(); + String previousParameterValue = UUID.randomUUID().toString(); + JobParametersIncrementer incrementer = ClearRunIdIncrementer.create(); + + JobExecution jobExecution = startNextInstanceAfterCompletedExecution(incrementer, previousRunId, + previousParameterName, previousParameterValue); + + JobParameters actual = jobExecution.getJobParameters(); + + assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED); + assertThat(actual.getLong("run.id")).isEqualTo(previousRunId + 1); + assertThat(actual.parameters()).hasSize(1); + } + + private JobExecution startNextInstanceAfterCompletedExecution( + JobParametersIncrementer incrementer, + long previousRunId, + String previousParameterName, + String previousParameterValue + ) { + try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { + context.register(BatchConfiguration.class); + context.refresh(); + JobRepository jobRepository = context.getBean(JobRepository.class); + Step step = new StepBuilder("testStep", jobRepository) + .tasklet( + (contribution, chunkContext) -> RepeatStatus.FINISHED, + new ResourcelessTransactionManager() + ) + .build(); + Job job = new JobBuilder("testJob", jobRepository) + .incrementer(incrementer) + .start(step) + .build(); + JobOperator jobOperator = context.getBean(JobOperator.class); + JobParameters previousParameters = new JobParametersBuilder() + .addLong("run.id", previousRunId) + .addString(previousParameterName, previousParameterValue) + .toJobParameters(); + seedCompletedJobExecution(jobRepository, job, previousParameters); + + return jobOperator.startNextInstance(job); + } + } + + private void seedCompletedJobExecution( + JobRepository jobRepository, + Job job, + JobParameters jobParameters + ) { + JobInstance jobInstance = jobRepository.createJobInstance(job.getName(), jobParameters); + JobExecution jobExecution = jobRepository.createJobExecution( + jobInstance, + jobParameters, + new ExecutionContext() + ); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setExitStatus(ExitStatus.COMPLETED); + jobRepository.update(jobExecution); + } + + @EnableBatchProcessing + @EnableJdbcJobRepository( + dataSourceRef = "metadataDataSource", + transactionManagerRef = "metadataTransactionManager" + ) + private static class BatchConfiguration { + + @Bean + TransactionManager metadataTransactionManager() { + return new DataSourceTransactionManager(metadataDataSource()); + } + + @Bean + DataSource metadataDataSource() { + return new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .addScript("/org/springframework/batch/core/schema-h2.sql") + .generateUniqueName(true) + .build(); + } + } +} 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 f05d71bf..5e49ed6f 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 @@ -27,9 +27,11 @@ import org.springframework.batch.core.job.parameters.RunIdIncrementer; /** - * Alternative to {@link RunIdIncrementer}. - * RunIdIncrementer returns not only a new run id but also all previous job parameters. - * It makes unintended job parameters for a job. + * A {@link JobParametersIncrementer} that increments a run-id parameter while + * discarding every other parameter from the supplied {@link JobParameters}. + * + *

Use this instead of {@link RunIdIncrementer} when parameters from the previous job + * execution must not propagate to the next job instance. * * @since 0.1.0 */ @@ -38,18 +40,18 @@ public class ClearRunIdIncrementer implements JobParametersIncrementer { protected static final String DEFAULT_RUN_ID = "run.id"; /** - * Create a new ClearRunIdIncrementer with {@link #DEFAULT_RUN_ID}. - * @return a new ClearRunIdIncrementer instance + * Creates an incrementer using {@link #DEFAULT_RUN_ID} as the run-id parameter name. + * @return a new incrementer */ public static JobParametersIncrementer create() { return create(DEFAULT_RUN_ID); } /** - * Create a new ClearRunIdIncrementer with custom run id. + * Creates an incrementer using the given run-id parameter name. * - * @param runId a run id - * @return a new ClearRunIdIncrementer instance + * @param runId the run-id parameter name + * @return a new incrementer */ public static JobParametersIncrementer create(String runId) { return new ClearRunIdIncrementer(runId); 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 df5880fd..1ff54546 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 @@ -18,8 +18,7 @@ package com.navercorp.spring.batch.plus.job; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.*; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; @@ -29,10 +28,13 @@ import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.core.job.parameters.JobParametersIncrementer; +/** + * Covers the parameter transformation contract independently of Spring Batch job execution. + */ class ClearRunIdIncrementerTest { @Test - void getNextShouldReturnOneWhenNoPreviousValue() { + void getNextShouldInitializeRunIdToOneWhenPreviousValueDoesNotExist() { JobParametersIncrementer clearRunIdIncrementer = ClearRunIdIncrementer.create(); JobParameters jobParameters = clearRunIdIncrementer.getNext(new JobParameters()); @@ -41,7 +43,7 @@ void getNextShouldReturnOneWhenNoPreviousValue() { } @Test - void getNextShouldReturnPlusOneWhenPreviousExists() { + void getNextShouldIncrementRunIdWhenPreviousValueExists() { JobParametersIncrementer clearRunIdIncrementer = ClearRunIdIncrementer.create(); long previousId = ThreadLocalRandom.current().nextLong(); @@ -54,7 +56,7 @@ void getNextShouldReturnPlusOneWhenPreviousExists() { } @Test - void getNextShouldReturnPlusOneWhenPreviousExistsUsingCustomRunId() { + void getNextShouldUseConfiguredRunIdParameterName() { String runId = UUID.randomUUID().toString(); JobParametersIncrementer clearRunIdIncrementer = ClearRunIdIncrementer.create(runId); @@ -70,7 +72,7 @@ void getNextShouldReturnPlusOneWhenPreviousExistsUsingCustomRunId() { @SuppressWarnings("DataFlowIssue") @Test - void createShouldThrowExceptionWhenPassingNull() { + void createShouldThrowExceptionWhenRunIdParameterNameIsNull() { assertThatThrownBy(() -> ClearRunIdIncrementer.create(null)); } } From c4f5f1bd1c9feace3d1917a93b6e459e7f84130b Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 19:20:18 +0900 Subject: [PATCH 64/69] Polish ClearRunIdIncrementer samples Signed-off-by: Taeik Lim --- .../spring/batch/plus/sample/clear/README.md | 8 +++++++ .../batch/plus/sample/clearwithid/README.md | 8 +++++++ .../spring/batch/plus/sample/clear/README.md | 8 +++++++ .../batch/plus/sample/clearwithid/README.md | 8 +++++++ .../batch/plus/sample/comparison/README.md | 12 ++++++++++ .../comparison/bad/SampleApplicationTest.java | 22 +++---------------- .../good/SampleApplicationTest.java | 22 +++---------------- 7 files changed, 50 insertions(+), 38 deletions(-) create mode 100644 spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/README.md create mode 100644 spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/README.md create mode 100644 spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/README.md create mode 100644 spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/README.md create mode 100644 spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/README.md diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/README.md b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/README.md new file mode 100644 index 00000000..8b54f435 --- /dev/null +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clear/README.md @@ -0,0 +1,8 @@ +# Default Run ID Samples + +## Invariants + +- Samples should configure `ClearRunIdIncrementer` with its default `run.id` + parameter name. +- Consecutive job instances should demonstrate initialization and incrementation + of that parameter. diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/README.md b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/README.md new file mode 100644 index 00000000..a10c3c74 --- /dev/null +++ b/spring-batch-plus-sample/clear-run-id-incrementer-kotlin-sample/src/test/kotlin/com/navercorp/spring/batch/plus/sample/clearwithid/README.md @@ -0,0 +1,8 @@ +# Custom Run ID Samples + +## Invariants + +- Samples should configure `ClearRunIdIncrementer` with an explicit run-id + parameter name. +- Consecutive job instances should demonstrate initialization and incrementation + of the configured parameter. diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/README.md b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/README.md new file mode 100644 index 00000000..8b54f435 --- /dev/null +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clear/README.md @@ -0,0 +1,8 @@ +# Default Run ID Samples + +## Invariants + +- Samples should configure `ClearRunIdIncrementer` with its default `run.id` + parameter name. +- Consecutive job instances should demonstrate initialization and incrementation + of that parameter. diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/README.md b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/README.md new file mode 100644 index 00000000..a10c3c74 --- /dev/null +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/clearwithid/README.md @@ -0,0 +1,8 @@ +# Custom Run ID Samples + +## Invariants + +- Samples should configure `ClearRunIdIncrementer` with an explicit run-id + parameter name. +- Consecutive job instances should demonstrate initialization and incrementation + of the configured parameter. diff --git a/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/README.md b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/README.md new file mode 100644 index 00000000..0f4b0ae7 --- /dev/null +++ b/spring-batch-plus-sample/clear-run-id-incrementer-sample/src/test/java/com/navercorp/spring/batch/plus/sample/comparison/README.md @@ -0,0 +1,12 @@ +# Run ID Incrementer Comparison Samples + +## Invariants + +- Comparison samples should start from equivalent completed job metadata + containing both run-id and non-run-id parameters. +- The [`bad`](bad) sample should show `RunIdIncrementer` carrying previous + non-run-id parameters forward. +- The [`good`](good) sample should show `ClearRunIdIncrementer` discarding those + parameters. +- This comparison represents legacy or externally populated metadata rather + than metadata produced by a clean Spring Batch 6 launch sequence. 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 73f95ca7..3925560b 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 @@ -36,20 +36,8 @@ 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. + * Demonstrates how {@link org.springframework.batch.core.job.parameters.RunIdIncrementer} + * carries legacy non-run-id parameters into the next job instance. */ @SpringBootApplication public class SampleApplicationTest { @@ -60,8 +48,7 @@ void run() throws Exception { JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean(Job.class); - // 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. + // Direct repository setup reproduces metadata that the normal launch path cannot create. JobParameters legacyParams = new JobParametersBuilder() .addString("stringValue", "1") .addString("longValue", "10") @@ -74,14 +61,11 @@ void run() throws Exception { legacyExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(legacyExecution); - // Launch the next instance: incrementer.getNext(legacyParams) is invoked under the hood. JobExecution nextExecution = jobOperator.startNextInstance(job); assert BatchStatus.COMPLETED.equals(nextExecution.getStatus()); JobParameters nextParams = nextExecution.getJobParameters(); - // 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")); 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 f4518d04..c52707fd 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 @@ -36,21 +36,8 @@ 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. + * Demonstrates how {@link com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer} + * discards legacy non-run-id parameters from the next job instance. */ @SpringBootApplication public class SampleApplicationTest { @@ -61,8 +48,7 @@ void run() throws Exception { JobOperator jobOperator = applicationContext.getBean(JobOperator.class); Job job = applicationContext.getBean(Job.class); - // Same legacy seed as the "bad" scenario for an apples-to-apples comparison. - // See the class-level Javadoc for the migration context. + // Direct repository setup reproduces metadata that the normal launch path cannot create. JobParameters legacyParams = new JobParametersBuilder() .addString("stringValue", "1") .addString("longValue", "10") @@ -80,8 +66,6 @@ void run() throws Exception { assert BatchStatus.COMPLETED.equals(nextExecution.getStatus()); JobParameters nextParams = nextExecution.getJobParameters(); - // 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; From 8a85a47f5985d1e488c97d1d9ba58dd75e0460d8 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 19:53:38 +0900 Subject: [PATCH 65/69] Standardize Java logger declarations Signed-off-by: Taeik Lim --- .../ItemStreamReaderProcessorWriterIntegrationTest.java | 4 ++-- .../adapter/ItemStreamReaderWriterIntegrationTest.java | 3 +-- .../batch/plus/item/adapter/StepScopeItemStreamReader.java | 7 +++---- .../job/metadata/CheckMaxJobInstanceIdToDeleteTasklet.java | 3 +-- .../batch/plus/job/metadata/DeleteMetadataTasklet.java | 3 +-- .../batch/plus/step/adapter/StepScopeItemStreamReader.java | 7 +++---- .../batch/plus/job/metadata/TestJobRepositoryConfig.java | 3 +-- 7 files changed, 12 insertions(+), 18 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 c74a50e4..94b86cf1 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 @@ -56,11 +56,11 @@ // note: it's deprecated. Do not change it. @SuppressWarnings({"unchecked", "deprecation"}) class ItemStreamReaderProcessorWriterIntegrationTest { + protected static final Logger logger = + LoggerFactory.getLogger(ItemStreamReaderProcessorWriterIntegrationTest.class); private static final int TEST_REPEAT_COUNT = 5; - private static final Logger logger = LoggerFactory.getLogger(ItemStreamReaderProcessorWriterIntegrationTest.class); - private static int onOpenReadCallCount = 0; private static int readContextCallCount = 0; private static int onUpdateReadCallCount = 0; 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 b636bceb..0fc9ba4c 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 @@ -56,11 +56,10 @@ // note: it's deprecated. Do not change it. @SuppressWarnings({"unchecked", "deprecation"}) class ItemStreamReaderWriterIntegrationTest { + protected static final Logger logger = LoggerFactory.getLogger(ItemStreamReaderWriterIntegrationTest.class); private static final int TEST_REPEAT_COUNT = 5; - private static final Logger logger = LoggerFactory.getLogger(ItemStreamReaderWriterIntegrationTest.class); - private static int onOpenReadCallCount = 0; private static int readContextCallCount = 0; private static int onUpdateReadCallCount = 0; 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 515debd4..4aaf01e1 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 @@ -40,6 +40,9 @@ */ @Deprecated public class StepScopeItemStreamReader implements ItemStreamReader { + protected static final Logger logger = getLogger(StepScopeItemStreamReader.class); + + protected static final String SCOPE_KEY = "StepScopeItemStreamReader@delegate"; /** * Create an {@link ItemStreamReader} instance bound to {@link StepScope}. @@ -53,10 +56,6 @@ public static ItemStreamReader of(Supplier> delegateS return new StepScopeItemStreamReader<>(delegateSupplier); } - protected static final String SCOPE_KEY = "StepScopeItemStreamReader@delegate"; - - protected final Logger logger = getLogger(StepScopeItemStreamReader.class); - protected final Supplier> delegateSupplier; protected StepScopeItemStreamReader(Supplier> readerGenerator) { 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 534a5f84..bbb8283e 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 @@ -41,13 +41,12 @@ * A tasklet to check metadata of job instances to delete. */ class CheckMaxJobInstanceIdToDeleteTasklet implements Tasklet, StepExecutionListener { + protected static final Logger logger = LoggerFactory.getLogger(CheckMaxJobInstanceIdToDeleteTasklet.class); static final String MAX_ID_KEY = "maxJobInstanceId"; static final ExitStatus EMPTY = new ExitStatus("EMPTY"); - private final Logger logger = LoggerFactory.getLogger(CheckMaxJobInstanceIdToDeleteTasklet.class); - private final JobMetadataDao dao; private final String baseDateParameterName; 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 861ac96b..014b770a 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 @@ -36,13 +36,12 @@ * This tasklet must be executed after execution of {@link CheckMaxJobInstanceIdToDeleteTasklet} */ class DeleteMetadataTasklet implements Tasklet, StepExecutionListener { + protected static final Logger logger = LoggerFactory.getLogger(DeleteMetadataTasklet.class); static final String LOW_ID_KEY = "lowJobInstanceId"; static final int DELETION_RANGE_LENGTH = 100; - private final Logger logger = LoggerFactory.getLogger(DeleteMetadataTasklet.class); - private final JobMetadataDao dao; private final String dryRunParameterName; 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 584eb089..c4a666da 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 @@ -38,6 +38,9 @@ * @since 1.1.0 */ public class StepScopeItemStreamReader implements ItemStreamReader { + protected static final Logger logger = getLogger(StepScopeItemStreamReader.class); + + protected static final String SCOPE_KEY = "StepScopeItemStreamReader@delegate"; /** * Create an {@link ItemStreamReader} instance bound to {@link StepScope}. @@ -51,10 +54,6 @@ public static ItemStreamReader of(Supplier> delegateS return new StepScopeItemStreamReader<>(delegateSupplier); } - protected static final String SCOPE_KEY = "StepScopeItemStreamReader@delegate"; - - protected final Logger logger = getLogger(StepScopeItemStreamReader.class); - protected final Supplier> delegateSupplier; protected StepScopeItemStreamReader(Supplier> readerGenerator) { 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 864bb2f9..3a01be4f 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 @@ -44,8 +44,7 @@ import org.springframework.util.StringUtils; public class TestJobRepositoryConfig { - - private final Logger logger = LoggerFactory.getLogger(TestJobRepositoryConfig.class); + protected static final Logger logger = LoggerFactory.getLogger(TestJobRepositoryConfig.class); @Bean DataSource dataSource(String tablePrefix) throws Exception { From 9a765a15bb040ca84a7a9b75f306be9142587335 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 20:26:01 +0900 Subject: [PATCH 66/69] Open metadata job internals for extension Signed-off-by: Taeik Lim --- .../CheckMaxJobInstanceIdToDeleteTasklet.java | 6 +++--- .../job/metadata/DeleteMetadataJobBuilder.java | 18 +++++++++--------- .../job/metadata/DeleteMetadataTasklet.java | 14 +++++++------- .../plus/job/metadata/JobMetadataDao.java | 16 ++++++++-------- 4 files changed, 27 insertions(+), 27 deletions(-) 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 bbb8283e..2327f20f 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 @@ -47,11 +47,11 @@ class CheckMaxJobInstanceIdToDeleteTasklet implements Tasklet, StepExecutionList static final ExitStatus EMPTY = new ExitStatus("EMPTY"); - private final JobMetadataDao dao; + protected final JobMetadataDao dao; - private final String baseDateParameterName; + protected final String baseDateParameterName; - private final DateTimeFormatter baseDateFormatter; + protected final DateTimeFormatter baseDateFormatter; CheckMaxJobInstanceIdToDeleteTasklet( JobMetadataDao dao, 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 cc2c10d0..5d71c835 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 @@ -43,19 +43,19 @@ * @since 0.2.0 */ public class DeleteMetadataJobBuilder { - private final JobRepository jobRepository; + protected final JobRepository jobRepository; - private final DataSource dataSource; + protected final DataSource dataSource; - private String name = "deleteMetadataJob"; + protected String name = "deleteMetadataJob"; - private String tablePrefix = AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX; + protected String tablePrefix = AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX; - private String baseDateParameterName = "baseDate"; + protected String baseDateParameterName = "baseDate"; - private DateTimeFormatter baseDateFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd"); + protected DateTimeFormatter baseDateFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd"); - private String dryRunParameterName = "dryRun"; + protected String dryRunParameterName = "dryRun"; /** * @param jobRepository the target job repository to delete old metadata. @@ -143,7 +143,7 @@ public Job build() { .build(); } - private Step buildCheckStep(JobMetadataDao dao) { + protected Step buildCheckStep(JobMetadataDao dao) { CheckMaxJobInstanceIdToDeleteTasklet tasklet = new CheckMaxJobInstanceIdToDeleteTasklet( dao, this.baseDateParameterName, @@ -158,7 +158,7 @@ private Step buildCheckStep(JobMetadataDao dao) { .build(); } - private Step buildDeleteStep(JobMetadataDao dao) { + protected Step buildDeleteStep(JobMetadataDao dao) { DeleteMetadataTasklet tasklet = new DeleteMetadataTasklet( dao, this.dryRunParameterName 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 014b770a..08df88a5 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 @@ -42,10 +42,10 @@ class DeleteMetadataTasklet implements Tasklet, StepExecutionListener { static final int DELETION_RANGE_LENGTH = 100; - private final JobMetadataDao dao; + protected final JobMetadataDao dao; - private final String dryRunParameterName; - private long maxJobInstanceId; + protected final String dryRunParameterName; + protected long maxJobInstanceId; DeleteMetadataTasklet(JobMetadataDao dao, String dryRunParameterName) { this.dao = dao; @@ -91,24 +91,24 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon return RepeatStatus.CONTINUABLE; } - private void putLowJobInstanceId(StepExecution stepExecution, long lowJobInstanceId) { + protected void putLowJobInstanceId(StepExecution stepExecution, long lowJobInstanceId) { ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); stepExecutionContext.put(LOW_ID_KEY, lowJobInstanceId); } - private long getLowJobInstanceId(StepExecution stepExecution) { + protected long getLowJobInstanceId(StepExecution stepExecution) { ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); return stepExecutionContext.getLong(LOW_ID_KEY); } - private boolean getDryRunParameter(StepExecution stepExecution) { + protected boolean getDryRunParameter(StepExecution stepExecution) { JobParameters jobParameters = stepExecution.getJobParameters(); return Optional.ofNullable(jobParameters.getString(this.dryRunParameterName)) .map(Boolean::parseBoolean) .orElse(false); } - private int deleteJobMetadata(long lowJobInstanceId, long highJobInstanceId) { + protected int deleteJobMetadata(long lowJobInstanceId, long highJobInstanceId) { dao.deleteStepExecutionContextsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); dao.deleteStepExecutionsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); dao.deleteJobExecutionContextsByJobInstanceIdRange(lowJobInstanceId, highJobInstanceId); diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java index b9d612d1..ad47facc 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java @@ -31,21 +31,21 @@ */ class JobMetadataDao extends AbstractJdbcBatchMetadataDao { - private final String selectMaxJobInstanceId; + protected final String selectMaxJobInstanceId; - private final String selectMinJobInstanceId; + protected final String selectMinJobInstanceId; - private final String deleteJobInstances; + protected final String deleteJobInstances; - private final String deleteJobExecutions; + protected final String deleteJobExecutions; - private final String deleteJobExecutionParams; + protected final String deleteJobExecutionParams; - private final String deleteJobExecutionContexts; + protected final String deleteJobExecutionContexts; - private final String deleteStepExecutions; + protected final String deleteStepExecutions; - private final String deleteStepExecutionContexts; + protected final String deleteStepExecutionContexts; JobMetadataDao(DataSource dataSource, String tablePrefix) { setJdbcTemplate(new JdbcTemplate(dataSource)); From 3a1ccd183855f58543c658891a1a9ad5727ca687 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 21:06:15 +0900 Subject: [PATCH 67/69] Fix Kotlin module Javadoc generation Signed-off-by: Taeik Lim --- spring-batch-plus-kotlin/build.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-batch-plus-kotlin/build.gradle.kts b/spring-batch-plus-kotlin/build.gradle.kts index bcab002f..e8f0614e 100644 --- a/spring-batch-plus-kotlin/build.gradle.kts +++ b/spring-batch-plus-kotlin/build.gradle.kts @@ -4,6 +4,11 @@ plugins { id("spring.batch.plus.maven-publish-conventions") } +tasks.javadoc { + // Java sources only bridge Kotlin compiler limitations and expose no public API to document. + exclude("**/*.java") +} + dependencies { api(project(":spring-batch-plus")) From 3634fe01e7aa85109c5ae069bfe96f87f6840e0e Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 21:58:38 +0900 Subject: [PATCH 68/69] Polish metadata deletion job Signed-off-by: Taeik Lim --- .../CheckMaxJobInstanceIdToDeleteTasklet.java | 2 +- .../metadata/DeleteMetadataJobBuilder.java | 13 ++++---- .../job/metadata/DeleteMetadataTasklet.java | 26 ++++++++++------ .../plus/job/metadata/JobMetadataDao.java | 30 ++++++++++++------- .../plus/job/metadata/JobMetadataDaoTest.java | 13 +++----- 5 files changed, 49 insertions(+), 35 deletions(-) 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 2327f20f..e439e579 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 @@ -71,7 +71,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon LocalDate baseDate = LocalDate.parse(baseDateStr, baseDateFormatter); Optional maxJobInstanceId = this.dao.selectMaxJobInstanceIdLessThanCreateTime(baseDate); - if (!maxJobInstanceId.isPresent()) { + if (maxJobInstanceId.isEmpty()) { logger.info("There is no record of job instance executed before {}. No need to delete metadata", baseDate); return RepeatStatus.FINISHED; } 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 5d71c835..a2fe21d6 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 @@ -43,6 +43,10 @@ * @since 0.2.0 */ public class DeleteMetadataJobBuilder { + protected static final String CHECK_MAX_JOB_INSTANCE_ID_STEP_NAME = "checkMaxJobInstanceId"; + + protected static final String DELETE_METADATA_STEP_NAME = "deleteMetadata"; + protected final JobRepository jobRepository; protected final DataSource dataSource; @@ -123,13 +127,12 @@ public DeleteMetadataJobBuilder dryRunParameterName(String dryRunParameterName) * @return a job to delete old metadata. */ public Job build() { - DefaultJobParametersValidator validator = new DefaultJobParametersValidator(); validator.setRequiredKeys(new String[] {this.baseDateParameterName}); JobMetadataDao dao = new JobMetadataDao(this.dataSource, this.tablePrefix); Step checkStep = this.buildCheckStep(dao); - + Step deleteStep = buildDeleteStep(dao); return new JobBuilder(this.name, this.jobRepository) .validator(validator) .start(checkStep) @@ -138,7 +141,7 @@ public Job build() { .end() .from(checkStep) - .next(buildDeleteStep(dao)) + .next(deleteStep) .end() .build(); } @@ -151,7 +154,7 @@ protected Step buildCheckStep(JobMetadataDao dao) { ); TransactionAttribute noTransaction = new DefaultTransactionAttribute(Propagation.NOT_SUPPORTED.value()); - return new StepBuilder("checkMaxJobInstanceId", this.jobRepository) + return new StepBuilder(CHECK_MAX_JOB_INSTANCE_ID_STEP_NAME, this.jobRepository) .tasklet(tasklet, new ResourcelessTransactionManager()) .transactionAttribute(noTransaction) .listener(tasklet) @@ -164,7 +167,7 @@ protected Step buildDeleteStep(JobMetadataDao dao) { this.dryRunParameterName ); PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource); - return new StepBuilder("deleteMetadata", this.jobRepository) + return new StepBuilder(DELETE_METADATA_STEP_NAME, this.jobRepository) .tasklet(tasklet, transactionManager) .listener(tasklet) .build(); 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 08df88a5..01e89970 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 @@ -56,21 +56,31 @@ class DeleteMetadataTasklet implements Tasklet, StepExecutionListener { public void beforeStep(StepExecution stepExecution) { ExecutionContext jobExecutionContext = stepExecution.getJobExecution().getExecutionContext(); this.maxJobInstanceId = jobExecutionContext.getLong(CheckMaxJobInstanceIdToDeleteTasklet.MAX_ID_KEY); - long minJobInstanceId = this.dao.selectMinJobInstanceId(); ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); - if (stepExecutionContext.containsKey(LOW_ID_KEY)) { // in case of restart + // Preserve the persisted lower bound when restarting the step. + if (stepExecutionContext.containsKey(LOW_ID_KEY)) { return; } - putLowJobInstanceId(stepExecution, minJobInstanceId); + Optional minJobInstanceId = this.dao.selectMinJobInstanceId(); + if (minJobInstanceId.isEmpty()) { + return; + } + + putLowJobInstanceId(stepExecutionContext, minJobInstanceId.get()); } @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { StepExecution stepExecution = contribution.getStepExecution(); + ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); + if (!stepExecutionContext.containsKey(LOW_ID_KEY)) { + logger.info("No job instances found. Skipping metadata deletion"); + return RepeatStatus.FINISHED; + } - long lowJobInstanceId = getLowJobInstanceId(stepExecution); + long lowJobInstanceId = getLowJobInstanceId(stepExecutionContext); long highJobInstanceId = Math.min(lowJobInstanceId + DELETION_RANGE_LENGTH - 1, maxJobInstanceId); boolean dryRun = getDryRunParameter(stepExecution); @@ -86,18 +96,16 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon if (nextLowJobInstanceId > this.maxJobInstanceId) { return RepeatStatus.FINISHED; } - putLowJobInstanceId(stepExecution, nextLowJobInstanceId); + putLowJobInstanceId(stepExecutionContext, nextLowJobInstanceId); return RepeatStatus.CONTINUABLE; } - protected void putLowJobInstanceId(StepExecution stepExecution, long lowJobInstanceId) { - ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); + protected void putLowJobInstanceId(ExecutionContext stepExecutionContext, long lowJobInstanceId) { stepExecutionContext.put(LOW_ID_KEY, lowJobInstanceId); } - protected long getLowJobInstanceId(StepExecution stepExecution) { - ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); + protected long getLowJobInstanceId(ExecutionContext stepExecutionContext) { return stepExecutionContext.getLong(LOW_ID_KEY); } diff --git a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java index ad47facc..564c4702 100644 --- a/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java +++ b/spring-batch-plus/src/main/java/com/navercorp/spring/batch/plus/job/metadata/JobMetadataDao.java @@ -19,11 +19,13 @@ package com.navercorp.spring.batch.plus.job.metadata; import java.time.LocalDate; +import java.util.Objects; import java.util.Optional; import javax.sql.DataSource; import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; /** @@ -62,36 +64,42 @@ class JobMetadataDao extends AbstractJdbcBatchMetadataDao { } Optional selectMaxJobInstanceIdLessThanCreateTime(LocalDate createTime) { - return Optional.ofNullable( - getJdbcTemplate().queryForObject(selectMaxJobInstanceId, Long.class, createTime) - ); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return Optional.ofNullable(jdbcTemplate.queryForObject(selectMaxJobInstanceId, Long.class, createTime)); } - Long selectMinJobInstanceId() { - return getJdbcTemplate().queryForObject(selectMinJobInstanceId, Long.class); + Optional selectMinJobInstanceId() { + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return Optional.ofNullable(jdbcTemplate.queryForObject(selectMinJobInstanceId, Long.class)); } int deleteJobInstancesByJobInstanceIdRange(long lowJobInstanceId, long highJobInstanceId) { - return getJdbcTemplate().update(deleteJobInstances, lowJobInstanceId, highJobInstanceId); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return jdbcTemplate.update(deleteJobInstances, lowJobInstanceId, highJobInstanceId); } int deleteJobExecutionsByJobInstanceIdRange(long lowJobInstanceId, long highJobInstanceId) { - return getJdbcTemplate().update(deleteJobExecutions, lowJobInstanceId, highJobInstanceId); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return jdbcTemplate.update(deleteJobExecutions, lowJobInstanceId, highJobInstanceId); } int deleteJobExecutionParamsByJobInstanceIdRange(long lowJobInstanceId, long highJobInstanceId) { - return getJdbcTemplate().update(deleteJobExecutionParams, lowJobInstanceId, highJobInstanceId); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return jdbcTemplate.update(deleteJobExecutionParams, lowJobInstanceId, highJobInstanceId); } int deleteJobExecutionContextsByJobInstanceIdRange(long lowJobInstanceId, long highJobInstanceId) { - return getJdbcTemplate().update(deleteJobExecutionContexts, lowJobInstanceId, highJobInstanceId); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return jdbcTemplate.update(deleteJobExecutionContexts, lowJobInstanceId, highJobInstanceId); } int deleteStepExecutionsByJobInstanceIdRange(long lowJobInstanceId, long highJobInstanceId) { - return getJdbcTemplate().update(deleteStepExecutions, lowJobInstanceId, highJobInstanceId); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return jdbcTemplate.update(deleteStepExecutions, lowJobInstanceId, highJobInstanceId); } int deleteStepExecutionContextsByJobInstanceIdRange(long lowJobInstanceId, long highJobInstanceId) { - return getJdbcTemplate().update(deleteStepExecutionContexts, lowJobInstanceId, highJobInstanceId); + JdbcOperations jdbcTemplate = Objects.requireNonNull(getJdbcTemplate(), "JdbcOperations must not be null"); + return jdbcTemplate.update(deleteStepExecutionContexts, lowJobInstanceId, highJobInstanceId); } } 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 eafdaa2d..a449d4e8 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 @@ -18,12 +18,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; +import static com.navercorp.spring.batch.plus.job.metadata.MetadataTestSupports.*; +import static org.assertj.core.api.Assertions.*; import java.time.LocalDate; import java.util.Optional; @@ -33,7 +29,6 @@ import org.springframework.batch.core.job.JobExecution; import org.springframework.batch.core.job.JobInstance; 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; @@ -92,10 +87,10 @@ void testSelectMinJobInstanceId() { jobRepository.createJobInstance("testJob2", buildJobParams()); // when - Long minJobInstanceId = dao.selectMinJobInstanceId(); + Optional minJobInstanceId = dao.selectMinJobInstanceId(); // then - assertThat(minJobInstanceId).isEqualTo(jobInstance1.getId()); + assertThat(minJobInstanceId).hasValue(jobInstance1.getId()); } @Test From 84a8d7e6ba8c55e5a3d24f1ce03efe80b66addeb Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Mon, 7 Sep 2026 23:26:31 +0900 Subject: [PATCH 69/69] Hold deletion upper bound in step execution context The upper bound was kept in a mutable instance field seeded by beforeStep, so the two bounds execute needs lived in different places and the tasklet carried state between callbacks. Store it in the step execution context next to the lower bound, with protected accessors matching the existing ones, leaving the tasklet stateless. Signed-off-by: Taeik Lim --- .../job/metadata/DeleteMetadataTasklet.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 01e89970..6a5cda34 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 @@ -45,7 +45,6 @@ class DeleteMetadataTasklet implements Tasklet, StepExecutionListener { protected final JobMetadataDao dao; protected final String dryRunParameterName; - protected long maxJobInstanceId; DeleteMetadataTasklet(JobMetadataDao dao, String dryRunParameterName) { this.dao = dao; @@ -55,9 +54,10 @@ class DeleteMetadataTasklet implements Tasklet, StepExecutionListener { @Override public void beforeStep(StepExecution stepExecution) { ExecutionContext jobExecutionContext = stepExecution.getJobExecution().getExecutionContext(); - this.maxJobInstanceId = jobExecutionContext.getLong(CheckMaxJobInstanceIdToDeleteTasklet.MAX_ID_KEY); - ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); + long maxJobInstanceId = jobExecutionContext.getLong(CheckMaxJobInstanceIdToDeleteTasklet.MAX_ID_KEY); + putMaxJobInstanceId(stepExecutionContext, maxJobInstanceId); + // Preserve the persisted lower bound when restarting the step. if (stepExecutionContext.containsKey(LOW_ID_KEY)) { return; @@ -81,6 +81,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon } long lowJobInstanceId = getLowJobInstanceId(stepExecutionContext); + long maxJobInstanceId = getMaxJobInstanceId(stepExecutionContext); long highJobInstanceId = Math.min(lowJobInstanceId + DELETION_RANGE_LENGTH - 1, maxJobInstanceId); boolean dryRun = getDryRunParameter(stepExecution); @@ -93,7 +94,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon } long nextLowJobInstanceId = highJobInstanceId + 1; - if (nextLowJobInstanceId > this.maxJobInstanceId) { + if (nextLowJobInstanceId > maxJobInstanceId) { return RepeatStatus.FINISHED; } putLowJobInstanceId(stepExecutionContext, nextLowJobInstanceId); @@ -109,6 +110,14 @@ protected long getLowJobInstanceId(ExecutionContext stepExecutionContext) { return stepExecutionContext.getLong(LOW_ID_KEY); } + protected void putMaxJobInstanceId(ExecutionContext stepExecutionContext, long maxJobInstanceId) { + stepExecutionContext.put(CheckMaxJobInstanceIdToDeleteTasklet.MAX_ID_KEY, maxJobInstanceId); + } + + protected long getMaxJobInstanceId(ExecutionContext stepExecutionContext) { + return stepExecutionContext.getLong(CheckMaxJobInstanceIdToDeleteTasklet.MAX_ID_KEY); + } + protected boolean getDryRunParameter(StepExecution stepExecution) { JobParameters jobParameters = stepExecution.getJobParameters(); return Optional.ofNullable(jobParameters.getString(this.dryRunParameterName))