Search in sources :

Example 6 with ConfigInput

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

the class ProjectIT method configChangeCausesRefUpdate.

@Test
public void configChangeCausesRefUpdate() throws Exception {
    RevCommit initialHead = getRemoteHead(project, RefNames.REFS_CONFIG);
    ConfigInfo info = gApi.projects().name(project.get()).config();
    assertThat(info.submitType).isEqualTo(SubmitType.MERGE_IF_NECESSARY);
    ConfigInput input = new ConfigInput();
    input.submitType = SubmitType.CHERRY_PICK;
    info = gApi.projects().name(project.get()).config(input);
    assertThat(info.submitType).isEqualTo(SubmitType.CHERRY_PICK);
    info = gApi.projects().name(project.get()).config();
    assertThat(info.submitType).isEqualTo(SubmitType.CHERRY_PICK);
    RevCommit updatedHead = getRemoteHead(project, RefNames.REFS_CONFIG);
    eventRecorder.assertRefUpdatedEvents(project.get(), RefNames.REFS_CONFIG, initialHead, updatedHead);
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with ConfigInput

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

the class ProjectIT method setPartialConfig.

@Test
public void setPartialConfig() throws Exception {
    ConfigInput input = createTestConfigInput();
    ConfigInfo info = gApi.projects().name(project.get()).config(input);
    ConfigInput partialInput = new ConfigInput();
    partialInput.useContributorAgreements = InheritableBoolean.FALSE;
    info = gApi.projects().name(project.get()).config(partialInput);
    assertThat(info.description).isNull();
    assertThat(info.useContributorAgreements.configuredValue).isEqualTo(partialInput.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 8 with ConfigInput

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

the class ProjectIT method createTestConfigInput.

private ConfigInput createTestConfigInput() {
    ConfigInput input = new ConfigInput();
    input.description = "some description";
    input.useContributorAgreements = InheritableBoolean.TRUE;
    input.useContentMerge = InheritableBoolean.TRUE;
    input.useSignedOffBy = InheritableBoolean.TRUE;
    input.createNewChangeForAllNotInTarget = InheritableBoolean.TRUE;
    input.requireChangeId = InheritableBoolean.TRUE;
    input.rejectImplicitMerges = InheritableBoolean.TRUE;
    input.enableReviewerByEmail = InheritableBoolean.TRUE;
    input.createNewChangeForAllNotInTarget = InheritableBoolean.TRUE;
    input.maxObjectSizeLimit = "5m";
    input.submitType = SubmitType.CHERRY_PICK;
    input.state = ProjectState.HIDDEN;
    return input;
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput)

Example 9 with ConfigInput

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

the class ChangeReviewersByEmailIT method rejectWhenFeatureIsDisabled.

@Test
public void rejectWhenFeatureIsDisabled() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    ConfigInput conf = new ConfigInput();
    conf.enableReviewerByEmail = InheritableBoolean.FALSE;
    gApi.projects().name(project.get()).config(conf);
    PushOneCommit.Result r = createChange();
    AddReviewerResult result = gApi.changes().id(r.getChangeId()).addReviewer("Foo Bar <foo.bar@gerritcodereview.com>");
    assertThat(result.error).isEqualTo("Foo Bar <foo.bar@gerritcodereview.com> does not identify a registered user or group");
    assertThat(result.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) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 with ConfigInput

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

the class SetProjectCommand method run.

@Override
protected void run() throws Failure {
    ConfigInput configInput = new ConfigInput();
    configInput.requireChangeId = requireChangeID;
    configInput.submitType = submitType;
    configInput.useContentMerge = contentMerge;
    configInput.useContributorAgreements = contributorAgreements;
    configInput.useSignedOffBy = signedOffBy;
    configInput.state = state;
    configInput.maxObjectSizeLimit = maxObjectSizeLimit;
    // keeping the existing description, it would delete it.
    if (Strings.emptyToNull(projectDescription) != null) {
        configInput.description = projectDescription;
    } else {
        configInput.description = projectControl.getProject().getDescription();
    }
    try {
        putConfig.apply(new ProjectResource(projectControl), configInput);
    } catch (RestApiException e) {
        throw die(e);
    }
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) ProjectResource(com.google.gerrit.server.project.ProjectResource) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

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