Skip to content

Instantly share code, notes, and snippets.

@mchmielarz
Created December 14, 2019 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchmielarz/bbca896f975e50898f8e5c0f7a385246 to your computer and use it in GitHub Desktop.
Save mchmielarz/bbca896f975e50898f8e5c0f7a385246 to your computer and use it in GitHub Desktop.
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