use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class ChangeIT method setReadyForReviewAllowedAsProjectOwner.
@Test
public void setReadyForReviewAllowedAsProjectOwner() throws Exception {
requestScopeOperations.setApiUser(user.id());
String changeId = gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
gApi.changes().id(changeId).setWorkInProgress();
com.google.gerrit.acceptance.TestAccount user2 = accountCreator.user2();
projectOperations.project(project).forUpdate().add(allow(Permission.OWNER).ref("refs/*").group(REGISTERED_USERS)).update();
requestScopeOperations.setApiUser(user2.id());
gApi.changes().id(changeId).setReadyForReview();
assertThat(gApi.changes().id(changeId).get().workInProgress).isNull();
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class ChangeIT method deleteChangeAsUser.
private void deleteChangeAsUser(Project.NameKey projectName, com.google.gerrit.acceptance.TestAccount owner, com.google.gerrit.acceptance.TestAccount deleteAs) throws Exception {
try {
projectOperations.project(projectName).forUpdate().add(allow(Permission.VIEW_PRIVATE_CHANGES).ref("refs/*").group(ANONYMOUS_USERS)).update();
requestScopeOperations.setApiUser(owner.id());
ChangeInput in = new ChangeInput();
in.project = projectName.get();
in.branch = "refs/heads/master";
in.subject = "test";
ChangeInfo changeInfo = gApi.changes().create(in).get();
String changeId = changeInfo.changeId;
int id = changeInfo._number;
String commit = changeInfo.currentRevision;
assertThat(gApi.changes().id(changeId).info().owner._accountId).isEqualTo(owner.id().get());
requestScopeOperations.setApiUser(deleteAs.id());
gApi.changes().id(changeId).delete();
assertThat(query(changeId)).isEmpty();
String ref = Change.id(id).toRefPrefix() + "1";
eventRecorder.assertRefUpdatedEvents(projectName.get(), ref, null, commit, commit, null);
eventRecorder.assertChangeDeletedEvents(changeId, deleteAs.email());
} finally {
projectOperations.project(project).forUpdate().remove(permissionKey(Permission.DELETE_OWN_CHANGES).ref("refs/*")).remove(permissionKey(Permission.DELETE_CHANGES).ref("refs/*")).update();
}
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class ChangeIT method setWorkInProgressAllowedAsProjectOwner.
@Test
public void setWorkInProgressAllowedAsProjectOwner() throws Exception {
requestScopeOperations.setApiUser(user.id());
String changeId = gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
com.google.gerrit.acceptance.TestAccount user2 = accountCreator.user2();
projectOperations.project(project).forUpdate().add(allow(Permission.OWNER).ref("refs/*").group(REGISTERED_USERS)).update();
requestScopeOperations.setApiUser(user2.id());
gApi.changes().id(changeId).setWorkInProgress();
assertThat(gApi.changes().id(changeId).get().workInProgress).isTrue();
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class AbstractReindexTests method setUpChange.
private void setUpChange() throws Exception {
project = Project.nameKey("reindex-project-test");
try (ServerContext ctx = startServer()) {
createAllIndexes(ctx.getInjector());
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
gApi.projects().create(project.get());
ChangeInput in = new ChangeInput(project.get(), "master", "Test change");
in.newBranch = true;
changeId = gApi.changes().create(in).info().changeId;
}
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CommentsIT method createChangeInNewBranch.
private ChangeInfo createChangeInNewBranch(String branchName) throws Exception {
ChangeInput in = new ChangeInput();
in.project = project.get();
in.branch = branchName;
in.newBranch = true;
in.subject = "New changes";
return gApi.changes().create(in).get();
}
Aggregations