|
36 | 36 | import java.util.Map; |
37 | 37 | import java.util.Optional; |
38 | 38 | import org.testng.annotations.BeforeMethod; |
| 39 | +import org.testng.annotations.DataProvider; |
39 | 40 | import org.testng.annotations.Test; |
40 | 41 |
|
41 | 42 |
|
@@ -364,43 +365,34 @@ public void testListStoresWithDataReplicationPolicyFilterNullPolicy() { |
364 | 365 | assertEquals(response.getStoreNamesCount(), 0); |
365 | 366 | } |
366 | 367 |
|
367 | | - @Test |
368 | | - public void testGetClusterHealthStoresSuccess() { |
369 | | - Map<String, String> storeStatusMap = new HashMap<>(); |
370 | | - storeStatusMap.put("store1", "ONLINE"); |
371 | | - storeStatusMap.put("store2", "DEGRADED"); |
372 | | - storeStatusMap.put("store3", "UNAVAILABLE"); |
373 | | - when(admin.getAllStoreStatuses("testCluster")).thenReturn(storeStatusMap); |
374 | | - |
375 | | - MultiStoreStatusResponse response = storeRequestHandler.getClusterHealthStores("testCluster"); |
376 | | - |
377 | | - verify(admin, times(1)).getAllStoreStatuses("testCluster"); |
378 | | - assertEquals(response.getCluster(), "testCluster"); |
379 | | - assertEquals(response.getStoreStatusMap().size(), 3); |
380 | | - assertEquals(response.getStoreStatusMap().get("store1"), "ONLINE"); |
381 | | - assertEquals(response.getStoreStatusMap().get("store2"), "DEGRADED"); |
382 | | - assertEquals(response.getStoreStatusMap().get("store3"), "UNAVAILABLE"); |
| 368 | + @DataProvider(name = "storeStatusMaps") |
| 369 | + public Object[][] storeStatusMaps() { |
| 370 | + Map<String, String> populatedMap = new HashMap<>(); |
| 371 | + populatedMap.put("store1", "ONLINE"); |
| 372 | + populatedMap.put("store2", "DEGRADED"); |
| 373 | + populatedMap.put("store3", "UNAVAILABLE"); |
| 374 | + return new Object[][] { { populatedMap }, { Collections.emptyMap() } }; |
383 | 375 | } |
384 | 376 |
|
385 | | - @Test |
386 | | - public void testGetClusterHealthStoresEmptyMap() { |
387 | | - when(admin.getAllStoreStatuses("testCluster")).thenReturn(Collections.emptyMap()); |
| 377 | + @Test(dataProvider = "storeStatusMaps") |
| 378 | + public void testGetClusterHealthStores(Map<String, String> expectedStatusMap) { |
| 379 | + when(admin.getAllStoreStatuses("testCluster")).thenReturn(expectedStatusMap); |
388 | 380 |
|
389 | 381 | MultiStoreStatusResponse response = storeRequestHandler.getClusterHealthStores("testCluster"); |
390 | 382 |
|
391 | 383 | verify(admin, times(1)).getAllStoreStatuses("testCluster"); |
392 | 384 | assertEquals(response.getCluster(), "testCluster"); |
393 | | - assertEquals(response.getStoreStatusMap().size(), 0); |
| 385 | + assertEquals(response.getStoreStatusMap(), expectedStatusMap); |
394 | 386 | } |
395 | 387 |
|
396 | | - @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Cluster name is required") |
397 | | - public void testGetClusterHealthStoresMissingClusterName() { |
398 | | - storeRequestHandler.getClusterHealthStores(null); |
| 388 | + @DataProvider(name = "blankClusterNames") |
| 389 | + public Object[][] blankClusterNames() { |
| 390 | + return new Object[][] { { null }, { "" } }; |
399 | 391 | } |
400 | 392 |
|
401 | | - @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Cluster name is required") |
402 | | - public void testGetClusterHealthStoresEmptyClusterName() { |
403 | | - storeRequestHandler.getClusterHealthStores(""); |
| 393 | + @Test(dataProvider = "blankClusterNames", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Cluster name is required") |
| 394 | + public void testGetClusterHealthStoresWithBlankClusterName(String clusterName) { |
| 395 | + storeRequestHandler.getClusterHealthStores(clusterName); |
404 | 396 | } |
405 | 397 |
|
406 | 398 | @Test |
|
0 commit comments