Polishing

This commit is contained in:
Sam Brannen
2023-04-26 11:09:20 +02:00
parent 1c7ceaa2ca
commit ce3e9b0c29
6 changed files with 17 additions and 42 deletions

View File

@@ -16,8 +16,6 @@
package org.springframework.core.env;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@@ -51,7 +49,7 @@ class CustomEnvironmentTests {
class CustomEnvironment extends AbstractEnvironment {
@Override
protected Set<String> getReservedDefaultProfiles() {
return Collections.emptySet();
return Set.of();
}
}
@@ -64,7 +62,7 @@ class CustomEnvironmentTests {
class CustomEnvironment extends AbstractEnvironment {
@Override
protected Set<String> getReservedDefaultProfiles() {
return Collections.singleton("rd1");
return Set.of("rd1");
}
}
@@ -79,10 +77,7 @@ class CustomEnvironmentTests {
@Override
@SuppressWarnings("serial")
protected Set<String> getReservedDefaultProfiles() {
return new HashSet<>() {{
add("rd1");
add("rd2");
}};
return Set.of("rd1", "rd2");
}
}
@@ -151,7 +146,7 @@ class CustomEnvironmentTests {
@Override
@Nullable
public String getProperty(String key) {
return super.getProperty(key)+"-test";
return super.getProperty(key) + "-test";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-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.
@@ -17,7 +17,6 @@
package org.springframework.core.env;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -37,12 +36,8 @@ class PropertySourceTests {
@Test
@SuppressWarnings("serial")
void equals() {
Map<String, Object> map1 = new HashMap<>() {{
put("a", "b");
}};
Map<String, Object> map2 = new HashMap<>() {{
put("c", "d");
}};
Map<String, Object> map1 = Map.of("a", "b");
Map<String, Object> map2 = Map.of("c", "d");
Properties props1 = new Properties() {{
setProperty("a", "b");
}};
@@ -69,12 +64,8 @@ class PropertySourceTests {
@Test
@SuppressWarnings("serial")
void collectionsOperations() {
Map<String, Object> map1 = new HashMap<>() {{
put("a", "b");
}};
Map<String, Object> map2 = new HashMap<>() {{
put("c", "d");
}};
Map<String, Object> map1 = Map.of("a", "b");
Map<String, Object> map2 = Map.of("c", "d");
PropertySource<?> ps1 = new MapPropertySource("ps1", map1);
ps1.getSource();