Skip to content

Commit 51d6e8b

Browse files
committed
Polishing
1 parent 5096db4 commit 51d6e8b

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public Set<String> getCandidateTypes(String basePackage, String stereotype) {
138138
List<Entry> candidates = this.index.get(stereotype);
139139
if (candidates != null) {
140140
return candidates.stream()
141-
.filter(t -> t.match(basePackage))
142-
.map(t -> t.type)
141+
.filter(entry -> entry.match(basePackage))
142+
.map(entry -> entry.type)
143143
.collect(Collectors.toSet());
144144
}
145145
return Collections.emptySet();

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* @author Stephane Nicoll
3434
*/
35-
public class CandidateComponentsIndexLoaderTests {
35+
class CandidateComponentsIndexLoaderTests {
3636

3737
@Test
3838
void validateIndexIsDisabledByDefault() {

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
package org.springframework.context.index;
1818

19-
import java.util.Arrays;
20-
import java.util.Collections;
19+
import java.util.List;
2120
import java.util.Properties;
2221
import java.util.Set;
2322

@@ -30,52 +29,47 @@
3029
*
3130
* @author Stephane Nicoll
3231
*/
33-
public class CandidateComponentsIndexTests {
32+
class CandidateComponentsIndexTests {
3433

3534
@Test
3635
void getCandidateTypes() {
37-
CandidateComponentsIndex index = new CandidateComponentsIndex(
38-
Collections.singletonList(createSampleProperties()));
36+
CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties()));
3937
Set<String> actual = index.getCandidateTypes("com.example.service", "service");
4038
assertThat(actual).contains("com.example.service.One",
4139
"com.example.service.sub.Two", "com.example.service.Three");
4240
}
4341

42+
@Test
43+
void getCandidateTypesNoMatch() {
44+
CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties()));
45+
Set<String> actual = index.getCandidateTypes("com.example.service", "entity");
46+
assertThat(actual).isEmpty();
47+
}
48+
4449
@Test
4550
void getCandidateTypesSubPackage() {
46-
CandidateComponentsIndex index = new CandidateComponentsIndex(
47-
Collections.singletonList(createSampleProperties()));
51+
CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties()));
4852
Set<String> actual = index.getCandidateTypes("com.example.service.sub", "service");
4953
assertThat(actual).contains("com.example.service.sub.Two");
5054
}
5155

5256
@Test
5357
void getCandidateTypesSubPackageNoMatch() {
54-
CandidateComponentsIndex index = new CandidateComponentsIndex(
55-
Collections.singletonList(createSampleProperties()));
58+
CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties()));
5659
Set<String> actual = index.getCandidateTypes("com.example.service.none", "service");
5760
assertThat(actual).isEmpty();
5861
}
5962

60-
@Test
61-
void getCandidateTypesNoMatch() {
62-
CandidateComponentsIndex index = new CandidateComponentsIndex(
63-
Collections.singletonList(createSampleProperties()));
64-
Set<String> actual = index.getCandidateTypes("com.example.service", "entity");
65-
assertThat(actual).isEmpty();
66-
}
67-
6863
@Test
6964
void mergeCandidateStereotypes() {
70-
CandidateComponentsIndex index = new CandidateComponentsIndex(Arrays.asList(
65+
CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(
7166
createProperties("com.example.Foo", "service"),
7267
createProperties("com.example.Foo", "entity")));
73-
assertThat(index.getCandidateTypes("com.example", "service"))
74-
.contains("com.example.Foo");
75-
assertThat(index.getCandidateTypes("com.example", "entity"))
76-
.contains("com.example.Foo");
68+
assertThat(index.getCandidateTypes("com.example", "service")).contains("com.example.Foo");
69+
assertThat(index.getCandidateTypes("com.example", "entity")).contains("com.example.Foo");
7770
}
7871

72+
7973
private static Properties createProperties(String key, String stereotypes) {
8074
Properties properties = new Properties();
8175
properties.put(key, String.join(",", stereotypes));

0 commit comments

Comments
 (0)