use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class PluginOperatorsIT method getChangeWithIsOperator.
@Test
public void getChangeWithIsOperator() throws Exception {
QueryChanges queryChanges = queryChangesProvider.get();
queryChanges.addQuery("is:changeNumberEven_myplugin");
String oddChangeId = createChange().getChangeId();
String evenChangeId = createChange().getChangeId();
BadRequestException exception = assertThrows(BadRequestException.class, () -> getChanges(queryChanges));
assertThat(exception).hasMessageThat().isEqualTo("Unrecognized value: changeNumberEven_myplugin");
try (AutoCloseable ignored = installPlugin("myplugin", IsOperatorModule.class)) {
List<?> changes = getChanges(queryChanges);
assertThat(changes).hasSize(1);
ChangeInfo c = (ChangeInfo) changes.get(0);
String outputChangeId = c.changeId;
assertThat(outputChangeId).isEqualTo(evenChangeId);
assertThat(outputChangeId).isNotEqualTo(oddChangeId);
}
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class PrivateChangeIT method setPrivateByOwner.
@Test
public void setPrivateByOwner() throws Exception {
TestRepository<InMemoryRepository> userRepo = cloneProject(project, user);
PushOneCommit.Result result = pushFactory.create(user.newIdent(), userRepo).to("refs/for/master");
requestScopeOperations.setApiUser(user.id());
String changeId = result.getChangeId();
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
gApi.changes().id(changeId).setPrivate(true, null);
ChangeInfo info = gApi.changes().id(changeId).get();
assertThat(info.isPrivate).isTrue();
assertThat(Iterables.getLast(info.messages).message).isEqualTo("Set private");
assertThat(Iterables.getLast(info.messages).tag).contains(ChangeMessagesUtil.TAG_SET_PRIVATE);
gApi.changes().id(changeId).setPrivate(false, null);
info = gApi.changes().id(changeId).get();
assertThat(info.isPrivate).isNull();
assertThat(Iterables.getLast(info.messages).message).isEqualTo("Unset private");
assertThat(Iterables.getLast(info.messages).tag).contains(ChangeMessagesUtil.TAG_UNSET_PRIVATE);
String msg = "This is a security fix that must not be public.";
gApi.changes().id(changeId).setPrivate(true, msg);
info = gApi.changes().id(changeId).get();
assertThat(info.isPrivate).isTrue();
assertThat(Iterables.getLast(info.messages).message).isEqualTo("Set private\n\n" + msg);
assertThat(Iterables.getLast(info.messages).tag).contains(ChangeMessagesUtil.TAG_SET_PRIVATE);
msg = "After this security fix has been released we can make it public now.";
gApi.changes().id(changeId).setPrivate(false, msg);
info = gApi.changes().id(changeId).get();
assertThat(info.isPrivate).isNull();
assertThat(Iterables.getLast(info.messages).message).isEqualTo("Unset private\n\n" + msg);
assertThat(Iterables.getLast(info.messages).tag).contains(ChangeMessagesUtil.TAG_UNSET_PRIVATE);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementCustomRuleIT method submittableQueryRuleOk.
@Test
public void submittableQueryRuleOk() throws Exception {
ChangeApi change = newChangeApi();
// Satisfy the default rule.
approveChange(change);
rule.status(Optional.of(SubmitRecord.Status.OK));
change.index();
List<ChangeInfo> result = queryIsSubmittable();
assertThat(result).hasSize(1);
assertThat(result.get(0).changeId).isEqualTo(change.info().changeId);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method removedVotesNotSticky.
@Test
public void removedVotesNotSticky() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType(LabelId.CODE_REVIEW, b -> b.setCopyAllScoresOnTrivialRebase(true));
u.getConfig().updateLabelType(LabelId.VERIFIED, b -> b.setCopyAllScoresIfNoCodeChange(true));
u.save();
}
for (ChangeKind changeKind : EnumSet.of(REWORK, TRIVIAL_REBASE, NO_CODE_CHANGE, MERGE_FIRST_PARENT_UPDATE, NO_CHANGE)) {
testRepo.reset(projectOperations.project(project).getHead("master"));
String changeId = changeKindCreator.createChange(changeKind, testRepo, admin);
vote(admin, changeId, 2, 1);
vote(user, changeId, -2, -1);
// Remove votes by re-voting with 0
vote(admin, changeId, 0, 0);
vote(user, changeId, 0, 0);
ChangeInfo c = detailedChange(changeId);
assertVotes(c, admin, 0, 0, null);
assertVotes(c, user, 0, 0, null);
changeKindCreator.updateChange(changeId, changeKind, testRepo, admin, project);
c = detailedChange(changeId);
assertVotes(c, admin, 0, 0, changeKind);
assertVotes(c, user, 0, 0, changeKind);
}
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists.
private void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileAlreadyExists() throws Exception {
// create "existing file" and submit it.
String existingFile = "existing file";
Change.Id prep = changeOperations.newChange().project(project).file(existingFile).content("content").create();
vote(admin, prep.toString(), 2, 1);
gApi.changes().id(prep.get()).current().submit();
Change.Id changeId = changeOperations.newChange().project(project).create();
vote(admin, changeId.toString(), 2, 1);
vote(user, changeId.toString(), -2, -1);
changeOperations.change(changeId).newPatchset().file(existingFile).content("new content").create();
ChangeInfo c = detailedChange(changeId.toString());
// no votes are copied since the list of files changed ("existing file" was added to the
// change).
assertVotes(c, admin, 0, 0);
assertVotes(c, user, 0, 0);
}
Aggregations