Merge changes I79cfa5b6,I9e67bf58,If5441d01

* changes:
  Inline one-liner utility AbstractDaemonTest#changeIds
  Push AbstractDaemonTest#getActions and #getETag down
  Remove single-use method AbstractDaemonTest#blockForgeCommitter
This commit is contained in:
hanwen
2018-04-18 11:04:35 +00:00
committed by Gerrit Code Review
4 changed files with 18 additions and 23 deletions

View File

@@ -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;
@@ -1108,12 +1107,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);
@@ -1127,26 +1120,18 @@ public abstract class AbstractDaemonTest {
gApi.changes().id(id).revision("current").review(ReviewInput.recommend());
}
protected Map<String, ActionInfo> 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<String> changeIds(Iterable<ChangeInfo> changes) {
return Iterables.transform(changes, i -> i.changeId);
}
protected void assertSubmittedTogether(String chId, String... expected) throws Exception {
List<ChangeInfo> 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 {

View File

@@ -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(

View File

@@ -71,6 +71,14 @@ public class ActionsIT extends AbstractDaemonTest {
}
}
protected Map<String, ActionInfo> 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();

View File

@@ -122,7 +122,9 @@ public class SubmitByFastForwardIT extends AbstractSubmit {
PushOneCommit.Result change2 = createChange("Change 2", "b.txt", "other content");
approve(change2.getChangeId());
Map<String, ActionInfo> actions = getActions(change2.getChangeId());
Map<String, ActionInfo> actions =
gApi.changes().id(change2.getChangeId()).revision(1).actions();
assertThat(actions).containsKey("submit");
ActionInfo info = actions.get("submit");