-
-
Notifications
You must be signed in to change notification settings - Fork 749
Closed as not planned
Closed as not planned
Copy link
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply
Description
The following compiles with 3.26.3:
record Container(String name, ArrayList<Object> elements) {
}
Container container = new Container("", new ArrayList<>());
assertThat(container)
// returns AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>>
.extracting(Container::name, Container::elements)
.contains("", List.of());
However, it doesn't compile with 3.27.0:
assertThat(container)
// returns AbstractListAssert<?, List<? extends Serializable>, Serializable, ObjectAssert<Serializable>>
.extracting(Container::name, Container::elements)
.contains("", List.of()); // Cannot resolve method 'contains(String, List<E>)'
This is a consequence of:
which changed the minimum accepted type of contains
values from Object
to Serializable
.
Arguably, the following wouldn't compile even with 3.26.3:
assertThat(List.of(container.name(), container.elements()))
.contains("", List.of()); // Cannot resolve method 'contains(String, List<E>)'
Therefore, I'm unsure whether the previous behavior of extracting
chained with contains
should be supported.
The workaround for both examples is to create an ArrayList
from the expected List
:
import static org.assertj.core.util.Lists.newArrayList;
assertThat(container)
.extracting(Container::name, Container::elements)
.contains("", newArrayList());
assertThat(List.of(container.name(), container.elements()))
.contains("", newArrayList());
ppkarwasz
Metadata
Metadata
Assignees
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply