|
16 | 16 |
|
17 | 17 | package org.springframework.context.index; |
18 | 18 |
|
19 | | -import java.util.Arrays; |
20 | | -import java.util.Collections; |
| 19 | +import java.util.List; |
21 | 20 | import java.util.Properties; |
22 | 21 | import java.util.Set; |
23 | 22 |
|
|
30 | 29 | * |
31 | 30 | * @author Stephane Nicoll |
32 | 31 | */ |
33 | | -public class CandidateComponentsIndexTests { |
| 32 | +class CandidateComponentsIndexTests { |
34 | 33 |
|
35 | 34 | @Test |
36 | 35 | void getCandidateTypes() { |
37 | | - CandidateComponentsIndex index = new CandidateComponentsIndex( |
38 | | - Collections.singletonList(createSampleProperties())); |
| 36 | + CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties())); |
39 | 37 | Set<String> actual = index.getCandidateTypes("com.example.service", "service"); |
40 | 38 | assertThat(actual).contains("com.example.service.One", |
41 | 39 | "com.example.service.sub.Two", "com.example.service.Three"); |
42 | 40 | } |
43 | 41 |
|
| 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 | + |
44 | 49 | @Test |
45 | 50 | void getCandidateTypesSubPackage() { |
46 | | - CandidateComponentsIndex index = new CandidateComponentsIndex( |
47 | | - Collections.singletonList(createSampleProperties())); |
| 51 | + CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties())); |
48 | 52 | Set<String> actual = index.getCandidateTypes("com.example.service.sub", "service"); |
49 | 53 | assertThat(actual).contains("com.example.service.sub.Two"); |
50 | 54 | } |
51 | 55 |
|
52 | 56 | @Test |
53 | 57 | void getCandidateTypesSubPackageNoMatch() { |
54 | | - CandidateComponentsIndex index = new CandidateComponentsIndex( |
55 | | - Collections.singletonList(createSampleProperties())); |
| 58 | + CandidateComponentsIndex index = new CandidateComponentsIndex(List.of(createSampleProperties())); |
56 | 59 | Set<String> actual = index.getCandidateTypes("com.example.service.none", "service"); |
57 | 60 | assertThat(actual).isEmpty(); |
58 | 61 | } |
59 | 62 |
|
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 | | - |
68 | 63 | @Test |
69 | 64 | void mergeCandidateStereotypes() { |
70 | | - CandidateComponentsIndex index = new CandidateComponentsIndex(Arrays.asList( |
| 65 | + CandidateComponentsIndex index = new CandidateComponentsIndex(List.of( |
71 | 66 | createProperties("com.example.Foo", "service"), |
72 | 67 | 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"); |
77 | 70 | } |
78 | 71 |
|
| 72 | + |
79 | 73 | private static Properties createProperties(String key, String stereotypes) { |
80 | 74 | Properties properties = new Properties(); |
81 | 75 | properties.put(key, String.join(",", stereotypes)); |
|
0 commit comments