You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I try to use AbstractObjectAssert::returns and I want to check that the function I pass returns null for something, the test throws a NullPointerException:
java.lang.NullPointerException
at org.assertj.core.api.AbstractObjectAssert.returns(AbstractObjectAssert.java:1105)
I've also looked into this and it's this line that throws: Objects objects = getComparatorBasedObjectAssertions(expected.getClass()); (expected is null in our usecase)
This could be fixed by doing something like this instead:
public <T> SELFdoesNotReturn(Texpected, Function<ACTUAL, T> from) {
requireNonNull(from, "The given getter method/Function must not be null");
Objectsobjects = getComparatorBasedObjectAssertions(expected);
objects.assertNotEqual(info, from.apply(actual), expected);
returnmyself;
}
private <T> ObjectsgetComparatorBasedObjectAssertions(TvalueOfType) {
if (valueOfType == null) {
returnobjects;
}
finalClass<?> type = valueOfType.getClass();
TypeComparatorscomparatorsByType = getComparatorsByType();
if (comparatorsByType.hasComparatorForType(type)) {
returnnewObjects(newComparatorBasedComparisonStrategy(comparatorsByType.getComparatorForType(type)));
}
returnobjects;
}
Describe the bug
When I try to use AbstractObjectAssert::returns and I want to check that the function I pass returns null for something, the test throws a NullPointerException:
java.lang.NullPointerException
at org.assertj.core.api.AbstractObjectAssert.returns(AbstractObjectAssert.java:1105)
The same thing also happens for doesNotReturn.
Test case reproducing the bug
Add a test case showing the bug that we can run
The text was updated successfully, but these errors were encountered: