From 990254c6745fdcd7e18e62bc65cfe9ad6751fdad Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 18 Apr 2018 10:43:04 +0200 Subject: [PATCH 1/3] Remove single-use method AbstractDaemonTest#blockForgeCommitter Change-Id: If5441d0156d3394bc1ea66c97aaf1d22d088e56d --- java/com/google/gerrit/acceptance/AbstractDaemonTest.java | 6 ------ .../google/gerrit/acceptance/git/AbstractPushForReview.java | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java index 8c38f5e926..a2497c7208 100644 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@ -1108,12 +1108,6 @@ public abstract class AbstractDaemonTest { block(ref, Permission.READ, REGISTERED_USERS); } - protected void blockForgeCommitter(Project.NameKey project, String ref) throws Exception { - ProjectConfig cfg = projectCache.checkedGet(project).getConfig(); - Util.block(cfg, Permission.FORGE_COMMITTER, REGISTERED_USERS, ref); - saveProjectConfig(project, cfg); - } - protected PushOneCommit.Result pushTo(String ref) throws Exception { PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo); return push.to(ref); diff --git a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java index 2ae4133fb4..ec68b05661 100644 --- a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java +++ b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java @@ -1116,7 +1116,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { r.assertOkStatus(); setUseSignedOffBy(InheritableBoolean.TRUE); - blockForgeCommitter(project, "refs/heads/master"); + block(project, "refs/heads/master", Permission.FORGE_COMMITTER, REGISTERED_USERS); push = pushFactory.create( From ffd7001cd7562eb22659903333dc8d4fd4befaf3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 18 Apr 2018 10:51:45 +0200 Subject: [PATCH 2/3] Push AbstractDaemonTest#getActions and #getETag down They are used rarely so have to be in AbstractDaemonTest Change-Id: I9e67bf585d555d4e7d8be2f6b9d16b474d8ad9ac --- .../com/google/gerrit/acceptance/AbstractDaemonTest.java | 9 --------- .../google/gerrit/acceptance/rest/change/ActionsIT.java | 8 ++++++++ .../acceptance/rest/change/SubmitByFastForwardIT.java | 4 +++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java index a2497c7208..8280c38f16 100644 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@ -61,7 +61,6 @@ import com.google.gerrit.extensions.client.InheritableBoolean; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.client.ProjectWatchInfo; import com.google.gerrit.extensions.client.SubmitType; -import com.google.gerrit.extensions.common.ActionInfo; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.common.ChangeType; import com.google.gerrit.extensions.common.DiffInfo; @@ -1121,14 +1120,6 @@ public abstract class AbstractDaemonTest { gApi.changes().id(id).revision("current").review(ReviewInput.recommend()); } - protected Map getActions(String id) throws Exception { - return gApi.changes().id(id).revision(1).actions(); - } - - protected String getETag(String id) throws Exception { - return gApi.changes().id(id).current().etag(); - } - private static Iterable changeIds(Iterable changes) { return Iterables.transform(changes, i -> i.changeId); } diff --git a/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java b/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java index 066af79db3..a4eedf27eb 100644 --- a/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java +++ b/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java @@ -71,6 +71,14 @@ public class ActionsIT extends AbstractDaemonTest { } } + protected Map getActions(String id) throws Exception { + return gApi.changes().id(id).revision(1).actions(); + } + + protected String getETag(String id) throws Exception { + return gApi.changes().id(id).current().etag(); + } + @Test public void revisionActionsOneChangePerTopicUnapproved() throws Exception { String changeId = createChangeWithTopic().getChangeId(); diff --git a/javatests/com/google/gerrit/acceptance/rest/change/SubmitByFastForwardIT.java b/javatests/com/google/gerrit/acceptance/rest/change/SubmitByFastForwardIT.java index 2ebf3caa28..ea8b98a839 100644 --- a/javatests/com/google/gerrit/acceptance/rest/change/SubmitByFastForwardIT.java +++ b/javatests/com/google/gerrit/acceptance/rest/change/SubmitByFastForwardIT.java @@ -122,7 +122,9 @@ public class SubmitByFastForwardIT extends AbstractSubmit { PushOneCommit.Result change2 = createChange("Change 2", "b.txt", "other content"); approve(change2.getChangeId()); - Map actions = getActions(change2.getChangeId()); + + Map actions = + gApi.changes().id(change2.getChangeId()).revision(1).actions(); assertThat(actions).containsKey("submit"); ActionInfo info = actions.get("submit"); From 4c91005a159fb1c4c8132dab24ca7be59740acb1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 18 Apr 2018 10:53:35 +0200 Subject: [PATCH 3/3] Inline one-liner utility AbstractDaemonTest#changeIds Change-Id: I79cfa5b66b6ea2ae91fd1ddd92a77376606b0be6 --- .../google/gerrit/acceptance/AbstractDaemonTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java index 8280c38f16..36b61f1e65 100644 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@ -1120,18 +1120,18 @@ public abstract class AbstractDaemonTest { gApi.changes().id(id).revision("current").review(ReviewInput.recommend()); } - private static Iterable changeIds(Iterable changes) { - return Iterables.transform(changes, i -> i.changeId); - } - protected void assertSubmittedTogether(String chId, String... expected) throws Exception { List actual = gApi.changes().id(chId).submittedTogether(); SubmittedTogetherInfo info = gApi.changes().id(chId).submittedTogether(EnumSet.of(NON_VISIBLE_CHANGES)); assertThat(info.nonVisibleChanges).isEqualTo(0); - assertThat(changeIds(actual)).containsExactly((Object[]) expected).inOrder(); - assertThat(changeIds(info.changes)).containsExactly((Object[]) expected).inOrder(); + assertThat(Iterables.transform(actual, i1 -> i1.changeId)) + .containsExactly((Object[]) expected) + .inOrder(); + assertThat(Iterables.transform(info.changes, i -> i.changeId)) + .containsExactly((Object[]) expected) + .inOrder(); } protected PatchSet getPatchSet(PatchSet.Id psId) throws OrmException {