|
15 | 15 |
|
16 | 16 | import org.springframework.test.context.MergedContextConfiguration; |
17 | 17 |
|
| 18 | +import static digital.pragmatech.testing.util.CollectionFormatUtils.prettyPrintCollection; |
| 19 | +import static digital.pragmatech.testing.util.CollectionFormatUtils.toStringSortedSet; |
| 20 | + |
18 | 21 | /** Entry representing a cached context configuration. */ |
19 | 22 | public class ContextCacheEntry { |
20 | 23 | private final MergedContextConfiguration configuration; |
@@ -200,26 +203,35 @@ public Map<String, Object> getConfigurationSummary() { |
200 | 203 | Map<String, Object> summary = new LinkedHashMap<>(); |
201 | 204 |
|
202 | 205 | if (configuration != null) { |
203 | | - |
| 206 | + // configurationClasses equality is based on ordered Class<?>[] |
204 | 207 | summary.put( |
205 | 208 | "configurationClasses", |
206 | | - Arrays.stream(configuration.getClasses()) |
207 | | - .map(Class::getSimpleName) |
208 | | - .collect(Collectors.toList())); |
| 209 | + prettyPrintCollection( |
| 210 | + Arrays.stream(configuration.getClasses()).map(Class::getName).toList())); |
209 | 211 |
|
210 | | - summary.put("activeProfiles", Arrays.asList(configuration.getActiveProfiles())); |
| 212 | + // activeProfiles equality is based on ordered String[] |
| 213 | + summary.put( |
| 214 | + "activeProfiles", |
| 215 | + prettyPrintCollection(Arrays.asList(configuration.getActiveProfiles()))); |
211 | 216 | summary.put("contextLoader", configuration.getContextLoader().getClass().getSimpleName()); |
212 | | - |
213 | 217 | summary.put("properties", configuration.getPropertySourceProperties().length + " properties"); |
214 | 218 | summary.put("parentContext", configuration.getParent()); |
215 | | - summary.put("contextCustomizers", configuration.getContextCustomizers()); |
216 | | - summary.put("locations", String.join(",", configuration.getLocations())); |
| 219 | + // contextCustomizers equality is based on Set. Convert to ordered String representation to |
| 220 | + // simplify comparison |
| 221 | + summary.put( |
| 222 | + "contextCustomizers", |
| 223 | + prettyPrintCollection(toStringSortedSet(configuration.getContextCustomizers()))); |
| 224 | + // locations equality is based on ordered String[] |
| 225 | + summary.put("locations", prettyPrintCollection(Arrays.asList(configuration.getLocations()))); |
217 | 226 |
|
| 227 | + // contextInitializers equality is based on Set. Convert to ordered String representation to |
| 228 | + // simplify comparison |
218 | 229 | summary.put( |
219 | 230 | "contextInitializers", |
220 | | - configuration.getContextInitializerClasses().stream() |
221 | | - .map(Class::getSimpleName) |
222 | | - .collect(Collectors.toList())); |
| 231 | + prettyPrintCollection( |
| 232 | + configuration.getContextInitializerClasses().stream() |
| 233 | + .map(Class::getName) |
| 234 | + .collect(Collectors.toList()))); |
223 | 235 |
|
224 | 236 | summary.put("beanDefinitionCount", beanDefinitionCount); |
225 | 237 | } |
|
0 commit comments