Search in sources :

Example 71 with ChangeInput

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

the class CreateChangeIT method sha1sOfTwoNewChangesDiffer.

@Test
@UseSystemTime
public void sha1sOfTwoNewChangesDiffer() throws Exception {
    ChangeInput changeInput = newChangeInput(ChangeStatus.NEW);
    ChangeInfo info1 = assertCreateSucceeds(changeInput);
    ChangeInfo info2 = assertCreateSucceeds(changeInput);
    assertThat(info1.currentRevision).isNotEqualTo(info2.currentRevision);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test) UseSystemTime(com.google.gerrit.acceptance.UseSystemTime)

Example 72 with ChangeInput

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

the class CreateChangeIT method createChangeWithParentCommit.

@Test
public void createChangeWithParentCommit() throws Exception {
    Map<String, PushOneCommit.Result> setup = changeInTwoBranches("foo", "foo.txt", "bar", "bar.txt");
    ChangeInput input = newChangeInput(ChangeStatus.NEW);
    input.baseCommit = setup.get("master").getCommit().getId().name();
    ChangeInfo result = assertCreateSucceeds(input);
    assertThat(gApi.changes().id(result.id).current().commit(false).parents.get(0).commit).isEqualTo(input.baseCommit);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Result(com.google.gerrit.acceptance.PushOneCommit.Result) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 73 with ChangeInput

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

the class CreateChangeIT method createChangeWithValidationOptions.

@Test
public void createChangeWithValidationOptions() throws Exception {
    ChangeInput changeInput = new ChangeInput();
    changeInput.project = project.get();
    changeInput.branch = "master";
    changeInput.subject = "A change";
    changeInput.status = ChangeStatus.NEW;
    changeInput.validationOptions = ImmutableMap.of("key", "value");
    TestCommitValidationListener testCommitValidationListener = new TestCommitValidationListener();
    try (Registration registration = extensionRegistry.newRegistration().add(testCommitValidationListener)) {
        assertCreateSucceeds(changeInput);
        assertThat(testCommitValidationListener.receiveEvent.pushOptions).containsExactly("key", "value");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 74 with ChangeInput

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

the class CreateChangeIT method canCreateChangeWithChangeIfOfExistingChangeOnOtherBranch.

@Test
public void canCreateChangeWithChangeIfOfExistingChangeOnOtherBranch() throws Exception {
    String changeId = createChange().getChangeId();
    createBranch(BranchNameKey.create(project, "other"));
    ChangeInput ci = newChangeInput(ChangeStatus.NEW);
    ci.subject = "Subject\n\nChange-Id: " + changeId;
    ci.branch = "other";
    ChangeInfo info = assertCreateSucceeds(ci);
    assertThat(info.changeId).isEqualTo(changeId);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 75 with ChangeInput

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

the class CreateChangeIT method createAuthorOverrideBadRequest.

@Test
public void createAuthorOverrideBadRequest() throws Exception {
    ChangeInput input = newChangeInput(ChangeStatus.NEW);
    input.author = new AccountInput();
    input.author.name = "name";
    assertCreateFails(input, BadRequestException.class, "email");
    input.author.name = null;
    input.author.email = "gerritlessjane@invalid";
    assertCreateFails(input, BadRequestException.class, "email");
}
Also used : ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) 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