Skip to content

Commit a9cc7b3

Browse files
committed
Improve tests for synthesized array of annotations
1 parent 5721c74 commit a9cc7b3

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,41 +1956,25 @@ void synthesizeNonPublicWithAttributeAliasesFromDifferentPackage() throws Except
19561956
}
19571957

19581958
@Test
1959-
void synthesizeWithAttributeAliasesInNestedAnnotations() throws Exception {
1959+
void synthesizeWithArrayOfAnnotations() throws Exception {
19601960
Hierarchy hierarchy = HierarchyClass.class.getAnnotation(Hierarchy.class);
19611961
assertThat(hierarchy).isNotNull();
19621962
Hierarchy synthesizedHierarchy = MergedAnnotation.from(hierarchy).synthesize();
19631963
assertThat(synthesizedHierarchy).isInstanceOf(SynthesizedAnnotation.class);
19641964
TestConfiguration[] configs = synthesizedHierarchy.value();
19651965
assertThat(configs).isNotNull();
19661966
assertThat(configs).allMatch(SynthesizedAnnotation.class::isInstance);
1967-
assertThat(
1968-
Arrays.stream(configs).map(TestConfiguration::location)).containsExactly(
1969-
"A", "B");
1970-
assertThat(Arrays.stream(configs).map(TestConfiguration::value)).containsExactly(
1971-
"A", "B");
1972-
}
1967+
assertThat(configs).extracting(TestConfiguration::value).containsExactly("A", "B");
1968+
assertThat(configs).extracting(TestConfiguration::location).containsExactly("A", "B");
19731969

1974-
@Test
1975-
void synthesizeWithArrayOfAnnotations() throws Exception {
1976-
Hierarchy hierarchy = HierarchyClass.class.getAnnotation(Hierarchy.class);
1977-
assertThat(hierarchy).isNotNull();
1978-
Hierarchy synthesizedHierarchy = MergedAnnotation.from(hierarchy).synthesize();
1979-
assertThat(synthesizedHierarchy).isInstanceOf(SynthesizedAnnotation.class);
1980-
TestConfiguration contextConfig = TestConfigurationClass.class.getAnnotation(
1981-
TestConfiguration.class);
1970+
TestConfiguration contextConfig = TestConfigurationClass.class.getAnnotation(TestConfiguration.class);
19821971
assertThat(contextConfig).isNotNull();
1983-
TestConfiguration[] configs = synthesizedHierarchy.value();
1984-
assertThat(
1985-
Arrays.stream(configs).map(TestConfiguration::location)).containsExactly(
1986-
"A", "B");
19871972
// Alter array returned from synthesized annotation
19881973
configs[0] = contextConfig;
1974+
assertThat(configs).extracting(TestConfiguration::value).containsExactly("simple.xml", "B");
19891975
// Re-retrieve the array from the synthesized annotation
19901976
configs = synthesizedHierarchy.value();
1991-
assertThat(
1992-
Arrays.stream(configs).map(TestConfiguration::location)).containsExactly(
1993-
"A", "B");
1977+
assertThat(configs).extracting(TestConfiguration::value).containsExactly("A", "B");
19941978
}
19951979

19961980
@Test

0 commit comments

Comments
 (0)