assertj: null is not blank?!

Summary

As far as I know, null is considered as “Blank” (as “Blank” is superset of null, empty string or blank characters only)

Example

This passes:

        String s = null;
        assertThat(s).isNotBlank();

Java 8 specific ?

  • NO : create Pull Request from the 2.x branch

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Ok. It looks like the spec is cleared up now. I’ll abandon my pull requests and fix this tomorrow unless anyone has any further comments?

@joel-costigliola I think the by far most common use-case is isNotBlank and use it to check that a string is not null, empty or whitespace only (as reported by eximius313). So if we make isNotBlank fail for null, it should also fail for an empty string.

I’m not a great fan of isStricklyBlank. Imho containsOnlyWhitespace would be a more intention revealing name ( it also similar to the existing method containsOnlyDigits), but I doubt somebody needs this assertion (I could be wrong of course 😉). containsNotOnlyWhitespace would be clearer that isNotStrictlyBlank, what do you think?

I’m o.k. with replacing the more correct whitespace definition with the java one, as most users probably do not care either way (but because of this I also do not see a strong reason to change it).

I’m going to add both isStrictlyBlank() and isNotStrictlyBlank() for completeness 😃