Search in sources :

Example 36 with ChangeInput

use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.

the class CreateChangeIT method basic.

/**
 * Just a basic test. The real functionality is tested by {@link
 * com.google.gerrit.acceptance.rest.change.CreateChangeIT}.
 */
@Test
public void basic() throws Exception {
    BranchInput branchInput = new BranchInput();
    branchInput.ref = "foo";
    assertThat(gApi.projects().name(project.get()).branches().get().stream().map(i -> i.ref)).doesNotContain(REFS_HEADS + branchInput.ref);
    RestResponse r = adminRestSession.put("/projects/" + project.get() + "/branches/" + branchInput.ref, branchInput);
    r.assertCreated();
    ChangeInput input = new ChangeInput();
    input.branch = "foo";
    input.subject = "subject";
    RestResponse cr = adminRestSession.post("/projects/" + project.get() + "/create.change", input);
    cr.assertCreated();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 37 with ChangeInput

use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.

the class AccountsRestApiBindingsIT method starEndpoints.

@Test
public void starEndpoints() throws Exception {
    ChangeInput ci = new ChangeInput(project.get(), "master", "Test change");
    String changeId = gApi.changes().create(ci).get().id;
    execute(adminRestSession, STAR_ENDPOINTS, "self", changeId);
}
Also used : ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 38 with ChangeInput

use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.

the class RequestScopeOperationsImplTest method checkSshUser.

private void checkSshUser(Account.Id expected) throws Exception {
    // No "gerrit whoami" command, so the simplest way to check who the user is over SSH is to query
    // for owner:self.
    ChangeInput cin = new ChangeInput();
    cin.project = project.get();
    cin.branch = "master";
    cin.subject = "Test change " + changeCounter.incrementAndGet();
    String changeId = gApi.changes().create(cin).get().changeId;
    assertThat(gApi.changes().id(changeId).get().owner._accountId).isEqualTo(expected.get());
    String queryResults = atrScope.get().getSession().exec("gerrit query owner:self change:" + changeId);
    assertWithMessage("Change-Ids in query results:\n%s", queryResults).that(findDistinct(queryResults, "I[0-9a-f]{40}")).containsExactly(changeId);
}
Also used : ChangeInput(com.google.gerrit.extensions.common.ChangeInput)

Example 39 with ChangeInput

use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.

the class SubmitRequirementsEvaluatorIT method byAuthorEmail.

@Test
public void byAuthorEmail() throws Exception {
    TestAccount user2 = accountCreator.create("Foo", "user@example.com", "User", /* displayName = */
    null);
    requestScopeOperations.setApiUser(user2.id());
    ChangeInfo info = gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get();
    ChangeData cd = changeQueryProvider.get().byLegacyChangeId(Change.Id.tryParse(Integer.toString(info._number)).get()).get(0);
    // Match by email works
    checkSubmitRequirementResult(cd, /* submittabilityExpr= */
    "authoremail:\"^.*@example\\.com\"", SubmitRequirementResult.Status.SATISFIED);
    checkSubmitRequirementResult(cd, /* submittabilityExpr= */
    "authoremail:\"^user@.*\\.com\"", SubmitRequirementResult.Status.SATISFIED);
    // Match by name does not work
    checkSubmitRequirementResult(cd, /* submittabilityExpr= */
    "authoremail:\"^Foo$\"", SubmitRequirementResult.Status.UNSATISFIED);
    checkSubmitRequirementResult(cd, /* submittabilityExpr= */
    "authoremail:\"^User$\"", SubmitRequirementResult.Status.UNSATISFIED);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) TestAccount(com.google.gerrit.acceptance.TestAccount) ChangeData(com.google.gerrit.server.query.change.ChangeData) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 40 with ChangeInput

use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.

the class AbstractSubmit method submitEmptyCommitPatchSetCanFastForward_emptyCommitNotAllowed.

@Test
@TestProjectInput(rejectEmptyCommit = InheritableBoolean.TRUE)
public void submitEmptyCommitPatchSetCanFastForward_emptyCommitNotAllowed() throws Throwable {
    ChangeInput ci = new ChangeInput();
    ci.subject = "Empty change";
    ci.project = project.get();
    ci.branch = "master";
    ChangeApi change = gApi.changes().create(ci);
    approve(change.id());
    ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> change.current().submit());
    assertThat(thrown).hasMessageThat().contains("Change " + change.get()._number + ": Change could not be merged because the commit is empty. Project policy" + " requires all commits to contain modifications to at least one file.");
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

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