New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify multiple single value extractors in flatExtracting #644
Comments
I already have working prototype for the multiple extractor function method. I will clean it up and submit a pull requests. |
Just noticed that the prototype is not working. It was expecting all collections to contain objects of the same type. When I tried to make it work for untyped objects, there is a conflict between the two method signatures:
so it does not seem to be possible to make this work (unless I'm missing something). |
I think what we want is : public ListAssert<Object> flatExtracting(Function<Object, Object>... extractors)
// or
public ListAssert<Object> flatExtracting(Extractor<Object, Object>... extractors) and not: public ListAssert<Object> flatExtracting(Function<Object, ? extends Collection<Object>>... extractors) the reason being that each extractor extracts one value, combine them in a list and flatten it. This will solve the compilation problem I think. As a side note, I'm not sure whether we would need to use wildcard or not, e.g: public ListAssert<Object> flatExtracting(Extractor<? super Object, ? extends Object>... extractors) |
I do not understand. If we want to extract a single value why use Anyway: public ListAssert<Object> flatExtracting(Function<Object, Object>... extractors)
public ListAssert<Object> flatExtracting(Extractor<Object, Object>... extractors)
public ListAssert<Object> flatExtracting(Extractor<? super Object, ? extends Object>... extractors) each cause a compile time conflict with the existing method: public <V> ListAssert<V> flatExtracting(Extractor<? super T, ? extends Collection<V>> extractor) |
We want to extract multiple single values as in: assertThat(fellowshipOfTheRing).flatExtracting(TolkienCharacter::getName,
TolkienCharacter::getAge))
.contains(33 ,"Frodo", "Legolas", 1000); We combine them in a list so that our users don't have to do it manually as in: // ch type is TolkienCharacter
assertThat(fellowshipOfTheRing).flatExtracting(ch -> asList(input.getName(), ch.getAge()))
.contains(33 ,"Frodo", "Legolas", 1000); @PascalSchumacher does it make sense to you ? |
Sure, thanks for explaining. :) |
…given a group of field/property names
Done for 2.5.0 by specifying extractors by name and 3.5.0 by specifying extractors as lambdas. |
…given a group of field/property names
…ngle value' extractors
For the time being, to extract multiple values and combine them before performing assertions we have to do something like this:
It would be nice to simply specify the list of extractors (Java 8) :
or with properties names (Java 7) :
The text was updated successfully, but these errors were encountered: