1717import static org .assertj .core .api .BDDAssertions .then ;
1818import static org .assertj .core .error .ShouldNotBeNull .shouldNotBeNull ;
1919import static org .assertj .core .presentation .UnicodeRepresentation .UNICODE_REPRESENTATION ;
20+ import static org .assertj .tests .core .testkit .AlwaysEqualComparator .ALWAYS_EQUALS ;
21+ import static org .assertj .tests .core .testkit .AlwaysEqualComparator .ALWAYS_EQUALS_STRING ;
2022
2123import java .util .List ;
2224import java .util .function .Function ;
25+
2326import org .assertj .core .api .AbstractAssert ;
2427import org .assertj .core .api .AbstractListAssert ;
2528import org .assertj .core .api .ObjectAssert ;
2629import org .assertj .core .internal .Objects ;
2730import org .assertj .core .util .introspection .PropertyOrFieldSupport ;
28- import org .assertj .tests .core .testkit .AlwaysEqualComparator ;
2931import org .assertj .tests .core .testkit .Employee ;
30- import org .assertj .tests .core .testkit .Jedi ;
3132import org .assertj .tests .core .testkit .Name ;
3233import org .assertj .tests .core .testkit .NavigationMethodBaseTest ;
33- import org .assertj .tests .core .testkit .Person ;
3434import org .junit .jupiter .api .BeforeEach ;
3535import org .junit .jupiter .api .Test ;
3636
3737class ObjectAssert_extracting_with_Function_Array_Test implements NavigationMethodBaseTest <ObjectAssert <Employee >> {
3838
3939 private Employee luke ;
4040
41- private static final Function <Employee , String > firstName = employee -> employee .getName ().getFirst ();
41+ private static final Function <Employee , String > FIRST_NAME = employee -> employee .getName ().getFirst ();
4242
4343 @ BeforeEach
4444 void setUp () {
@@ -50,35 +50,18 @@ void should_allow_extracting_values_using_multiple_lambda_extractors() {
5050 // GIVEN
5151 Function <Employee , Object > lastName = employee -> employee .getName ().getLast ();
5252 // WHEN
53- AbstractListAssert <?, List <?>, Object , ObjectAssert <Object >> result = assertThat (luke ).extracting (firstName , lastName );
53+ AbstractListAssert <?, List <?>, Object , ObjectAssert <Object >> result = assertThat (luke ).extracting (FIRST_NAME , lastName );
5454 // THEN
5555 result .hasSize (2 )
5656 .containsExactly ("Luke" , "Skywalker" );
5757 }
5858
59- @ Test
60- void should_allow_extracting_values_using_multiple_lambda_extractors_with_common_ancestor () {
61- // GIVEN
62- record Companions (Jedi jedi , Person person ) {
63- }
64- Companions companions = new Companions (new Jedi ("Luke" , "blue" ), new Person ("Han" ));
65- Function <Companions , Jedi > jedi = Companions ::jedi ;
66- Function <Companions , Person > person = Companions ::person ;
67- // WHEN
68- AbstractListAssert <?, List <? extends Person >, Person , ObjectAssert <Person >> result = assertThat (companions ).extracting (jedi ,
69- person );
70- // THEN
71- result .hasSize (2 )
72- .allSatisfy (e -> assertThat (e .getName ()).isNotBlank ());
73- }
74-
7559 @ Test
7660 void should_allow_extracting_values_using_multiple_lambda_extractors_with_type () {
7761 // GIVEN
7862 Function <Employee , String > lastName = employee -> employee .getName ().getLast ();
7963 // WHEN
80- AbstractListAssert <?, List <? extends String >, String , ObjectAssert <String >> result = assertThat (luke ).extracting (firstName ,
81- lastName );
64+ AbstractListAssert <?, List <?>, Object , ObjectAssert <Object >> result = assertThat (luke ).extracting (FIRST_NAME , lastName );
8265 // THEN
8366 result .hasSize (2 )
8467 .containsExactly ("Luke" , "Skywalker" );
@@ -101,7 +84,7 @@ void should_rethrow_any_extractor_function_exception() {
10184 throw explosion ;
10285 };
10386 // WHEN
104- Throwable error = catchThrowable (() -> assertThat (luke ).extracting (firstName , bomb ));
87+ Throwable error = catchThrowable (() -> assertThat (luke ).extracting (FIRST_NAME , bomb ));
10588 // THEN
10689 then (error ).isSameAs (explosion );
10790 }
@@ -124,18 +107,18 @@ void extracting_should_keep_assertion_state() {
124107 ObjectAssert <Employee > assertion = assertThat (luke ).as ("test description" )
125108 .withFailMessage ("error message" )
126109 .withRepresentation (UNICODE_REPRESENTATION )
127- .usingComparator (AlwaysEqualComparator . ALWAYS_EQUALS )
128- .usingComparatorForFields (AlwaysEqualComparator . ALWAYS_EQUALS_STRING ,
110+ .usingComparator (ALWAYS_EQUALS )
111+ .usingComparatorForFields (ALWAYS_EQUALS_STRING ,
129112 "foo" )
130- .usingComparatorForType (AlwaysEqualComparator . ALWAYS_EQUALS_STRING ,
113+ .usingComparatorForType (ALWAYS_EQUALS_STRING ,
131114 String .class );
132115 // WHEN
133- AbstractListAssert <?, List <?>, Object , ObjectAssert <Object >> result = assertion .extracting (firstName , Employee ::getName );
116+ AbstractListAssert <?, List <?>, Object , ObjectAssert <Object >> result = assertion .extracting (FIRST_NAME , Employee ::getName );
134117 // THEN
135118 then (result .descriptionText ()).isEqualTo ("test description" );
136119 then (result .info .overridingErrorMessage ()).isEqualTo ("error message" );
137120 then (result .info .representation ()).isEqualTo (UNICODE_REPRESENTATION );
138- then (comparatorOf (result ).getComparator ()).isSameAs (AlwaysEqualComparator . ALWAYS_EQUALS );
121+ then (comparatorOf (result ).getComparator ()).isSameAs (ALWAYS_EQUALS );
139122 }
140123
141124 private static Objects comparatorOf (AbstractListAssert <?, ?, ?, ?> assertion ) {
0 commit comments