From 167f3c427da468816bad0d68aaea7ce2d59f2dbf Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Tue, 4 Jul 2023 19:03:18 +0200 Subject: [PATCH] Remove usage of raw parametrized types --- .../batch/core/JobParametersBuilder.java | 16 +++++----- .../batch/core/JobParametersTests.java | 32 +++++++++---------- ...stractExecutionContextSerializerTests.java | 12 +++---- .../dao/JdbcJobExecutionDaoTests.java | 2 +- .../core/scope/context/ChunkContextTests.java | 4 +-- .../item/avro/support/AvroTestFixtures.java | 6 ++-- ...hunkFaultTolerantStepIntegrationTests.java | 4 +-- ...FaultTolerantStepJdbcIntegrationTests.java | 4 +-- ...kFaultTolerantStepJmsIntegrationTests.java | 6 ++-- .../RemoteChunkStepIntegrationTests.java | 4 +-- .../batch/test/JobLauncherTestUtils.java | 4 +-- .../batch/test/JobRepositoryTestUtils.java | 2 +- .../batch/test/StepRunner.java | 2 +- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java index cc230128f..3450f4894 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java @@ -105,7 +105,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addString(String key, @NonNull String parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, String.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, String.class, identifying)); return this; } @@ -128,7 +128,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addDate(String key, @NonNull Date parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, Date.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, Date.class, identifying)); return this; } @@ -151,7 +151,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addLocalDate(String key, @NonNull LocalDate parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, LocalDate.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, LocalDate.class, identifying)); return this; } @@ -174,7 +174,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addLocalTime(String key, @NonNull LocalTime parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, LocalTime.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, LocalTime.class, identifying)); return this; } @@ -197,7 +197,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addLocalDateTime(String key, @NonNull LocalDateTime parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, LocalDateTime.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, LocalDateTime.class, identifying)); return this; } @@ -220,7 +220,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addLong(String key, @NonNull Long parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, Long.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, Long.class, identifying)); return this; } @@ -243,7 +243,7 @@ public class JobParametersBuilder { * @return a reference to this object. */ public JobParametersBuilder addDouble(String key, @NonNull Double parameter, boolean identifying) { - this.parameterMap.put(key, new JobParameter(parameter, Double.class, identifying)); + this.parameterMap.put(key, new JobParameter<>(parameter, Double.class, identifying)); return this; } @@ -293,7 +293,7 @@ public class JobParametersBuilder { * @since 5.0 */ public JobParametersBuilder addJobParameter(String name, T value, Class type, boolean identifying) { - return addJobParameter(name, new JobParameter(value, type, identifying)); + return addJobParameter(name, new JobParameter<>(value, type, identifying)); } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java index 2445c00a9..b3a4b310d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java @@ -54,14 +54,14 @@ class JobParametersTests { private JobParameters getNewParameters() { Map> parameterMap = new HashMap<>(); - parameterMap.put("string.key1", new JobParameter("value1", String.class, true)); - parameterMap.put("string.key2", new JobParameter("value2", String.class, true)); - parameterMap.put("long.key1", new JobParameter(1L, Long.class, true)); - parameterMap.put("long.key2", new JobParameter(2L, Long.class, true)); - parameterMap.put("double.key1", new JobParameter(1.1, Double.class, true)); - parameterMap.put("double.key2", new JobParameter(2.2, Double.class, true)); - parameterMap.put("date.key1", new JobParameter(date1, Date.class, true)); - parameterMap.put("date.key2", new JobParameter(date2, Date.class, true)); + parameterMap.put("string.key1", new JobParameter<>("value1", String.class, true)); + parameterMap.put("string.key2", new JobParameter<>("value2", String.class, true)); + parameterMap.put("long.key1", new JobParameter<>(1L, Long.class, true)); + parameterMap.put("long.key2", new JobParameter<>(2L, Long.class, true)); + parameterMap.put("double.key1", new JobParameter<>(1.1, Double.class, true)); + parameterMap.put("double.key2", new JobParameter<>(2.2, Double.class, true)); + parameterMap.put("date.key1", new JobParameter<>(date1, Date.class, true)); + parameterMap.put("date.key2", new JobParameter<>(date2, Date.class, true)); return new JobParameters(parameterMap); } @@ -148,14 +148,14 @@ class JobParametersTests { String string1 = stringBuilder.toString(); Map> parameterMap = new HashMap<>(); - parameterMap.put("string.key2", new JobParameter("value2", String.class, true)); - parameterMap.put("string.key1", new JobParameter("value1", String.class, true)); - parameterMap.put("long.key2", new JobParameter(2L, Long.class, true)); - parameterMap.put("long.key1", new JobParameter(1L, Long.class, true)); - parameterMap.put("double.key2", new JobParameter(2.2, Double.class, true)); - parameterMap.put("double.key1", new JobParameter(1.1, Double.class, true)); - parameterMap.put("date.key2", new JobParameter(date2, Date.class, true)); - parameterMap.put("date.key1", new JobParameter(date1, Date.class, true)); + parameterMap.put("string.key2", new JobParameter<>("value2", String.class, true)); + parameterMap.put("string.key1", new JobParameter<>("value1", String.class, true)); + parameterMap.put("long.key2", new JobParameter<>(2L, Long.class, true)); + parameterMap.put("long.key1", new JobParameter<>(1L, Long.class, true)); + parameterMap.put("double.key2", new JobParameter<>(2.2, Double.class, true)); + parameterMap.put("double.key1", new JobParameter<>(1.1, Double.class, true)); + parameterMap.put("date.key2", new JobParameter<>(date2, Date.class, true)); + parameterMap.put("date.key1", new JobParameter<>(date1, Date.class, true)); JobParameters testProps = new JobParameters(parameterMap); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java index 9fdeba1d4..c427cfffe 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java @@ -65,7 +65,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeStringJobParameter() throws Exception { Map m1 = new HashMap<>(); - m1.put("name", new JobParameter("foo", String.class)); + m1.put("name", new JobParameter<>("foo", String.class)); Map m2 = serializationRoundTrip(m1); @@ -75,7 +75,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeDateJobParameter() throws Exception { Map m1 = new HashMap<>(); - m1.put("birthDate", new JobParameter(new Date(123456790123L), Date.class)); + m1.put("birthDate", new JobParameter<>(new Date(123456790123L), Date.class)); Map m2 = serializationRoundTrip(m1); @@ -85,7 +85,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeDoubleJobParameter() throws Exception { Map m1 = new HashMap<>(); - m1.put("weight", new JobParameter(80.5D, Double.class)); + m1.put("weight", new JobParameter<>(80.5D, Double.class)); Map m2 = serializationRoundTrip(m1); @@ -95,7 +95,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeLongJobParameter() throws Exception { Map m1 = new HashMap<>(); - m1.put("age", new JobParameter(20L, Long.class)); + m1.put("age", new JobParameter<>(20L, Long.class)); Map m2 = serializationRoundTrip(m1); @@ -105,7 +105,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeNonIdentifyingJobParameter() throws Exception { Map m1 = new HashMap<>(); - m1.put("name", new JobParameter("foo", String.class, false)); + m1.put("name", new JobParameter<>("foo", String.class, false)); Map m2 = serializationRoundTrip(m1); @@ -115,7 +115,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeJobParameters() throws Exception { Map> jobParametersMap = new HashMap<>(); - jobParametersMap.put("paramName", new JobParameter("paramValue", String.class)); + jobParametersMap.put("paramName", new JobParameter<>("paramValue", String.class)); Map m1 = new HashMap<>(); m1.put("params", new JobParameters(jobParametersMap)); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java index 510fcfada..67ceaeb5e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java @@ -96,7 +96,7 @@ public class JdbcJobExecutionDaoTests extends AbstractJobExecutionDaoTests { void testDeleteJobExecutionParameters() { // given Map> parameters = new HashMap<>(); - parameters.put("string-param", new JobParameter("value", String.class)); + parameters.put("string-param", new JobParameter<>("value", String.class)); JobExecution execution = new JobExecution(jobInstance, new JobParameters(parameters)); dao.saveJobExecution(execution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java index b5e91763a..6024ce059 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.batch.core.JobParameters; class ChunkContextTests { private final ChunkContext context = new ChunkContext(new StepContext(new JobExecution(new JobInstance(0L, "job"), - 1L, new JobParameters(Collections.singletonMap("foo", new JobParameter("bar", String.class)))) + 1L, new JobParameters(Collections.singletonMap("foo", new JobParameter<>("bar", String.class)))) .createStepExecution("foo"))); @Test diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/support/AvroTestFixtures.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/support/AvroTestFixtures.java index 8bfd2615c..f7f39ecfa 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/support/AvroTestFixtures.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/support/AvroTestFixtures.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ public abstract class AvroTestFixtures { } protected Chunk genericAvroGeneratedUsers() { - return new Chunk(this.avroGeneratedUsers.getItems().stream().map(u -> { + return new Chunk<>(this.avroGeneratedUsers.getItems().stream().map(u -> { GenericData.Record avroRecord; avroRecord = new GenericData.Record(u.getSchema()); avroRecord.put("name", u.getName()); @@ -106,7 +106,7 @@ public abstract class AvroTestFixtures { } protected Chunk genericPlainOldUsers() { - return new Chunk( + return new Chunk<>( this.plainOldUsers.getItems().stream().map(PlainOldUser::toGenericRecord).collect(Collectors.toList())); } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests.java index 9eea995a3..088e3964b 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests.java @@ -57,7 +57,7 @@ class RemoteChunkFaultTolerantStepIntegrationTests { @Test void testFailedStep() throws Exception { JobExecution jobExecution = jobLauncher.run(job, new JobParameters( - Collections.singletonMap("item.three", new JobParameter("unsupported", String.class)))); + Collections.singletonMap("item.three", new JobParameter<>("unsupported", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); @@ -68,7 +68,7 @@ class RemoteChunkFaultTolerantStepIntegrationTests { @Test void testFailedStepOnError() throws Exception { JobExecution jobExecution = jobLauncher.run(job, - new JobParameters(Collections.singletonMap("item.three", new JobParameter("error", String.class)))); + new JobParameters(Collections.singletonMap("item.three", new JobParameter<>("error", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests.java index 85d85aab9..6c30b3803 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests.java @@ -62,7 +62,7 @@ class RemoteChunkFaultTolerantStepJdbcIntegrationTests { @DirtiesContext void testFailedStep() throws Exception { JobExecution jobExecution = jobLauncher.run(job, new JobParameters( - Collections.singletonMap("item.three", new JobParameter("unsupported", String.class)))); + Collections.singletonMap("item.three", new JobParameter<>("unsupported", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); @@ -74,7 +74,7 @@ class RemoteChunkFaultTolerantStepJdbcIntegrationTests { @DirtiesContext void testFailedStepOnError() throws Exception { JobExecution jobExecution = jobLauncher.run(job, - new JobParameters(Collections.singletonMap("item.three", new JobParameter("error", String.class)))); + new JobParameters(Collections.singletonMap("item.three", new JobParameter<>("error", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests.java index ec51e6e77..9595f1e27 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ class RemoteChunkFaultTolerantStepJmsIntegrationTests { @Test void testFailedStep() throws Exception { JobExecution jobExecution = jobLauncher.run(job, new JobParameters( - Collections.singletonMap("item.three", new JobParameter("unsupported", String.class)))); + Collections.singletonMap("item.three", new JobParameter<>("unsupported", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); @@ -64,7 +64,7 @@ class RemoteChunkFaultTolerantStepJmsIntegrationTests { @Test void testFailedStepOnError() throws Exception { JobExecution jobExecution = jobLauncher.run(job, - new JobParameters(Collections.singletonMap("item.three", new JobParameter("error", String.class)))); + new JobParameters(Collections.singletonMap("item.three", new JobParameter<>("error", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests.java index 4595f2630..7b6198e0e 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ class RemoteChunkStepIntegrationTests { @Test void testFailedStep() throws Exception { JobExecution jobExecution = jobLauncher.run(job, - new JobParameters(Collections.singletonMap("item.three", new JobParameter("fail", String.class)))); + new JobParameters(Collections.singletonMap("item.three", new JobParameter<>("fail", String.class)))); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(9, stepExecution.getReadCount()); diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java index bc8b39f8e..27a0aea8a 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -152,7 +152,7 @@ public class JobLauncherTestUtils { */ public JobParameters getUniqueJobParameters() { Map> parameters = new HashMap<>(); - parameters.put("random", new JobParameter(this.secureRandom.nextLong(), Long.class)); + parameters.put("random", new JobParameter<>(this.secureRandom.nextLong(), Long.class)); return new JobParameters(parameters); } diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java index 86391a472..d6a7b0732 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java @@ -50,7 +50,7 @@ public class JobRepositoryTestUtils { @Override public JobParameters getNext(@Nullable JobParameters parameters) { - return new JobParameters(Collections.singletonMap("count", new JobParameter(count++, Long.class))); + return new JobParameters(Collections.singletonMap("count", new JobParameter<>(count++, Long.class))); } }; diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java index 42a596add..3badf0b32 100755 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java @@ -178,7 +178,7 @@ public class StepRunner { */ private JobParameters makeUniqueJobParameters() { Map> parameters = new HashMap<>(); - parameters.put("timestamp", new JobParameter(new Date().getTime(), Long.class)); + parameters.put("timestamp", new JobParameter<>(new Date().getTime(), Long.class)); return new JobParameters(parameters); }