Search in sources :

Example 1 with CheckProjectInput

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

the class CheckProjectIT method noBranch.

@Test
public void noBranch() throws Exception {
    CheckProjectInput input = new CheckProjectInput();
    input.autoCloseableChangesCheck = new AutoCloseableChangesCheckInput();
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(project.get()).check(input));
    assertThat(thrown).hasMessageThat().contains("branch is required");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) AutoCloseableChangesCheckInput(com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with CheckProjectInput

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

the class CheckProjectIT method maxCommits.

@Test
public void maxCommits() throws Exception {
    PushOneCommit.Result r = createChange("refs/for/master");
    String branch = r.getChange().change().getDest().branch();
    RevCommit amendedCommit = serverSideTestRepo.amend(r.getCommit()).create();
    serverSideTestRepo.branch(branch).update(amendedCommit);
    serverSideTestRepo.commit(amendedCommit);
    ChangeInfo info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck(branch);
    input.autoCloseableChangesCheck.fix = true;
    input.autoCloseableChangesCheck.maxCommits = 1;
    CheckProjectResultInfo checkResult = gApi.projects().name(project.get()).check(input);
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges).isEmpty();
    info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    input.autoCloseableChangesCheck.maxCommits = 2;
    checkResult = gApi.projects().name(project.get()).check(input);
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges.stream().map(i -> i._number).collect(toSet())).containsExactly(r.getChange().getId().get());
    info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.MERGED);
}
Also used : GitUtil.pushHead(com.google.gerrit.acceptance.GitUtil.pushHead) Iterables(com.google.common.collect.Iterables) TestRepository(org.eclipse.jgit.junit.TestRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) Test(org.junit.Test) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) Truth.assertThat(com.google.common.truth.Truth.assertThat) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) PersonIdent(org.eclipse.jgit.lib.PersonIdent) InheritableBoolean(com.google.gerrit.extensions.client.InheritableBoolean) ProjectsConsistencyChecker(com.google.gerrit.server.project.ProjectsConsistencyChecker) Collectors.toList(java.util.stream.Collectors.toList) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) AutoCloseableChangesCheckInput(com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput) Collectors.toSet(java.util.stream.Collectors.toSet) ChangeStatus(com.google.gerrit.extensions.client.ChangeStatus) Before(org.junit.Before) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with CheckProjectInput

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

the class CheckProjectIT method nonExistingBranch.

@Test
public void nonExistingBranch() throws Exception {
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck("non-existing");
    UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> gApi.projects().name(project.get()).check(input));
    assertThat(thrown).hasMessageThat().contains("branch 'non-existing' not found");
}
Also used : UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with CheckProjectInput

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

the class CheckProjectIT method tooLargeMaxCommits.

@Test
public void tooLargeMaxCommits() throws Exception {
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck("refs/heads/master");
    input.autoCloseableChangesCheck.maxCommits = ProjectsConsistencyChecker.AUTO_CLOSE_MAX_COMMITS_LIMIT + 1;
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(project.get()).check(input));
    assertThat(thrown).hasMessageThat().contains("max commits can at most be set to " + ProjectsConsistencyChecker.AUTO_CLOSE_MAX_COMMITS_LIMIT);
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with CheckProjectInput

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

the class CheckProjectIT method setLimitForMaxCommits.

@Test
public void setLimitForMaxCommits() throws Exception {
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck("refs/heads/master");
    input.autoCloseableChangesCheck.maxCommits = ProjectsConsistencyChecker.AUTO_CLOSE_MAX_COMMITS_LIMIT;
    gApi.projects().name(project.get()).check(input);
}
Also used : CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

CheckProjectInput (com.google.gerrit.extensions.api.projects.CheckProjectInput)10 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 Test (org.junit.Test)9 AutoCloseableChangesCheckInput (com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput)6 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)6 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)5 Iterables (com.google.common.collect.Iterables)4 Truth.assertThat (com.google.common.truth.Truth.assertThat)4 GitUtil.pushHead (com.google.gerrit.acceptance.GitUtil.pushHead)4 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 CheckProjectResultInfo (com.google.gerrit.extensions.api.projects.CheckProjectResultInfo)4 ChangeStatus (com.google.gerrit.extensions.client.ChangeStatus)4 InheritableBoolean (com.google.gerrit.extensions.client.InheritableBoolean)4 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 ProjectsConsistencyChecker (com.google.gerrit.server.project.ProjectsConsistencyChecker)4 GerritJUnit.assertThrows (com.google.gerrit.testing.GerritJUnit.assertThrows)4 Collectors.toList (java.util.stream.Collectors.toList)4 Collectors.toSet (java.util.stream.Collectors.toSet)4 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)4 TestRepository (org.eclipse.jgit.junit.TestRepository)4