Search in sources :

Example 1 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method suppressRevertNotifications.

@Test
public void suppressRevertNotifications() throws Exception {
    PushOneCommit.Result r = createChange();
    gApi.changes().id(r.getChangeId()).addReviewer(user.email());
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
    RevertInput revertInput = new RevertInput();
    revertInput.notify = NotifyHandling.NONE;
    sender.clear();
    gApi.changes().id(r.getChangeId()).revert(revertInput).get();
    assertThat(sender.getMessages()).isEmpty();
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertSubmissionWipNotificationsWithNotifyHandlingAll.

@Test
public void revertSubmissionWipNotificationsWithNotifyHandlingAll() throws Exception {
    String changeId1 = createChange("first change", "a.txt", "message").getChangeId();
    approve(changeId1);
    gApi.changes().id(changeId1).addReviewer(user.email());
    String changeId2 = createChange("second change", "b.txt", "other").getChangeId();
    approve(changeId2);
    gApi.changes().id(changeId2).addReviewer(user.email());
    gApi.changes().id(changeId2).current().submit();
    sender.clear();
    // If notify handling is specified, it will be used by the API
    RevertInput revertInput = createWipRevertInput();
    revertInput.notify = NotifyHandling.ALL;
    gApi.changes().id(changeId2).revertSubmission(revertInput);
    assertThat(sender.getMessages()).hasSize(4);
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertChangeWithLongSubject.

@Test
public void revertChangeWithLongSubject() throws Exception {
    String changeTitle = "This change has a very long title and therefore it will be cut to 50 characters when the" + " revert change will revert this change";
    String result = createChange(changeTitle, "a.txt", "message").getChangeId();
    gApi.changes().id(result).current().review(ReviewInput.approve());
    gApi.changes().id(result).current().submit();
    RevertInput revertInput = new RevertInput();
    ChangeInfo revertChange = gApi.changes().id(result).revert(revertInput).get();
    assertThat(revertChange.subject).isEqualTo(String.format("Revert \"%s...\"", changeTitle.substring(0, 59)));
    assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Revert \"%s...\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n", changeTitle.substring(0, 59), gApi.changes().id(result).get().currentRevision, revertChange.changeId));
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertSubmissionWipMarksAllChangesAsWip.

@Test
public void revertSubmissionWipMarksAllChangesAsWip() throws Exception {
    String changeId1 = createChange("first change", "a.txt", "message").getChangeId();
    approve(changeId1);
    gApi.changes().id(changeId1).addReviewer(user.email());
    String changeId2 = createChange("second change", "b.txt", "other").getChangeId();
    approve(changeId2);
    gApi.changes().id(changeId2).addReviewer(user.email());
    gApi.changes().id(changeId2).current().submit();
    sender.clear();
    RevertInput revertInput = createWipRevertInput();
    RevertSubmissionInfo revertSubmissionInfo = gApi.changes().id(changeId2).revertSubmission(revertInput);
    assertThat(revertSubmissionInfo.revertChanges.stream().allMatch(r -> r.workInProgress)).isTrue();
}
Also used : RevertSubmissionInfo(com.google.gerrit.extensions.common.RevertSubmissionInfo) RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertNotificationsSupressedOnWip.

@Test
public void revertNotificationsSupressedOnWip() throws Exception {
    PushOneCommit.Result r = createChange();
    gApi.changes().id(r.getChangeId()).addReviewer(user.email());
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
    sender.clear();
    // If notify input not specified, the endpoint overrides it to OWNER
    RevertInput revertInput = createWipRevertInput();
    revertInput.notify = null;
    gApi.changes().id(r.getChangeId()).revert(revertInput).get();
    assertThat(sender.getMessages()).isEmpty();
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

RevertInput (com.google.gerrit.extensions.api.changes.RevertInput)22 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)20 Test (org.junit.Test)20 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)9 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)7 RevertSubmissionInfo (com.google.gerrit.extensions.common.RevertSubmissionInfo)3 MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)1 Strings (com.google.common.base.Strings)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Iterables (com.google.common.collect.Iterables)1 Multimap (com.google.common.collect.Multimap)1 FluentLogger (com.google.common.flogger.FluentLogger)1 BranchNameKey (com.google.gerrit.entities.BranchNameKey)1 Change (com.google.gerrit.entities.Change)1 Project (com.google.gerrit.entities.Project)1 RefNames (com.google.gerrit.entities.RefNames)1 StorageException (com.google.gerrit.exceptions.StorageException)1 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)1 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)1 NotifyHandling (com.google.gerrit.extensions.api.changes.NotifyHandling)1