Polish TestPropertySourceUtils
This commit is contained in:
parent
a271a0a2bf
commit
2eee56d0e2
|
@ -75,11 +75,8 @@ public abstract class TestPropertySourceUtils {
|
||||||
|
|
||||||
|
|
||||||
static MergedTestPropertySources buildMergedTestPropertySources(Class<?> testClass) {
|
static MergedTestPropertySources buildMergedTestPropertySources(Class<?> testClass) {
|
||||||
return mergeTestPropertySources(findRepeatableAnnotations(testClass, TestPropertySource.class));
|
List<MergedAnnotation<TestPropertySource>> mergedAnnotations =
|
||||||
}
|
findRepeatableAnnotations(testClass, TestPropertySource.class);
|
||||||
|
|
||||||
private static MergedTestPropertySources mergeTestPropertySources(
|
|
||||||
List<MergedAnnotation<TestPropertySource>> mergedAnnotations) {
|
|
||||||
|
|
||||||
if (mergedAnnotations.isEmpty()) {
|
if (mergedAnnotations.isEmpty()) {
|
||||||
return MergedTestPropertySources.empty();
|
return MergedTestPropertySources.empty();
|
||||||
|
@ -287,20 +284,15 @@ public abstract class TestPropertySourceUtils {
|
||||||
private static <T extends Annotation> void findRepeatableAnnotations(
|
private static <T extends Annotation> void findRepeatableAnnotations(
|
||||||
Class<?> clazz, Class<T> annotationType, List<List<MergedAnnotation<T>>> listOfLists, int[] aggregateIndex) {
|
Class<?> clazz, Class<T> annotationType, List<List<MergedAnnotation<T>>> listOfLists, int[] aggregateIndex) {
|
||||||
|
|
||||||
|
// Ensure we have a list for the current aggregate index.
|
||||||
|
if (listOfLists.size() < aggregateIndex[0] + 1) {
|
||||||
|
listOfLists.add(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
MergedAnnotations.from(clazz, SearchStrategy.DIRECT)
|
MergedAnnotations.from(clazz, SearchStrategy.DIRECT)
|
||||||
.stream(annotationType)
|
.stream(annotationType)
|
||||||
.sorted(highMetaDistancesFirst())
|
.sorted(highMetaDistancesFirst())
|
||||||
.forEach(annotation -> {
|
.forEach(annotation -> listOfLists.get(aggregateIndex[0]).add(0, annotation));
|
||||||
List<MergedAnnotation<T>> current = null;
|
|
||||||
if (listOfLists.size() < aggregateIndex[0] + 1) {
|
|
||||||
current = new ArrayList<>();
|
|
||||||
listOfLists.add(current);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
current = listOfLists.get(aggregateIndex[0]);
|
|
||||||
}
|
|
||||||
current.add(0, annotation);
|
|
||||||
});
|
|
||||||
|
|
||||||
aggregateIndex[0]++;
|
aggregateIndex[0]++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue