Search in sources :

Example 1 with ConfigInput

use of com.google.gerrit.extensions.api.projects.ConfigInput in project gerrit by GerritCodeReview.

the class ChangeReviewersByEmailIT method setUp.

@Before
public void setUp() throws Exception {
    ConfigInput conf = new ConfigInput();
    conf.enableReviewerByEmail = InheritableBoolean.TRUE;
    gApi.projects().name(project.get()).config(conf);
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) Before(org.junit.Before)

Example 2 with ConfigInput

use of com.google.gerrit.extensions.api.projects.ConfigInput in project gerrit by GerritCodeReview.

the class ProjectIT method setConfig.

@Test
public void setConfig() throws Exception {
    ConfigInput input = createTestConfigInput();
    ConfigInfo info = gApi.projects().name(project.get()).config(input);
    assertThat(info.description).isEqualTo(input.description);
    assertThat(info.useContributorAgreements.configuredValue).isEqualTo(input.useContributorAgreements);
    assertThat(info.useContentMerge.configuredValue).isEqualTo(input.useContentMerge);
    assertThat(info.useSignedOffBy.configuredValue).isEqualTo(input.useSignedOffBy);
    assertThat(info.createNewChangeForAllNotInTarget.configuredValue).isEqualTo(input.createNewChangeForAllNotInTarget);
    assertThat(info.requireChangeId.configuredValue).isEqualTo(input.requireChangeId);
    assertThat(info.rejectImplicitMerges.configuredValue).isEqualTo(input.rejectImplicitMerges);
    assertThat(info.enableReviewerByEmail.configuredValue).isEqualTo(input.enableReviewerByEmail);
    assertThat(info.createNewChangeForAllNotInTarget.configuredValue).isEqualTo(input.createNewChangeForAllNotInTarget);
    assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo(input.maxObjectSizeLimit);
    assertThat(info.submitType).isEqualTo(input.submitType);
    assertThat(info.state).isEqualTo(input.state);
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with ConfigInput

use of com.google.gerrit.extensions.api.projects.ConfigInput in project gerrit by GerritCodeReview.

the class ProjectIT method nonOwnerCannotSetConfig.

@Test
public void nonOwnerCannotSetConfig() throws Exception {
    ConfigInput input = createTestConfigInput();
    setApiUser(user);
    exception.expect(AuthException.class);
    exception.expectMessage("restricted to project owner");
    gApi.projects().name(project.get()).config(input);
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with ConfigInput

use of com.google.gerrit.extensions.api.projects.ConfigInput in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method reviewerAndCcByEmail.

@Test
public void reviewerAndCcByEmail() throws Exception {
    assume().that(notesMigration.enabled()).isTrue();
    Project.NameKey project = new Project.NameKey("repo");
    TestRepository<Repo> repo = createProject(project.get());
    ConfigInput conf = new ConfigInput();
    conf.enableReviewerByEmail = InheritableBoolean.TRUE;
    gApi.projects().name(project.get()).config(conf);
    String userByEmail = "un.registered@reviewer.com";
    String userByEmailWithName = "John Doe <" + userByEmail + ">";
    Change change1 = insert(repo, newChange(repo));
    Change change2 = insert(repo, newChange(repo));
    insert(repo, newChange(repo));
    AddReviewerInput rin = new AddReviewerInput();
    rin.reviewer = userByEmailWithName;
    rin.state = ReviewerState.REVIEWER;
    gApi.changes().id(change1.getId().get()).addReviewer(rin);
    rin = new AddReviewerInput();
    rin.reviewer = userByEmailWithName;
    rin.state = ReviewerState.CC;
    gApi.changes().id(change2.getId().get()).addReviewer(rin);
    if (getSchemaVersion() >= 41) {
        assertQuery("reviewer:\"" + userByEmailWithName + "\"", change1);
        assertQuery("cc:\"" + userByEmailWithName + "\"", change2);
        // Omitting the name:
        assertQuery("reviewer:\"" + userByEmail + "\"", change1);
        assertQuery("cc:\"" + userByEmail + "\"", change2);
    } else {
        assertMissingField(ChangeField.REVIEWER_BY_EMAIL);
        assertFailingQuery("reviewer:\"" + userByEmailWithName + "\"", "User " + userByEmailWithName + " not found");
        assertFailingQuery("cc:\"" + userByEmailWithName + "\"", "User " + userByEmailWithName + " not found");
        // Omitting the name:
        assertFailingQuery("reviewer:\"" + userByEmail + "\"", "User " + userByEmail + " not found");
        assertFailingQuery("cc:\"" + userByEmail + "\"", "User " + userByEmail + " not found");
    }
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) Change(com.google.gerrit.reviewdb.client.Change) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test)

Example 5 with ConfigInput

use of com.google.gerrit.extensions.api.projects.ConfigInput in project gerrit by GerritCodeReview.

the class ChangeIT method addReviewerThatIsInactiveEmailFallback.

@Test
public void addReviewerThatIsInactiveEmailFallback() throws Exception {
    assume().that(notesMigration.enabled()).isTrue();
    ConfigInput conf = new ConfigInput();
    conf.enableReviewerByEmail = InheritableBoolean.TRUE;
    gApi.projects().name(project.get()).config(conf);
    PushOneCommit.Result result = createChange();
    String username = "user@domain.com";
    gApi.accounts().create(username).setActive(false);
    AddReviewerInput in = new AddReviewerInput();
    in.reviewer = username;
    in.state = ReviewerState.CC;
    AddReviewerResult r = gApi.changes().id(result.getChangeId()).addReviewer(in);
    assertThat(r.input).isEqualTo(username);
    assertThat(r.error).isNull();
    // When adding by email, the reviewers field is also empty because we can't
    // render a ReviewerInfo object for a non-account.
    assertThat(r.reviewers).isNull();
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) AddReviewerResult(com.google.gerrit.extensions.api.changes.AddReviewerResult) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

ConfigInput (com.google.gerrit.extensions.api.projects.ConfigInput)12 Test (org.junit.Test)8 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)6 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)3 ConfigInfo (com.google.gerrit.extensions.api.projects.ConfigInfo)3 Project (com.google.gerrit.reviewdb.client.Project)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 AddReviewerResult (com.google.gerrit.extensions.api.changes.AddReviewerResult)2 Change (com.google.gerrit.reviewdb.client.Change)2 Repo (com.google.gerrit.testutil.InMemoryRepositoryManager.Repo)2 ProjectInput (com.google.gerrit.extensions.api.projects.ProjectInput)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 ProjectResource (com.google.gerrit.server.project.ProjectResource)1 ProjectCreationValidationListener (com.google.gerrit.server.validators.ProjectCreationValidationListener)1 ValidationException (com.google.gerrit.server.validators.ValidationException)1 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1