Add comments for null parameters in changed file tests
This improves the test readability.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I2c6426fe89332df26e042592b994e9ef00c1f1c4
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java
index 6abb86e..a1ac734 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFileTest.java
@@ -44,14 +44,14 @@
@Test
public void getNewPath_diffEntry() throws Exception {
String newPath = "foo/bar/baz.txt";
- setupDiffEntry(newPath, null, ChangeType.ADD);
+ setupDiffEntry(newPath, /* oldPath= */ null, ChangeType.ADD);
assertThat(ChangedFile.create(diffEntry).newPath()).value().isEqualTo(Paths.get("/" + newPath));
}
@Test
public void getNewPath_patchListEntry() throws Exception {
String newPath = "foo/bar/baz.txt";
- setupPatchListEntry(newPath, null, Patch.ChangeType.ADDED);
+ setupPatchListEntry(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED);
assertThat(ChangedFile.create(patchListEntry).newPath())
.value()
.isEqualTo(Paths.get("/" + newPath));
@@ -59,20 +59,20 @@
@Test
public void getNewPathWhenNewPathIsNotSet_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.ADD);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.ADD);
assertThat(ChangedFile.create(diffEntry).newPath()).isEmpty();
}
@Test
public void getNewPathWhenNewPathIsNotSet_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.ADDED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.ADDED);
assertThat(ChangedFile.create(patchListEntry).newPath()).isEmpty();
}
@Test
public void hasNewPath_diffEntry() throws Exception {
String newPath = "foo/bar/baz.txt";
- setupDiffEntry(newPath, null, ChangeType.ADD);
+ setupDiffEntry(newPath, /* oldPath= */ null, ChangeType.ADD);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.hasNewPath(Paths.get("/" + newPath))).isTrue();
@@ -82,7 +82,7 @@
@Test
public void hasNewPath_patchListEntry() throws Exception {
String newPath = "foo/bar/baz.txt";
- setupPatchListEntry(newPath, null, Patch.ChangeType.ADDED);
+ setupPatchListEntry(newPath, /* oldPath= */ null, Patch.ChangeType.ADDED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.hasNewPath(Paths.get("/" + newPath))).isTrue();
@@ -91,28 +91,30 @@
@Test
public void cannotCheckHasNewPathWithNull_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.ADD);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.ADD);
NullPointerException npe =
assertThrows(
- NullPointerException.class, () -> ChangedFile.create(diffEntry).hasNewPath(null));
+ NullPointerException.class,
+ () -> ChangedFile.create(diffEntry).hasNewPath(/* absolutePath= */ null));
assertThat(npe).hasMessageThat().isEqualTo("absolutePath");
}
@Test
public void cannotCheckHasNewPathWithNull_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.ADDED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.ADDED);
NullPointerException npe =
assertThrows(
- NullPointerException.class, () -> ChangedFile.create(patchListEntry).hasNewPath(null));
+ NullPointerException.class,
+ () -> ChangedFile.create(patchListEntry).hasNewPath(/* absolutePath= */ null));
assertThat(npe).hasMessageThat().isEqualTo("absolutePath");
}
@Test
public void cannotCheckHasNewPathWithRelativePath_diffEntry() throws Exception {
String relativePath = "foo/bar/baz.txt";
- setupDiffEntry(null, null, ChangeType.ADD);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.ADD);
IllegalStateException exception =
assertThrows(
IllegalStateException.class,
@@ -125,7 +127,7 @@
@Test
public void cannotCheckHasNewPathWithRelativePath_patchListEntry() throws Exception {
String relativePath = "foo/bar/baz.txt";
- setupPatchListEntry(null, null, Patch.ChangeType.ADDED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.ADDED);
IllegalStateException exception =
assertThrows(
IllegalStateException.class,
@@ -138,14 +140,14 @@
@Test
public void getOldPath_diffEntry() throws Exception {
String oldPath = "foo/bar/baz.txt";
- setupDiffEntry(null, oldPath, ChangeType.DELETE);
+ setupDiffEntry(/* newPath= */ null, oldPath, ChangeType.DELETE);
assertThat(ChangedFile.create(diffEntry).oldPath()).value().isEqualTo(Paths.get("/" + oldPath));
}
@Test
public void getOldPath_patchListEntry() throws Exception {
String oldPath = "foo/bar/baz.txt";
- setupPatchListEntry(null, oldPath, Patch.ChangeType.DELETED);
+ setupPatchListEntry(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED);
assertThat(ChangedFile.create(patchListEntry).oldPath())
.value()
.isEqualTo(Paths.get("/" + oldPath));
@@ -153,21 +155,21 @@
@Test
public void getOldPathWhenOldPathIsNotSet_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.DELETE);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.DELETE);
when(diffEntry.getOldPath()).thenReturn(DiffEntry.DEV_NULL);
assertThat(ChangedFile.create(diffEntry).oldPath()).isEmpty();
}
@Test
public void getOldPathWhenOldPathIsNotSet_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.DELETED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.DELETED);
assertThat(ChangedFile.create(patchListEntry).oldPath()).isEmpty();
}
@Test
public void hasOldPath_diffEntry() throws Exception {
String oldPath = "foo/bar/baz.txt";
- setupDiffEntry(null, oldPath, ChangeType.DELETE);
+ setupDiffEntry(/* newPath= */ null, oldPath, ChangeType.DELETE);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.hasOldPath(Paths.get("/" + oldPath))).isTrue();
@@ -177,7 +179,7 @@
@Test
public void hasOldPath_patchListEntry() throws Exception {
String oldPath = "foo/bar/baz.txt";
- setupPatchListEntry(null, oldPath, Patch.ChangeType.DELETED);
+ setupPatchListEntry(/* newPath= */ null, oldPath, Patch.ChangeType.DELETED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.hasOldPath(Paths.get("/" + oldPath))).isTrue();
@@ -186,25 +188,27 @@
@Test
public void cannotCheckHasOldPathWithNull_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.DELETE);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.DELETE);
NullPointerException npe =
assertThrows(
- NullPointerException.class, () -> ChangedFile.create(diffEntry).hasOldPath(null));
+ NullPointerException.class,
+ () -> ChangedFile.create(diffEntry).hasOldPath(/* absolutePath= */ null));
assertThat(npe).hasMessageThat().isEqualTo("absolutePath");
}
@Test
public void cannotCheckHasOldPathWithNull_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.DELETED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.DELETED);
NullPointerException npe =
assertThrows(
- NullPointerException.class, () -> ChangedFile.create(patchListEntry).hasOldPath(null));
+ NullPointerException.class,
+ () -> ChangedFile.create(patchListEntry).hasOldPath(/* absolutePath= */ null));
assertThat(npe).hasMessageThat().isEqualTo("absolutePath");
}
@Test
public void cannotCheckHasOldPathWithRelativePath_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.DELETE);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.DELETE);
String relativePath = "foo/bar/baz.txt";
IllegalStateException exception =
assertThrows(
@@ -217,7 +221,7 @@
@Test
public void cannotCheckHasOldPathWithRelativePath_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.DELETED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.DELETED);
String relativePath = "foo/bar/baz.txt";
IllegalStateException exception =
assertThrows(
@@ -230,7 +234,7 @@
@Test
public void isRename_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.RENAME);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.RENAME);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.isRename()).isTrue();
assertThat(changedFile.isDeletion()).isFalse();
@@ -238,7 +242,7 @@
@Test
public void isRename_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.RENAMED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.RENAMED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.isRename()).isTrue();
assertThat(changedFile.isDeletion()).isFalse();
@@ -246,7 +250,7 @@
@Test
public void isDeletion_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.DELETE);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.DELETE);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isTrue();
@@ -254,7 +258,7 @@
@Test
public void isDeletion_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.DELETED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.DELETED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isTrue();
@@ -262,7 +266,7 @@
@Test
public void isAddition_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.ADD);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.ADD);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isFalse();
@@ -270,7 +274,7 @@
@Test
public void isAddition_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.ADDED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.ADDED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isFalse();
@@ -278,7 +282,7 @@
@Test
public void isModify_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.MODIFY);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.MODIFY);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isFalse();
@@ -286,7 +290,7 @@
@Test
public void isModify_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.MODIFIED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.MODIFIED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isFalse();
@@ -294,7 +298,7 @@
@Test
public void isCopy_diffEntry() throws Exception {
- setupDiffEntry(null, null, ChangeType.COPY);
+ setupDiffEntry(/* newPath= */ null, /* oldPath= */ null, ChangeType.COPY);
ChangedFile changedFile = ChangedFile.create(diffEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isFalse();
@@ -302,7 +306,7 @@
@Test
public void isCopy_patchListEntry() throws Exception {
- setupPatchListEntry(null, null, Patch.ChangeType.COPIED);
+ setupPatchListEntry(/* newPath= */ null, /* oldPath= */ null, Patch.ChangeType.COPIED);
ChangedFile changedFile = ChangedFile.create(patchListEntry);
assertThat(changedFile.isRename()).isFalse();
assertThat(changedFile.isDeletion()).isFalse();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java
index 2bbc4f4..8e70676 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/ChangedFilesTest.java
@@ -66,7 +66,8 @@
@Test
public void cannotComputeForNullRevisionResource() throws Exception {
NullPointerException npe =
- assertThrows(NullPointerException.class, () -> changedFiles.compute(null));
+ assertThrows(
+ NullPointerException.class, () -> changedFiles.compute(/* revisionResource= */ null));
assertThat(npe).hasMessageThat().isEqualTo("revisionResource");
}
@@ -74,14 +75,16 @@
public void cannotComputeForNullProject() throws Exception {
NullPointerException npe =
assertThrows(
- NullPointerException.class, () -> changedFiles.compute(null, ObjectId.zeroId()));
+ NullPointerException.class,
+ () -> changedFiles.compute(/* project= */ null, ObjectId.zeroId()));
assertThat(npe).hasMessageThat().isEqualTo("project");
}
@Test
public void cannotComputeForNullRevision() throws Exception {
NullPointerException npe =
- assertThrows(NullPointerException.class, () -> changedFiles.compute(project, null));
+ assertThrows(
+ NullPointerException.class, () -> changedFiles.compute(project, /* revision= */ null));
assertThat(npe).hasMessageThat().isEqualTo("revision");
}