use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class CorsIT method putWithServerOriginAcceptedWithNoCorsResponseHeaders.
@Test
public void putWithServerOriginAcceptedWithNoCorsResponseHeaders() throws Exception {
Result change = createChange();
String origin = adminRestSession.url();
RestResponse r = adminRestSession.putWithHeaders("/changes/" + change.getChangeId() + "/topic", /* content = */
"A", new BasicHeader(ORIGIN, origin));
r.assertOK();
checkCors(r, false, origin);
checkTopic(change, "A");
}
use of com.google.gerrit.acceptance.PushOneCommit.Result 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.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class CreateChangeIT method createMergeChangeFailsWithConflictIfThereAreTooManyCommonPredecessors.
@Test
public void createMergeChangeFailsWithConflictIfThereAreTooManyCommonPredecessors() throws Exception {
// Create an initial commit in master.
Result initialCommit = pushFactory.create(user.newIdent(), testRepo, "initial commit", "readme.txt", "initial commit").to("refs/heads/master");
initialCommit.assertOkStatus();
String file = "shared.txt";
List<RevCommit> parents = new ArrayList<>();
// RecursiveMerger#MAX_BASES = 200, cannot use RecursiveMerger#MAX_BASES as it is not static.
int maxBases = 200;
// Create more than RecursiveMerger#MAX_BASES base commits.
for (int i = 1; i <= maxBases + 1; i++) {
parents.add(testRepo.commit().message("Base " + i).add(file, "content " + i).parent(initialCommit.getCommit()).create());
}
// Create 2 branches.
String branchA = "branchA";
String branchB = "branchB";
createBranch(BranchNameKey.create(project, branchA));
createBranch(BranchNameKey.create(project, branchB));
// Push an octopus merge to both of the branches.
Result octopusA = pushFactory.create(user.newIdent(), testRepo).setParents(parents).to("refs/heads/" + branchA);
octopusA.assertOkStatus();
Result octopusB = pushFactory.create(user.newIdent(), testRepo).setParents(parents).to("refs/heads/" + branchB);
octopusB.assertOkStatus();
// Creating a merge commit for the 2 octopus commits fails, because they have more than
// RecursiveMerger#MAX_BASES common predecessors.
assertCreateFails(newMergeChangeInput("branchA", "branchB", ""), ResourceConflictException.class, "Cannot create merge commit: No merge base could be determined." + " Reason=TOO_MANY_MERGE_BASES.");
}
use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class RevisionDiffIT method diffBetweenPatchSetsOfMergeCommitCanBeRetrievedForCommitMessageAndMergeList.
@Test
public void diffBetweenPatchSetsOfMergeCommitCanBeRetrievedForCommitMessageAndMergeList() throws Exception {
PushOneCommit.Result result = createMergeCommitChange("refs/for/master", "my_file.txt");
String changeId = result.getChangeId();
String previousPatchSetId = gApi.changes().id(changeId).get().currentRevision;
addModifiedPatchSet(changeId, "my_file.txt", content -> content.concat("Line I\nLine II\n"));
// Call both of them in succession to ensure that they don't share the same cache keys.
DiffInfo commitMessageDiffInfo = getDiffRequest(changeId, CURRENT, COMMIT_MSG).withBase(previousPatchSetId).get();
DiffInfo mergeListDiffInfo = getDiffRequest(changeId, CURRENT, MERGE_LIST).withBase(previousPatchSetId).get();
assertThat(commitMessageDiffInfo).content().hasSize(3);
assertThat(mergeListDiffInfo).content().hasSize(1);
}
use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.
the class TopicIT method illegalTopics.
@Test
public void illegalTopics() throws Exception {
Result result = createChange();
char illegalChar = '"';
String endpoint = "/changes/" + result.getChangeId() + "/topic";
RestResponse response = adminRestSession.put(endpoint, "topic" + illegalChar);
response.assertBadRequest();
}
Aggregations