How to write a proper test on a method that can return a null to assign the value to a nonnull variable?
@Nonnull String abc;
if(holderForState.getNodeElementSelectedAPI() == null || holderForState.getNodeElementSelectedAPI().equals("")) {
throw new IllegalArgumentException("SelectedAPI is empty or null during logic usage");
}
abc = holderForState.getNodeElementSelectedAPI();
Why does VS-code tell me that: Null type safety: The expression of type 'String' needs unchecked conversion to conform to '@Nonnull String'Java(16778128) on abc assignment line? I am literally testing if it is null 1 line above and throwing out of context if it is...
I tried multiple versions of this test, but I get the same. To make it simpler I am showing the assignment, whereas in reality I am using abc as a method parameter, with same outcomes.