MultimapAssert in assertj-vavr v0.2.0
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
// given | |
private static final Tuple2<String, String> FRODO = Tuple.of("hobbit", "frodo"); | |
private static final Tuple2<String, String> SAM = Tuple.of("hobbit", "sam"); | |
private static final Tuple2<String, String> GIMLI = Tuple.of("dwarf", "gimli"); | |
private static final Tuple2<String, String> LEGOLAS = Tuple.of("elf", "legolas"); | |
private static final Multimap<String, String> RACES = | |
HashMultimap.withSeq().ofEntries(FRODO, SAM, GIMLI); | |
private static final BiConsumer<String, String> OK_CONSUMER = (key, value) -> Assertions.assertThat(key).isLowerCase(); | |
// somewhere in tests | |
assertThat(RACES).allSatisfy(OK_CONSUMER) | |
.containsAnyOf(FRODO, LEGOLAS) | |
.contains(FRODO) | |
.containsAllEntriesOf(List.of(FRODO, GIMLI)) | |
.containsEntry("hobbit", "frodo") | |
.containsExactly(GIMLI, SAM, FRODO) | |
.containsKey("hobbit") | |
.containsKeys("hobbit", "dwarf") | |
.containsOnly(List.of(SAM, FRODO, GIMLI)) | |
.containsOnlyKeys("hobbit", "dwarf") | |
.containsValue("frodo") | |
.containsValues("frodo", "gimli") | |
.doesNotContainEntry("elf", "legolas") | |
.doesNotContain(LEGOLAS) | |
.doesNotContainKey("elf") | |
.doesNotContainKeys("elf", "man") | |
.doesNotContainValue("legolas") | |
.doesNotContainValues("legolas", "aragorn") | |
.hasSameSizeAs(new String[]{"frodo", "gimli", "sam"}) | |
.hasSameSizeAs(Array.of(FRODO, GIMLI, SAM)) | |
.hasSize(3) | |
.isNotEmpty(); // and isEmpty() / isNullOrEmpty() | |
assertThat(RACES).hasEntrySatisfying("hobbit", new Condition<String>() { | |
@Override | |
public boolean matches(String value) { | |
return value.equals("sam"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment