use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.
the class SubmittedTogetherIT method doesNotIncludeCurrentFiles.
@Test
public void doesNotIncludeCurrentFiles() throws Exception {
RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create();
RevCommit c2_1 = commitBuilder().add("b.txt", "2").message("subject: 2").create();
String id2 = getChangeId(c2_1);
pushHead(testRepo, "refs/for/master", false);
SubmittedTogetherInfo info = gApi.changes().id(id2).submittedTogether(EnumSet.of(NON_VISIBLE_CHANGES));
assertThat(info.changes).hasSize(2);
assertThat(info.changes.get(0).currentRevision).isEqualTo(c2_1.name());
assertThat(info.changes.get(1).currentRevision).isEqualTo(c1_1.name());
RevisionInfo rev = info.changes.get(0).revisions.get(c2_1.name());
assertThat(rev.files).isNull();
}
use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.
the class ActionsIT method currentRevisionActionVisitor.
@Test
public void currentRevisionActionVisitor() throws Exception {
String id = createChange().getChangeId();
amendChange(id);
ChangeInfo origChange = gApi.changes().id(id).get(CHANGE_ACTIONS);
Change.Id changeId = Change.id(origChange._number);
class Visitor implements ActionVisitor {
@Override
public boolean visit(String name, ActionInfo actionInfo, ChangeInfo changeInfo) {
// Do nothing; implicitly called for CURRENT_ACTIONS.
return true;
}
@Override
public boolean visit(String name, ActionInfo actionInfo, ChangeInfo changeInfo, RevisionInfo revisionInfo) {
assertThat(changeInfo).isNotNull();
assertThat(changeInfo._number).isEqualTo(origChange._number);
assertThat(revisionInfo).isNotNull();
assertThat(revisionInfo._number).isEqualTo(2);
if (name.equals("cherrypick")) {
return false;
}
if (name.equals("rebase")) {
actionInfo.label = "All Your Base";
}
return true;
}
}
Map<String, ActionInfo> origActions = gApi.changes().id(id).current().actions();
assertThat(origActions.keySet()).containsAtLeast("cherrypick", "rebase");
assertThat(origActions.get("rebase").label).isEqualTo("Rebase");
try (Registration registration = extensionRegistry.newRegistration().add(new Visitor())) {
// Test different codepaths within ActionJson...
// ...via revision API.
visitedCurrentRevisionActionsAssertions(origActions, gApi.changes().id(id).current().actions());
// ...via change API with option.
EnumSet<ListChangesOption> opts = EnumSet.of(CURRENT_ACTIONS, CURRENT_REVISION);
ChangeInfo changeInfo = gApi.changes().id(id).get(opts);
RevisionInfo revisionInfo = Iterables.getOnlyElement(changeInfo.revisions.values());
visitedCurrentRevisionActionsAssertions(origActions, revisionInfo.actions);
// ...via ChangeJson directly.
ChangeData cd = changeDataFactory.create(project, changeId);
revisionJsonFactory.create(opts).getRevisionInfo(cd, cd.patchSet(PatchSet.id(changeId, 1)));
}
}
use of com.google.gerrit.extensions.common.RevisionInfo 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");
}
}
use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.
the class ChangeOperationsImplTest method newPatchsetCanBeCreatedWithoutSpecifyingAnyParameters.
@Test
public void newPatchsetCanBeCreatedWithoutSpecifyingAnyParameters() throws Exception {
Change.Id changeId = changeOperations.newChange().create();
ChangeInfo unmodifiedChange = getChangeFromServer(changeId);
int originalPatchsetCount = unmodifiedChange.revisions.size();
PatchSet.Id patchsetId = changeOperations.change(changeId).newPatchset().create();
ChangeInfo change = getChangeFromServer(changeId);
assertThatMap(change.revisions).hasSize(originalPatchsetCount + 1);
RevisionInfo currentRevision = change.revisions.get(change.currentRevision);
assertThat(currentRevision._number).isEqualTo(patchsetId.get());
}
Aggregations