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");
}
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);
}
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");
}
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);
}
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);
}
Aggregations