Skip to content

Commit

Permalink
#844: Implement equals and hashCode for MapEnvelope - fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
proshin-roman committed May 18, 2018
1 parent cd42e15 commit 1ed8fe7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/test/java/org/cactoos/map/MapEnvelopeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ public void mapNotEqualsToAnotherClass() {

@Test
public void mapEqualsToMapWithSameEntries() {
final MapEntry<String, String> entry =
new MapEntry<>("key2", "value2");
final String key = "key2";
final String value = "value2";
final MapEntry<String, String> input = new MapEntry<>(key, value);
final MapEntry<String, String> expected = new MapEntry<>(key, value);
MatcherAssert.assertThat(
"Map doesn't equal to another map with same entries",
new MapOf<String, String>(entry),
new IsEqual<>(new MapOf<String, String>(entry))
new MapOf<String, String>(input),
new IsEqual<>(new MapOf<String, String>(expected))
);
}

Expand Down Expand Up @@ -289,12 +291,14 @@ public void mapNotEqualsToOtherWithDifferentValues() {

@Test
public void hashCodeDependsOnItems() {
final MapEntry<String, String> entry =
new MapEntry<>("key9", "value9");
final String key = "key9";
final String value = "value9";
final MapEntry<String, String> input = new MapEntry<>(key, value);
final MapEntry<String, String> expected = new MapEntry<>(key, value);
MatcherAssert.assertThat(
"hashCode returns different results for same entries",
new MapOf<String, String>(entry).hashCode(),
new IsEqual<>(new MapOf<String, String>(entry).hashCode())
new MapOf<String, String>(input).hashCode(),
new IsEqual<>(new MapOf<String, String>(expected).hashCode())
);
}

Expand Down

0 comments on commit 1ed8fe7

Please sign in to comment.