|
18 | 18 |
|
19 | 19 | import static org.junit.Assert.assertFalse; |
20 | 20 | import static org.junit.Assert.assertTrue; |
21 | | -import static org.junit.Assert.fail; |
| 21 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 22 | +import static org.hamcrest.Matchers.everyItem; |
| 23 | +import static org.hamcrest.Matchers.equalTo; |
22 | 24 | import static org.mockito.Matchers.anyString; |
23 | 25 | import static org.mockito.Mockito.mock; |
24 | 26 | import static org.mockito.Mockito.when; |
@@ -211,15 +213,7 @@ public void checkStrictModeWithCurrentAccountVmsPresent() throws InsufficientSer |
211 | 213 | // Check cluster 2 and 3 are not in the cluster list. |
212 | 214 | // Host 6 and 7 should also be in avoid list. |
213 | 215 | assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); |
214 | | - boolean foundNeededCluster = false; |
215 | | - for (Long cluster : clusterList) { |
216 | | - if (cluster != 1) { |
217 | | - fail("Found a cluster that shouldn't have been present, cluster id : " + cluster); |
218 | | - } else { |
219 | | - foundNeededCluster = true; |
220 | | - } |
221 | | - } |
222 | | - assertTrue("Didn't find cluster 1 in the list. It should have been present", foundNeededCluster); |
| 216 | + assertThat("Found cluster that shouldn't have been present, only cluster 1 should be present", clusterList, everyItem(equalTo(1L))); |
223 | 217 |
|
224 | 218 | Set<Long> hostsInAvoidList = avoids.getHostsToAvoid(); |
225 | 219 | assertFalse("Host 5 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(5L)); |
@@ -248,15 +242,7 @@ public void checkStrictModeHostWithCurrentAccountVmsFull() throws InsufficientSe |
248 | 242 | // Check cluster 1 and 3 are not in the cluster list. |
249 | 243 | // Host 5 and 7 should also be in avoid list. |
250 | 244 | assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); |
251 | | - boolean foundNeededCluster = false; |
252 | | - for (Long cluster : clusterList) { |
253 | | - if (cluster != 2) { |
254 | | - fail("Found a cluster that shouldn't have been present, cluster id : " + cluster); |
255 | | - } else { |
256 | | - foundNeededCluster = true; |
257 | | - } |
258 | | - } |
259 | | - assertTrue("Didn't find cluster 2 in the list. It should have been present", foundNeededCluster); |
| 245 | + assertThat("Found cluster that shouldn't have been present, only cluster 2 should be present", clusterList, everyItem(equalTo(2L))); |
260 | 246 |
|
261 | 247 | Set<Long> hostsInAvoidList = avoids.getHostsToAvoid(); |
262 | 248 | assertFalse("Host 6 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(6L)); |
@@ -307,15 +293,7 @@ public void checkPreferredModePreferredHostAvailable() throws InsufficientServer |
307 | 293 | // Check cluster 1 and 2 are not in the cluster list. |
308 | 294 | // Host 5 and 6 should also be in avoid list. |
309 | 295 | assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); |
310 | | - boolean foundNeededCluster = false; |
311 | | - for (Long cluster : clusterList) { |
312 | | - if (cluster != 3) { |
313 | | - fail("Found a cluster that shouldn't have been present, cluster id : " + cluster); |
314 | | - } else { |
315 | | - foundNeededCluster = true; |
316 | | - } |
317 | | - } |
318 | | - assertTrue("Didn't find cluster 3 in the list. It should have been present", foundNeededCluster); |
| 296 | + assertThat("Found cluster that shouldn't have been present, only cluster 3 should be present", clusterList, everyItem(equalTo(3L))); |
319 | 297 |
|
320 | 298 | Set<Long> hostsInAvoidList = avoids.getHostsToAvoid(); |
321 | 299 | assertFalse("Host 7 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(7L)); |
|
0 commit comments