Skip to content

Instantly share code, notes, and snippets.

@mchmielarz
Last active March 12, 2019 15:39
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/898811b96a00142946e62b533180c9a8 to your computer and use it in GitHub Desktop.
Save mchmielarz/898811b96a00142946e62b533180c9a8 to your computer and use it in GitHub Desktop.
Capabilities of MapAssert from assertj-vavr v0.1.0
final Map<String, String> cars = HashMap.of(
"electric", "Tesla Model 3",
"gasoline", "Audi A4 Quattro",
"diesel", "Peugeot 308SW"
);
final Map<String, String> expected = cars;
assertThat(cars)
.isNotEmpty()
.hasSize(3)
.isEqualTo(expected) // assuming it contains the same values as cars
.contains(
Tuple.of("gasoline", "Audi A4 Quattro"), Tuple.of("diesel", "Peugeot 308SW")
)
.containsEntry("electric", "Tesla Model 3")
.containsAnyOf(
Tuple.of("nuclear", "DeLorean DMC-12"), Tuple.of("diesel", "Peugeot 308SW")
)
.containsAllEntriesOf(
List.of(Tuple.of("gasoline", "Audi A4 Quattro"),
Tuple.of("diesel", "Peugeot 308SW"))
)
.doesNotContain(Tuple.of("nuclear", "DeLorean DMC-12"))
.doesNotContainEntry("nuclear", "DeLorean DMC-12");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment