StickyApprovalsIT: Rename common private test methods to test<NAME>
If 2 (or more) tests share the same implementation, except setup, they
usually have the same name, but with a different suffix (e.g.
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded_withoutCopyCondition
and
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded_withCopyCondition).
Both methods delegate to the same private method to do the assertions.
Usually this method has the same name as the test methods without the
suffix, but prefixed with 'test' (e.g.
testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded).
The test prefix ensures that these methods can be easily distinguished
from the public test methods that represent test cases (e.g. you can
easier recognize that this is the shared test implementation, rather
than another test case).
Rename the common private test methods to follow this name schema.
Also make sure that the test methods and their common private test
method are always defined next to each other.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ib4bce63d17c39b1d1306be8bd1d83fab830a9929
Release-Notes: skip
diff --git a/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java b/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java
index ade5414..664f17b 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java
@@ -349,17 +349,17 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded();
}
@Test
public void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded_withCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded();
}
- private void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded()
+ private void testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsAdded()
throws Exception {
Change.Id changeId =
changeOperations.newChange().project(project).file("file").content("content").create();
@@ -384,7 +384,7 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists();
}
@Test
@@ -392,10 +392,10 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists_withCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists();
}
- private void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists()
+ private void testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists()
throws Exception {
// create "existing file" and submit it.
String existingFile = "existing file";
@@ -432,7 +432,7 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted();
}
@Test
@@ -440,10 +440,10 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted_withCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted();
}
- private void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted()
+ private void testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsDeleted()
throws Exception {
Change.Id changeId =
changeOperations.newChange().project(project).file("file").content("content").create();
@@ -463,7 +463,30 @@
stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified();
+ testStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified();
+ }
+
+ @Test
+ public void stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified_withCopyCondition()
+ throws Exception {
+ updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
+ testStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified();
+ }
+
+ private void testStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified()
+ throws Exception {
+ Change.Id changeId =
+ changeOperations.newChange().project(project).file("file").content("content").create();
+ vote(admin, changeId.toString(), 2, 1);
+ vote(user, changeId.toString(), -2, -1);
+
+ changeOperations.change(changeId).newPatchset().file("file").content("new content").create();
+ ChangeInfo c = detailedChange(changeId.toString());
+
+ // only code review votes are copied since copyAllScoresIfListOfFilesDidNotChange is
+ // configured for that label, and list of files didn't change.
+ assertVotes(c, admin, 2, 0);
+ assertVotes(c, user, -2, 0);
}
@Test
@@ -503,35 +526,12 @@
}
@Test
- public void stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified_withCopyCondition()
- throws Exception {
- updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified();
- }
-
- private void stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModified()
- throws Exception {
- Change.Id changeId =
- changeOperations.newChange().project(project).file("file").content("content").create();
- vote(admin, changeId.toString(), 2, 1);
- vote(user, changeId.toString(), -2, -1);
-
- changeOperations.change(changeId).newPatchset().file("file").content("new content").create();
- ChangeInfo c = detailedChange(changeId.toString());
-
- // only code review votes are copied since copyAllScoresIfListOfFilesDidNotChange is
- // configured for that label, and list of files didn't change.
- assertVotes(c, admin, 2, 0);
- assertVotes(c, user, -2, 0);
- }
-
- @Test
@TestProjectInput(createEmptyCommit = false)
public void
stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit();
+ testStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit();
}
@Test
@@ -540,11 +540,12 @@
stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit_withCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit();
+ testStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit();
}
- private void stickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit()
- throws Exception {
+ private void
+ testStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedAsInitialCommit()
+ throws Exception {
Change.Id changeId =
changeOperations.newChange().project(project).file("file").content("content").create();
vote(admin, changeId.toString(), 2, 1);
@@ -564,7 +565,7 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset();
}
@Test
@@ -572,11 +573,11 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset_withCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset();
}
private void
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset()
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsModifiedOnEarlierPatchset()
throws Exception {
Change.Id changeId =
changeOperations.newChange().project(project).file("file").content("content").create();
@@ -602,7 +603,7 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed_withoutCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed();
}
@Test
@@ -610,10 +611,10 @@
notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed_withCopyCondition()
throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed();
+ testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed();
}
- private void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed()
+ private void testNotStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed()
throws Exception {
Change.Id changeId =
changeOperations.newChange().project(project).file("file").content("content").create();
@@ -631,16 +632,16 @@
@Test
public void copyWithListOfFilesUnchanged_withoutCopyCondition() throws Exception {
updateCodeReviewLabel(b -> b.setCopyAllScoresIfListOfFilesDidNotChange(true));
- copyWithListOfFilesUnchanged();
+ testCopyWithListOfFilesUnchanged();
}
@Test
public void copyWithListOfFilesUnchanged_withCopyCondition() throws Exception {
updateCodeReviewLabel(b -> b.setCopyCondition("has:unchanged-files"));
- copyWithListOfFilesUnchanged();
+ testCopyWithListOfFilesUnchanged();
}
- private void copyWithListOfFilesUnchanged() throws Exception {
+ private void testCopyWithListOfFilesUnchanged() throws Exception {
Change.Id changeId =
changeOperations.newChange().project(project).file("file").content("content").create();
vote(admin, changeId.toString(), 2, 1);