Remove double brace initialization

Remove double brace collection initialization as
it is considered bad practice.
This commit is contained in:
Philippe Marschall
2021-03-13 20:40:09 +01:00
committed by Mahmoud Ben Hassine
parent f15edd414a
commit 3d0cb90590
8 changed files with 38 additions and 101 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2021 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.
@@ -17,6 +17,7 @@ package org.springframework.batch.core.jsr.configuration.support;
import static org.junit.Assert.assertEquals;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -65,25 +66,19 @@ public class BatchPropertyContextTests {
stepArtifactProperties.setProperty("readerProperty1", "readerProperty1value");
stepArtifactProperties.setProperty("readerProperty2", "readerProperty2value");
this.stepArtifactProperties.put("step1", new HashMap<String, Properties>() {{
put("reader", stepArtifactProperties);
}});
this.stepArtifactProperties.put("step1", Collections.singletonMap("reader", stepArtifactProperties));
final Properties partitionProperties = new Properties();
partitionProperties.setProperty("writerProperty1", "writerProperty1valuePartition0");
partitionProperties.setProperty("writerProperty2", "writerProperty2valuePartition0");
this.partitionProperties.put("step2:partition0", new HashMap<String, Properties>() {{
put("writer", partitionProperties);
}});
this.partitionProperties.put("step2:partition0", Collections.singletonMap("writer", partitionProperties));
final Properties partitionStepProperties = new Properties();
partitionStepProperties.setProperty("writerProperty1Step", "writerProperty1");
partitionStepProperties.setProperty("writerProperty2Step", "writerProperty2");
this.partitionProperties.put("step2", new HashMap<String, Properties>() {{
put("writer", partitionStepProperties);
}});
this.partitionProperties.put("step2", Collections.singletonMap("writer", partitionStepProperties));
}
@Test

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.batch.core.step.builder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
@@ -59,7 +59,6 @@ import static org.junit.Assert.assertEquals;
* @author Parikshit Dutta
*
*/
@SuppressWarnings("serial")
public class StepBuilderTests {
@Test
@@ -181,15 +180,10 @@ public class StepBuilderTests {
jobRepository.add(execution);
PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
List<String> items = new ArrayList<String>() {{
add("1");
add("2");
add("3");
}};
List<String> items = Arrays.asList("1", "2", "3");
ItemReader<String> reader = new ListItemReader<>(items);
@SuppressWarnings("unchecked")
SimpleStepBuilder<String, String> builder = new StepBuilder("step")
.repository(jobRepository)
.transactionManager(transactionManager)
@@ -229,16 +223,11 @@ public class StepBuilderTests {
jobRepository.add(execution);
PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
List<Long> items = new ArrayList<Long>() {{
add(1L);
add(2L);
add(3L);
}};
List<Long> items = Arrays.asList(1L, 2L, 3L);
ItemReader<Long> reader = new ListItemReader<>(items);
ListItemWriter<String> itemWriter = new ListItemWriter<>();
SimpleStepBuilder<Object, String> builder = new StepBuilder("step")
.repository(jobRepository)
.transactionManager(transactionManager)