hemantk-12 commented on code in PR #3993:
URL: https://github.com/apache/ozone/pull/3993#discussion_r1037455173
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java:
##########
@@ -688,21 +707,44 @@ public void testListSnapshot() throws Exception {
}
}
- //Test listing snapshots with no volume name.
- Assert.assertThrows(OMException.class, () ->
omMetadataManager.listSnapshot(
- null, null));
-
- //Test listing snapshots with no bucket name.
- Assert.assertThrows(OMException.class, () ->
omMetadataManager.listSnapshot(
- vol1, null));
-
//Test listing all snapshots.
List<SnapshotInfo> snapshotInfos = omMetadataManager.listSnapshot(vol1,
bucket1);
- Assert.assertEquals(10, snapshotInfos.size());
+ assertEquals(10, snapshotInfos.size());
for (SnapshotInfo snapshotInfo : snapshotInfos) {
- Assert.assertTrue(snapshotInfo.getName().startsWith(snapshotName));
+ assertTrue(snapshotInfo.getName().startsWith(snapshotName));
+ }
+
+ }
+
+ @ParameterizedTest
+ @NullSource
+ @ValueSource(strings = { "nonexistentBucket"})
+ public void testListSnapshotWithInvalidPath(String invalidBucket)
Review Comment:
Test, you wrote, defeats the whole purpose of parameterized test. Please
rewrite it like following.
```suggestion
private static Stream<Arguments> listSnapshotWithInvalidPathCases() {
return Stream.of(
Arguments.of("Test 1: Volume is null.", null, null,
VOLUME_NOT_FOUND),
Arguments.of("Test 2: Bucket is null.", "vol1", null,
BUCKET_NOT_FOUND),
Arguments.of("Test 3: Bucket is invalid.", "vol1", "buck",
BUCKET_NOT_FOUND)
);
}
@ParameterizedTest(name = "{0}")
@MethodSource("listSnapshotWithInvalidPathCases")
public void testListSnapshotWithInvalidPath(String description,
String volume,
String bucket,
ResultCodes expectedResultCode)
throws Exception {
String vol1 = "vol1";
String bucket1 = "bucket1";
OMRequestTestUtils.addVolumeToDB(vol1, omMetadataManager);
addBucketsToCache(vol1, bucket1);
OMException omException = assertThrows(OMException.class,
() -> omMetadataManager.listSnapshot(volume, bucket));
assertEquals(expectedResultCode, omException.getResult());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]