use of com.google.gerrit.extensions.common.ActionInfo in project gerrit by GerritCodeReview.
the class ActionsIT method revisionActionsTwoChangesInTopic_conflicting.
@Test
public void revisionActionsTwoChangesInTopic_conflicting() throws Exception {
String changeId = createChangeWithTopic().getChangeId();
approve(changeId);
// create another change with the same topic
String changeId2 = createChangeWithTopic(testRepo, "topic", "touching b", "b.txt", "real content").getChangeId();
int changeNum2 = gApi.changes().id(changeId2).info()._number;
approve(changeId2);
// collide with the other change in the same topic
testRepo.reset("HEAD~2");
String collidingChange = createChangeWithTopic(testRepo, "off_topic", "rewriting file b", "b.txt", "garbage\ngarbage\ngarbage").getChangeId();
gApi.changes().id(collidingChange).current().review(ReviewInput.approve());
gApi.changes().id(collidingChange).current().submit();
Map<String, ActionInfo> actions = getActions(changeId);
commonActionsAssertions(actions);
if (isSubmitWholeTopicEnabled()) {
ActionInfo info = actions.get("submit");
assertThat(info.enabled).isNull();
assertThat(info.label).isEqualTo("Submit whole topic");
assertThat(info.method).isEqualTo("POST");
assertThat(info.title).isEqualTo("Problems with change(s): " + changeNum2);
} else {
noSubmitWholeTopicAssertions(actions, 1);
}
}
use of com.google.gerrit.extensions.common.ActionInfo in project gerrit by GerritCodeReview.
the class ActionsIT method revisionActionsTwoChangesInTopic.
@Test
public void revisionActionsTwoChangesInTopic() throws Exception {
String changeId = createChangeWithTopic().getChangeId();
approve(changeId);
PushOneCommit.Result change2 = createChangeWithTopic();
int legacyId2 = change2.getChange().getId().get();
String changeId2 = change2.getChangeId();
Map<String, ActionInfo> actions = getActions(changeId);
commonActionsAssertions(actions);
if (isSubmitWholeTopicEnabled()) {
ActionInfo info = actions.get("submit");
assertThat(info.enabled).isNull();
assertThat(info.label).isEqualTo("Submit whole topic");
assertThat(info.method).isEqualTo("POST");
assertThat(info.title).matches("Change " + legacyId2 + " is not ready: submit requirement 'Code-Review' is unsatisfied.");
} else {
noSubmitWholeTopicAssertions(actions, 1);
assertThat(getActions(changeId2).get("submit")).isNull();
approve(changeId2);
noSubmitWholeTopicAssertions(getActions(changeId2), 2);
}
}
use of com.google.gerrit.extensions.common.ActionInfo in project gerrit by GerritCodeReview.
the class ActionsIT method changeActionVisitor.
@Test
public void changeActionVisitor() throws Exception {
String id = createChange().getChangeId();
ChangeInfo origChange = gApi.changes().id(id).get(CHANGE_ACTIONS);
class Visitor implements ActionVisitor {
@Override
public boolean visit(String name, ActionInfo actionInfo, ChangeInfo changeInfo) {
assertThat(changeInfo).isNotNull();
assertThat(changeInfo._number).isEqualTo(origChange._number);
if (name.equals("followup")) {
return false;
}
if (name.equals("abandon")) {
actionInfo.label = "Abandon All Hope";
}
return true;
}
@Override
public boolean visit(String name, ActionInfo actionInfo, ChangeInfo changeInfo, RevisionInfo revisionInfo) {
throw new UnsupportedOperationException();
}
}
Map<String, ActionInfo> origActions = origChange.actions;
assertThat(origActions.keySet()).containsAtLeast("followup", "abandon");
assertThat(origActions.get("abandon").label).isEqualTo("Abandon");
try (Registration registration = extensionRegistry.newRegistration().add(new Visitor())) {
Map<String, ActionInfo> newActions = gApi.changes().id(id).get(EnumSet.of(ListChangesOption.CHANGE_ACTIONS)).actions;
Set<String> expectedNames = new TreeSet<>(origActions.keySet());
expectedNames.remove("followup");
assertThat(newActions.keySet()).isEqualTo(expectedNames);
ActionInfo abandon = newActions.get("abandon");
assertThat(abandon).isNotNull();
assertThat(abandon.label).isEqualTo("Abandon All Hope");
}
}
Aggregations