Browse code

BM-14942 Fix: exclude some objects attribute from equals and hash methods

Anthony Prades authored on 17/06/2019 10:03:12
Showing 3 changed files
... ...
@@ -105,6 +105,12 @@ public class LdapParametersHostTest {
105 105
 		Host h2 = Host.build("2 3 1 hostname");
106 106
 
107 107
 		assertEquals(h1, h2);
108
+
109
+		h2 = Host.build("4 3 1 hostname");
110
+		assertEquals(h1, h2);
111
+
112
+		h2 = Host.build("2 4 1 hostname");
113
+		assertEquals(h1, h2);
108 114
 	}
109 115
 
110 116
 	@Test
... ...
@@ -114,12 +120,6 @@ public class LdapParametersHostTest {
114 120
 		Host h2 = Host.build("2 3 1 hostname1");
115 121
 		assertNotEquals(h1, h2);
116 122
 
117
-		h2 = Host.build("4 3 1 hostname");
118
-		assertNotEquals(h1, h2);
119
-
120
-		h2 = Host.build("2 4 1 hostname");
121
-		assertNotEquals(h1, h2);
122
-
123 123
 		h2 = Host.build("2 3 4 hostname");
124 124
 		assertNotEquals(h1, h2);
125 125
 	}
... ...
@@ -85,6 +85,12 @@ public class LdapParametersTest {
85 85
 				new SplitDomain(true, "relaymailboxgroup1"), "lastupdate1");
86 86
 
87 87
 		assertEquals(ldapParameters1, ldapParameters2);
88
+
89
+		ldapParameters2 = Parameters.build(false,
90
+				new ServerTest(Host.build("hostname1", 389, 1, 2), "login1", "password1", LdapProtocol.PLAIN, true),
91
+				Directory.build("dc=local1", "userfilter1", "groupfilter1", "extidattr1"),
92
+				new SplitDomain(true, "relaymailboxgroup1"), "lastupdate2");
93
+		assertEquals(ldapParameters1, ldapParameters2);
88 94
 	}
89 95
 
90 96
 	@Test
... ...
@@ -117,12 +123,6 @@ public class LdapParametersTest {
117 123
 				Directory.build("dc=local1", "userfilter1", "groupfilter1", "extidattr1"),
118 124
 				new SplitDomain(false, "relaymailboxgroup1"), "lastupdate1");
119 125
 		assertNotEquals(ldapParameters1, ldapParameters2);
120
-
121
-		ldapParameters2 = Parameters.build(false,
122
-				new ServerTest(Host.build("hostname1", 389, 1, 2), "login1", "password1", LdapProtocol.PLAIN, true),
123
-				Directory.build("dc=local1", "userfilter1", "groupfilter1", "extidattr1"),
124
-				new SplitDomain(true, "relaymailboxgroup1"), "lastupdate2");
125
-		assertNotEquals(ldapParameters1, ldapParameters2);
126 126
 	}
127 127
 
128 128
 	@Test
... ...
@@ -73,8 +73,6 @@ public class Parameters {
73 73
 				int result = 1;
74 74
 				result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
75 75
 				result = prime * result + port;
76
-				result = prime * result + priority;
77
-				result = prime * result + weight;
78 76
 				return result;
79 77
 			}
80 78
 
... ...
@@ -94,10 +92,6 @@ public class Parameters {
94 92
 					return false;
95 93
 				if (port != other.port)
96 94
 					return false;
97
-				if (priority != other.priority)
98
-					return false;
99
-				if (weight != other.weight)
100
-					return false;
101 95
 				return true;
102 96
 			}
103 97
 
... ...
@@ -353,7 +347,6 @@ public class Parameters {
353 347
 		final int prime = 31;
354 348
 		int result = 1;
355 349
 		result = prime * result + (enabled ? 1231 : 1237);
356
-		result = prime * result + ((lastUpdate == null) ? 0 : lastUpdate.hashCode());
357 350
 		result = prime * result + ((ldapDirectory == null) ? 0 : ldapDirectory.hashCode());
358 351
 		result = prime * result + ((ldapServer == null) ? 0 : ldapServer.hashCode());
359 352
 		result = prime * result + ((splitDomain == null) ? 0 : splitDomain.hashCode());
... ...
@@ -371,11 +364,6 @@ public class Parameters {
371 364
 		Parameters other = (Parameters) obj;
372 365
 		if (enabled != other.enabled)
373 366
 			return false;
374
-		if (lastUpdate == null) {
375
-			if (other.lastUpdate != null)
376
-				return false;
377
-		} else if (!lastUpdate.equals(other.lastUpdate))
378
-			return false;
379 367
 		if (ldapDirectory == null) {
380 368
 			if (other.ldapDirectory != null)
381 369
 				return false;