use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method createChangeOnNonExistingBranch.
@Test
public void createChangeOnNonExistingBranch() throws Exception {
requestScopeOperations.setApiUser(user.id());
ChangeInput input = newChangeInput(ChangeStatus.NEW);
input.branch = "foo";
input.newBranch = true;
assertCreateSucceeds(input);
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method createMergeChangeOnNonExistingBranchNotPossible.
@Test
public void createMergeChangeOnNonExistingBranchNotPossible() throws Exception {
requestScopeOperations.setApiUser(user.id());
ChangeInput input = newMergeChangeInput("foo", "master", "");
input.newBranch = true;
assertCreateFails(input, BadRequestException.class, "Cannot create merge: destination branch does not exist");
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method cannotCreateChangeOnTagRefs.
@Test
public void cannotCreateChangeOnTagRefs() 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";
// disallowed ref
ci.branch = "refs/tags/v1.0";
Throwable thrown = assertThrows(RestApiException.class, () -> gApi.changes().create(ci));
assertThat(thrown).hasMessageThat().contains("Cannot create a change on ref " + ci.branch);
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method createChangeWithParentChange.
@Test
public void createChangeWithParentChange() throws Exception {
Result change = createChange();
ChangeInput input = newChangeInput(ChangeStatus.NEW);
input.baseChange = change.getChangeId();
ChangeInfo result = assertCreateSucceeds(input);
assertThat(gApi.changes().id(result.id).current().commit(false).parents.get(0).commit).isEqualTo(change.getCommit().getId().name());
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method createMergeChange.
@Test
public void createMergeChange() throws Exception {
changeInTwoBranches("branchA", "a.txt", "branchB", "b.txt");
ChangeInput in = newMergeChangeInput("branchA", "branchB", "");
ChangeInfo change = assertCreateSucceeds(in);
// Verify the message that has been posted on the change.
List<ChangeMessageInfo> messages = gApi.changes().id(change._number).messages();
assertThat(messages).hasSize(1);
assertThat(Iterables.getOnlyElement(messages).message).isEqualTo("Uploaded patch set 1.");
}
Aggregations