Skip to content

Commit

Permalink
(#114) Implements complete mismatches tests for HasEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed Sep 15, 2019
1 parent ba2e3bf commit 28e225e
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/test/java/org/llorllale/cactoos/matchers/HasEntryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
* Test case for {@link HasEntry}.
*
* @since 1.0.0
* @todo #65:30min Add two more tests for the mismatch message,
* testing both the case when a key is absent and a value is incorrect,
* if possible using the Mismatches Matcher introduced by
* https://github.com/llorllale/cactoos-matchers/issues/106.
* @checkstyle JavadocMethodCheck (200 lines)
*/
@SuppressWarnings("unchecked")
Expand All @@ -61,27 +57,29 @@ public void matches() {
).affirm();
}

@Test(expected = AssertionError.class)
@Test
public void doesNotMatchAMissingEntry() {
new Assertion<>(
"must not match a missing entry in the map",
new MapOf<>(
new MapEntry<>("a", 1),
new MapEntry<>("b", 2)
),
new HasEntry<>("c", 1)
new HasEntry<>("c", 1),
new Mismatches<>(
new MapOf<>(new MapEntry<>("a", 1)),
"has entry \"c\"=<1>",
"has no entry for \"c\""
)
).affirm();
}

@Test(expected = AssertionError.class)
@Test
public void doesNotMatchAnIncorrectEntry() {
new Assertion<>(
"must not match an existing entry in the map",
new MapOf<>(
new MapEntry<>("a", 1),
new MapEntry<>("b", 2)
),
new HasEntry<>("b", 1)
new HasEntry<>("b", 1),
new Mismatches<>(
new MapOf<>(new MapEntry<>("b", 2)),
"has entry \"b\"=<1>",
"has entry \"b\"=<2>"
)
).affirm();
}
}

1 comment on commit 28e225e

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 28e225e Sep 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 65-01fd6042 disappeared from src/test/java/org/llorllale/cactoos/matchers/HasEntryTest.java, that's why I closed #114. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.