We have just released the 0.2.0 version of the assertj-vavr library. With this release, you get the assertions for Vavr’s Multimap type, a bunch of new ones for Map, the next two for Either, and assumptions for all supported Vavr types. Let’s got through them in more detail.
Map assertions
While the support of Maps was already there, we’ve been missing methods allowing us to check for containment of specific keys or values. The new version of the library makes it possible:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If we are using a map that has a consistent iteration order (like LinkedHashMap or TreeMap), there is new assert allowing to check the order of entries:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Additionally, we can check whether an entry with given key satisfies provided condition:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The new release adds support of Multimap types. The range of assertions we can make is the same as for Map:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EitherAssert gets two new methods checking whether a value on left or right satisfies provided criteria:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The new release adds assumptions for all supported Vavr types. The starting point is org.assertj.vavr.api.VavrAssumptions class and its assumeThat static methods. The API matches the one for assertions. We can now write conditional tests, as presented below. Failing assumption marks a given test as ignored, not as failed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With this release, we have updated the error message when calling TryAssert.isSuccess() fails. Now, the output is more informative and presents the content of the Try.Failure instance, we’ve been checking.
Contribs
A big thank you go to Alex Dukhno and James Lorenzen for providing PRs and ideas on how to extend the library. And last but not least, special thanks go to Maciek Opala for competent reviews all of my PRs made to the project!
As you may spot, I released the previous version almost nine months ago. That’s a long time. Unfortunately, I had not enough free time to sit down on the project. And it doesn’t look like it is going to change shortly. Thus, if you have any idea on how to extend the project, do not hesitate and make an issue. Or even better – create a pull request. Your contribution is more than welcome!
I'm happy to present you a new release of assertj-vavr. This version, i.e., v0.1.0, uses Vavr v0.10.0 and adds support of more types from this library.
If you are working with Java, you probably know Vavr library, I guess. It is a great library, and it is my default in every Java project I am working on, as it was with Read more…
2 Comments
December 18 evening Java digest – BLOG – THE HACKER NEWS · December 23, 2019 at 11:30 am
[…] it assertj-vavr v0.2.0. Library lies on github (95 commits, 30 stars) and provides assists for vavr. Vavr, in turn, is a […]
Java digest for December 18 / Blog of the JUG Ru Group company / geek magazine – Developers · January 19, 2020 at 2:00 am
[…] it assertj-vavr v0.2.0. Library lies on github (95 commits, 30 stars) and provides assists for vavr. Vavr, in turn, is a […]