use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class PostReviewIT method onPostReviewCallbackGetsCorrectChangeAndPatchSet.
@Test
public void onPostReviewCallbackGetsCorrectChangeAndPatchSet() throws Exception {
PushOneCommit.Result r = createChange();
amendChange(r.getChangeId());
TestOnPostReview testOnPostReview = new TestOnPostReview(/* message= */
null);
try (Registration registration = extensionRegistry.newRegistration().add(testOnPostReview)) {
ReviewInput input = new ReviewInput().label(LabelId.CODE_REVIEW, 1);
// Vote on current patch set.
gApi.changes().id(r.getChangeId()).current().review(input);
testOnPostReview.assertChangeAndPatchSet(r.getChange().getId(), 2);
// Vote on old patch set.
gApi.changes().id(r.getChangeId()).revision(1).review(input);
testOnPostReview.assertChangeAndPatchSet(r.getChange().getId(), 1);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SubmitByRebaseAlwaysIT method rebaseInvokesChangeMessageModifiers.
@Test
public void rebaseInvokesChangeMessageModifiers() throws Throwable {
ChangeMessageModifier modifier1 = (msg, orig, tip, dest) -> msg + "This-change-before-rebase: " + orig.name() + "\n";
ChangeMessageModifier modifier2 = (msg, orig, tip, dest) -> msg + "Previous-step-tip: " + tip.name() + "\n";
ChangeMessageModifier modifier3 = (msg, orig, tip, dest) -> msg + "Dest: " + dest.shortName() + "\n";
try (Registration registration = extensionRegistry.newRegistration().add(modifier1).add(modifier2).add(modifier3)) {
ImmutableList<PushOneCommit.Result> changes = submitWithRebase(admin);
ChangeData cd1 = changes.get(0).getChange();
ChangeData cd2 = changes.get(1).getChange();
assertThat(cd2.patchSets()).hasSize(2);
String change1CurrentCommit = cd1.currentPatchSet().commitId().name();
String change2Ps1Commit = cd2.patchSet(PatchSet.id(cd2.getId(), 1)).commitId().name();
assertThat(gApi.changes().id(cd2.getId().get()).revision(2).commit(false).message).isEqualTo("Change 2\n\n" + ("Change-Id: " + cd2.change().getKey() + "\n") + ("Reviewed-on: " + urlFormatter.get().getChangeViewUrl(project, cd2.getId()).get() + "\n") + "Reviewed-by: Administrator <admin@example.com>\n" + ("This-change-before-rebase: " + change2Ps1Commit + "\n") + ("Previous-step-tip: " + change1CurrentCommit + "\n") + "Dest: master\n");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SubmitByRebaseAlwaysIT method failingChangeMessageModifierShortCircuits.
@Test
public void failingChangeMessageModifierShortCircuits() throws Throwable {
ChangeMessageModifier modifier1 = (msg, orig, tip, dest) -> {
throw new IllegalStateException("boom");
};
ChangeMessageModifier modifier2 = (msg, orig, tip, dest) -> msg + "A-footer: value\n";
try (Registration registration = extensionRegistry.newRegistration().add(modifier1).add(modifier2)) {
MergeUpdateException thrown = assertThrows(MergeUpdateException.class, () -> submitWithRebase());
Throwable cause = Throwables.getRootCause(thrown);
assertThat(cause).isInstanceOf(RuntimeException.class);
assertThat(cause).hasMessageThat().isEqualTo("boom");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushForMasterWithTopic.
@Test
public void pushForMasterWithTopic() throws Exception {
TopicValidator topicValidator = new TopicValidator();
try (Registration registration = extensionRegistry.newRegistration().add(topicValidator)) {
String topic = "my/topic";
// specify topic as option
PushOneCommit.Result r = pushTo("refs/for/master%topic=" + topic);
r.assertOkStatus();
r.assertChange(Change.Status.NEW, topic);
assertThat(topicValidator.count()).isEqualTo(1);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickWithValidationOptions.
@Test
public void cherryPickWithValidationOptions() throws Exception {
PushOneCommit.Result r = createChange();
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
in.message = "Cherry Pick";
in.validationOptions = ImmutableMap.of("key", "value");
gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
TestCommitValidationListener testCommitValidationListener = new TestCommitValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(testCommitValidationListener)) {
gApi.changes().id(r.getChangeId()).current().cherryPickAsInfo(in);
assertThat(testCommitValidationListener.receiveEvent.pushOptions).containsExactly("key", "value");
}
}
Aggregations