use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method newMergeChangeInput.
private ChangeInput newMergeChangeInput(String targetBranch, String sourceRef, String strategy) {
// create a merge change from branchA to master in gerrit
ChangeInput in = new ChangeInput();
in.project = project.get();
in.branch = targetBranch;
in.subject = "merge " + sourceRef + " to " + targetBranch;
in.status = ChangeStatus.NEW;
MergeInput mergeInput = new MergeInput();
mergeInput.source = sourceRef;
in.merge = mergeInput;
if (!Strings.isNullOrEmpty(strategy)) {
in.merge.strategy = strategy;
}
return in;
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method createChangeFromApi.
private String createChangeFromApi(Project.NameKey project) throws RestApiException {
ChangeInput ci = new ChangeInput();
ci.project = project.get();
ci.subject = "Test change at" + System.nanoTime();
ci.branch = "master";
return gApi.changes().create(ci).get().changeId;
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method notificationsOnChangeCreation.
@Test
public void notificationsOnChangeCreation() throws Exception {
requestScopeOperations.setApiUser(user.id());
watch(project.get());
// check that watcher is notified
requestScopeOperations.setApiUser(admin.id());
assertCreateSucceeds(newChangeInput(ChangeStatus.NEW));
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.getNameEmail());
assertThat(m.body()).contains(admin.fullName() + " has uploaded this change for review.");
// check that watcher is not notified if notify=NONE
sender.clear();
ChangeInput input = newChangeInput(ChangeStatus.NEW);
input.notify = NotifyHandling.NONE;
assertCreateSucceeds(input);
assertThat(sender.getMessages()).isEmpty();
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method createDefaultAuthor.
@Test
public void createDefaultAuthor() throws Exception {
ChangeInput input = newChangeInput(ChangeStatus.NEW);
ChangeInfo info = assertCreateSucceeds(input);
GitPerson person = gApi.changes().id(info.id).current().commit(false).author;
assertThat(person).email().isEqualTo(admin.email());
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method cannotCreateChangeOnGerritInternalRefs.
@Test
public void cannotCreateChangeOnGerritInternalRefs() throws Exception {
requestScopeOperations.setApiUser(admin.id());
projectOperations.project(project).forUpdate().add(allow(CREATE).ref("refs/*").group(REGISTERED_USERS)).update();
requestScopeOperations.setApiUser(user.id());
ChangeInput ci = newChangeInput(ChangeStatus.NEW);
ci.subject = "Subject";
// disallowedRef
ci.branch = "refs/changes/00/1000";
Throwable thrown = assertThrows(RestApiException.class, () -> gApi.changes().create(ci));
assertThat(thrown).hasMessageThat().contains("Cannot create a change on ref " + ci.branch);
}
Aggregations