Search in sources :

Example 61 with ChangeInput

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();
}
Also used : TestAccount(com.google.gerrit.acceptance.TestAccount) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 62 with ChangeInput

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();
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput)

Example 63 with ChangeInput

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();
}
Also used : TestAccount(com.google.gerrit.acceptance.TestAccount) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 64 with ChangeInput

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;
    }
}
Also used : ChangeInput(com.google.gerrit.extensions.common.ChangeInput) GerritApi(com.google.gerrit.extensions.api.GerritApi)

Example 65 with ChangeInput

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();
}
Also used : ChangeInput(com.google.gerrit.extensions.common.ChangeInput)

Aggregations

ChangeInput (com.google.gerrit.extensions.common.ChangeInput)107 Test (org.junit.Test)94 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)89 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)30 Project (com.google.gerrit.entities.Project)10 Result (com.google.gerrit.acceptance.PushOneCommit.Result)7 AccountInput (com.google.gerrit.extensions.api.accounts.AccountInput)7 MergeInput (com.google.gerrit.extensions.common.MergeInput)6 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)6 Change (com.google.gerrit.entities.Change)5 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)5 TestAccount (com.google.gerrit.acceptance.TestAccount)4 StandaloneSiteTest (com.google.gerrit.acceptance.StandaloneSiteTest)3 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)3 GitPerson (com.google.gerrit.extensions.common.GitPerson)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)2 UseSystemTime (com.google.gerrit.acceptance.UseSystemTime)2 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)2