Search in sources :

Example 16 with RevertInput

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

the class RevertIT method revertSubmissionNotifications.

@Test
public void revertSubmissionNotifications() throws Exception {
    String firstResult = createChange("first change", "a.txt", "message").getChangeId();
    approve(firstResult);
    gApi.changes().id(firstResult).addReviewer(user.email());
    String secondResult = createChange("second change", "b.txt", "other").getChangeId();
    approve(secondResult);
    gApi.changes().id(secondResult).addReviewer(user.email());
    gApi.changes().id(secondResult).current().submit();
    sender.clear();
    RevertInput revertInput = new RevertInput();
    revertInput.notify = NotifyHandling.ALL;
    RevertSubmissionInfo revertChanges = gApi.changes().id(secondResult).revertSubmission(revertInput);
    List<Message> messages = sender.getMessages();
    assertThat(messages).hasSize(4);
    assertThat(sender.getMessages(revertChanges.revertChanges.get(0).changeId, "newchange")).hasSize(1);
    assertThat(sender.getMessages(firstResult, "revert")).hasSize(1);
    assertThat(sender.getMessages(revertChanges.revertChanges.get(1).changeId, "newchange")).hasSize(1);
    assertThat(sender.getMessages(secondResult, "revert")).hasSize(1);
}
Also used : RevertSubmissionInfo(com.google.gerrit.extensions.common.RevertSubmissionInfo) Message(com.google.gerrit.testing.FakeEmailSender.Message) RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 17 with RevertInput

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

the class RevertIT method revertSubmissionSuppressNotificationsWithWip.

@Test
public void revertSubmissionSuppressNotificationsWithWip() throws Exception {
    String firstResult = createChange("first change", "a.txt", "message").getChangeId();
    approve(firstResult);
    gApi.changes().id(firstResult).addReviewer(user.email());
    String secondResult = createChange("second change", "b.txt", "other").getChangeId();
    approve(secondResult);
    gApi.changes().id(secondResult).addReviewer(user.email());
    gApi.changes().id(secondResult).current().submit();
    sender.clear();
    RevertInput revertInput = new RevertInput();
    revertInput.workInProgress = true;
    revertInput.notify = NotifyHandling.NONE;
    gApi.changes().id(secondResult).revertSubmission(revertInput);
    assertThat(sender.getMessages()).isEmpty();
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 18 with RevertInput

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

the class RevertIT method revertSubmissionWithSetTopic.

@Test
public void revertSubmissionWithSetTopic() throws Exception {
    String result = createChange().getChangeId();
    gApi.changes().id(result).current().review(ReviewInput.approve());
    gApi.changes().id(result).topic("topic");
    gApi.changes().id(result).current().submit();
    RevertInput revertInput = new RevertInput();
    revertInput.topic = "reverted-not-default";
    assertThat(gApi.changes().id(result).revertSubmission(revertInput).revertChanges.get(0).topic).isEqualTo(revertInput.topic);
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 19 with RevertInput

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

the class RevertIT method revertSubmissionWithSetMessage.

@Test
public void revertSubmissionWithSetMessage() throws Exception {
    String firstResult = createChange("first change", "a.txt", "message").getChangeId();
    String secondResult = createChange("second change", "b.txt", "message").getChangeId();
    approve(firstResult);
    approve(secondResult);
    gApi.changes().id(secondResult).current().submit();
    RevertInput revertInput = new RevertInput();
    String commitMessage = "Message from input";
    revertInput.message = commitMessage;
    List<ChangeInfo> revertChanges = gApi.changes().id(firstResult).revertSubmission(revertInput).revertChanges;
    assertThat(revertChanges.get(0).subject).isEqualTo("Revert \"first change\"");
    assertThat(gApi.changes().id(revertChanges.get(0).id).current().commit(false).message).isEqualTo(String.format("Revert \"first change\"\n\n%s\n\nChange-Id: %s\n", commitMessage, revertChanges.get(0).changeId));
    assertThat(revertChanges.get(1).subject).isEqualTo("Revert \"second change\"");
    assertThat(gApi.changes().id(revertChanges.get(1).id).current().commit(false).message).isEqualTo(String.format("Revert \"second change\"\n\n%s\n\nChange-Id: %s\n", commitMessage, revertChanges.get(1).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 20 with RevertInput

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

the class RevertIT method revertSubmissionWithoutMessage.

@Test
public void revertSubmissionWithoutMessage() throws Exception {
    String firstResult = createChange("first change", "a.txt", "message").getChangeId();
    String secondResult = createChange("second change", "b.txt", "message").getChangeId();
    approve(firstResult);
    approve(secondResult);
    gApi.changes().id(secondResult).current().submit();
    RevertInput revertInput = new RevertInput();
    List<ChangeInfo> revertChanges = gApi.changes().id(firstResult).revertSubmission(revertInput).revertChanges;
    assertThat(revertChanges.get(0).subject).isEqualTo("Revert \"first change\"");
    assertThat(gApi.changes().id(revertChanges.get(0).id).current().commit(false).message).isEqualTo(String.format("Revert \"first change\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n", gApi.changes().id(firstResult).get().currentRevision, revertChanges.get(0).changeId));
    assertThat(revertChanges.get(1).subject).isEqualTo("Revert \"second change\"");
    assertThat(gApi.changes().id(revertChanges.get(1).id).current().commit(false).message).isEqualTo(String.format("Revert \"second change\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n", gApi.changes().id(secondResult).get().currentRevision, revertChanges.get(1).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)

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