use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method assertCreateSucceeds.
private ChangeInfo assertCreateSucceeds(ChangeInput in) throws Exception {
ChangeInfo out = gApi.changes().create(in).get();
assertThat(out.project).isEqualTo(in.project);
assertThat(RefNames.fullName(out.branch)).isEqualTo(RefNames.fullName(in.branch));
assertThat(out.subject).isEqualTo(Splitter.on("\n").splitToList(in.subject).get(0));
assertThat(out.topic).isEqualTo(in.topic);
assertThat(out.status).isEqualTo(in.status);
if (in.isPrivate) {
assertThat(out.isPrivate).isTrue();
} else {
assertThat(out.isPrivate).isNull();
}
if (in.workInProgress) {
assertThat(out.workInProgress).isTrue();
} else {
assertThat(out.workInProgress).isNull();
}
assertThat(out.revisions).hasSize(1);
assertThat(out.submitted).isNull();
assertThat(out.containsGitConflicts).isNull();
assertThat(in.status).isEqualTo(ChangeStatus.NEW);
return out;
}
use of com.google.gerrit.extensions.common.ChangeInfo 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.ChangeInfo 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.");
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method createWithMergeConflictAuthorAddedAsCcNotNotifiedWithNotifyNone.
@Test
public void createWithMergeConflictAuthorAddedAsCcNotNotifiedWithNotifyNone() throws Exception {
String fileName = "shared.txt";
String sourceBranch = "sourceBranch";
String sourceSubject = "source change";
String sourceContent = "source content";
String targetBranch = "targetBranch";
String targetSubject = "target change";
String targetContent = "target content";
changeInTwoBranches(sourceBranch, sourceSubject, fileName, sourceContent, targetBranch, targetSubject, fileName, targetContent);
ChangeInput input = newMergeChangeInput(targetBranch, sourceBranch, "", true);
input.workInProgress = true;
input.author = new AccountInput();
input.author.email = user.email();
input.author.name = user.fullName();
input.notify = NotifyHandling.NONE;
ChangeInfo info = assertCreateSucceeds(input);
assertThat(info.reviewers.get(ReviewerState.CC)).hasSize(1);
assertThat(Iterables.getOnlyElement(info.reviewers.get(ReviewerState.CC)).email).isEqualTo(user.email());
assertThat(sender.getMessages()).isEmpty();
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method createMergeChange_ConflictsAllowed.
@Test
public void createMergeChange_ConflictsAllowed() throws Exception {
String fileName = "shared.txt";
String sourceBranch = "sourceBranch";
String sourceSubject = "source change";
String sourceContent = "source content";
String targetBranch = "targetBranch";
String targetSubject = "target change";
String targetContent = "target content";
changeInTwoBranches(sourceBranch, sourceSubject, fileName, sourceContent, targetBranch, targetSubject, fileName, targetContent);
ChangeInput in = newMergeChangeInput(targetBranch, sourceBranch, "", true);
ChangeInfo change = assertCreateSucceedsWithConflicts(in);
// Verify that the file content in the created change is correct.
// We expect that it has conflict markers to indicate the conflict.
BinaryResult bin = gApi.changes().id(change._number).current().file(fileName).content();
ByteArrayOutputStream os = new ByteArrayOutputStream();
bin.writeTo(os);
String fileContent = new String(os.toByteArray(), UTF_8);
String sourceSha1 = abbreviateName(projectOperations.project(project).getHead(sourceBranch), 6);
String targetSha1 = abbreviateName(projectOperations.project(project).getHead(targetBranch), 6);
assertThat(fileContent).isEqualTo("<<<<<<< TARGET BRANCH (" + targetSha1 + " " + targetSubject + ")\n" + targetContent + "\n" + "=======\n" + sourceContent + "\n" + ">>>>>>> SOURCE BRANCH (" + sourceSha1 + " " + sourceSubject + ")\n");
// 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.\n\n" + "The following files contain Git conflicts:\n" + "* " + fileName + "\n");
}
Aggregations