55
66import java .util .Map ;
77
8- import static org .testng .Assert .assertEquals ;
9- import static org .testng .Assert .assertNotSame ;
8+ import static org .testng .Assert .*;
109
1110/**
1211 * @author Vincent Latombe <vincent@latombe.net>
@@ -18,14 +17,25 @@ public void newFiltersShouldBeEquals() {
1817 assertEquals (new Filters (), new Filters ());
1918 }
2019
20+ @ Test
21+ public void newFiltersShouldHaveEqualHashcode () {
22+ assertEquals (new Filters ().hashCode (), new Filters ().hashCode ());
23+ }
24+
2125 @ Test
2226 public void filtersWithEqualContentShouldBeEquals () {
2327 assertEquals (new Filters ().withContainers ("foo" ), new Filters ().withContainers ("foo" ));
2428 assertEquals (new Filters ().withLabels ("alpha=val" ), new Filters ().withLabels ("alpha=val" ));
2529 }
2630
2731 @ Test
28- public void withLabelsMapShouldBeEquivalentToVarargs () {
32+ public void filtersWithEqualContentShouldHaveEqualHashcode () {
33+ assertEquals (new Filters ().withContainers ("foo" ).hashCode (), new Filters ().withContainers ("foo" ).hashCode ());
34+ assertEquals (new Filters ().withLabels ("alpha=val" ).hashCode (), new Filters ().withLabels ("alpha=val" ).hashCode ());
35+ }
36+
37+ @ Test
38+ public void withLabelsMapShouldBeEqualsToVarargs () {
2939 Map <String , String > map = Maps .newHashMap ();
3040 map .put ("alpha" , "val" );
3141 assertEquals (new Filters ().withLabels ("alpha=val" ), new Filters ().withLabels (map ));
@@ -38,6 +48,11 @@ public void withLabelsMapShouldBeEquivalentToVarargs() {
3848
3949 @ Test
4050 public void filtersWithDifferentContentShouldntBeEquals () {
41- assertNotSame (new Filters ().withContainers ("foo" ), new Filters ().withContainers ("bar" ));
51+ assertNotEquals (new Filters ().withContainers ("foo" ), new Filters ().withContainers ("bar" ));
52+ }
53+
54+ @ Test
55+ public void filtersWithDifferentContentShouldntHaveEqualHashcode () {
56+ assertNotEquals (new Filters ().withContainers ("foo" ).hashCode (), new Filters ().withContainers ("bar" ).hashCode ());
4257 }
4358}
0 commit comments