Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New assertions added to MapAssert in assertj-vavr v0.2.0
// given
private static final Tuple2<String, String> FRODO = Tuple.of("frodo", "hobbit");
private static final Tuple2<String, String> GIMLI = Tuple.of("gimli", "dwarf");
private static final Tuple2<String, String> LEGOLAS = Tuple.of("legolas", "elf");
private static final Map<String, String> PERSONS = List.of(FRODO, GIMLI, LEGOLAS).toMap(tup -> tup);
// somewhere in tests
assertThat(PERSONS)
.containsOnly(List.of(FRODO, GIMLI, LEGOLAS))
.containsOnlyKeys(FRODO._1, GIMLI._1, LEGOLAS._1)
.containsKey("frodo")
.containsKeys("frodo", "legolas")
.containsValue("dwarf")
.containsValues("elf", "dwarf")
.doesNotContainKey("aragorn")
.doesNotContainKeys("aragorn", "boromir")
.doesNotContainValue("man")
.doesNotContainValues("man", "orc");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment