This requires adapting to Truth's recent nullness annotations.
Specifically, a Subject constructor (and the associated
Subject.Factory and assertThat function) should accept a null actual
value. By doing so, it makes it possible to write
assertThat(foo).isNull(), for example.
This does not necessarily mean that all assertions will pass if the caller
passes null. Obviously isNotNull() will fail, of course, but so too may
other assertions, like hasFoundProducts will here.
(In principle, it would be nice for all assertions to fail with
detailed NullPointerException messages. In practice, we mostly
haven't done that even for the core Truth assertions. So I haven't here,
either.)
Without this PR, the error that Truth 1.4.2 produces is:
ProductsAPITest.kt:245:46 Type mismatch: inferred type is KFunction2<FailureMetadata, Search, ProductsAPITest.SearchSubject> but (FailureMetadata!, TypeVariable(ActualT)?) -> TypeVariable(SubjectT)! was expected
This requires adapting to Truth's recent nullness annotations.
Specifically, a
Subject
constructor (and the associatedSubject.Factory
andassertThat
function) should accept a null actual value. By doing so, it makes it possible to writeassertThat(foo).isNull()
, for example.This does not necessarily mean that all assertions will pass if the caller passes
null
. ObviouslyisNotNull()
will fail, of course, but so too may other assertions, likehasFoundProducts
will here.(In principle, it would be nice for all assertions to fail with detailed
NullPointerException
messages. In practice, we mostly haven't done that even for the core Truth assertions. So I haven't here, either.)Without this PR, the error that Truth 1.4.2 produces is:
Fixes https://github.com/openfoodfacts/openfoodfacts-androidapp/pull/5191