Search in sources :

Example 6 with CheckProjectInput

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

the class CheckProjectIT method fixAutoCloseableChangeByChangeId.

@Test
public void fixAutoCloseableChangeByChangeId() 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);
    ChangeInfo info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck(branch);
    input.autoCloseableChangesCheck.fix = true;
    CheckProjectResultInfo 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 7 with CheckProjectInput

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

the class CheckProjectIT method checkProjectInputForAutoCloseableCheck.

private static CheckProjectInput checkProjectInputForAutoCloseableCheck(String branch) {
    CheckProjectInput input = new CheckProjectInput();
    input.autoCloseableChangesCheck = new AutoCloseableChangesCheckInput();
    input.autoCloseableChangesCheck.branch = branch;
    return input;
}
Also used : CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) AutoCloseableChangesCheckInput(com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput)

Example 8 with CheckProjectInput

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

the class CheckProjectIT method branchPrefixCanBeOmitted.

@Test
public void branchPrefixCanBeOmitted() throws Exception {
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck("master");
    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)

Example 9 with CheckProjectInput

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

the class CheckProjectIT method fixAutoCloseableChangeByCommit.

@Test
public void fixAutoCloseableChangeByCommit() throws Exception {
    RevCommit commit = pushCommitWithoutChangeIdForReview();
    ChangeInfo change = Iterables.getOnlyElement(gApi.changes().query("commit:" + commit.name()).get());
    String branch = "refs/heads/master";
    serverSideTestRepo.branch(branch).update(commit);
    ChangeInfo info = gApi.changes().id(change._number).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck(branch);
    input.autoCloseableChangesCheck.fix = true;
    CheckProjectResultInfo checkResult = gApi.projects().name(project.get()).check(input);
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges.stream().map(i -> i._number).collect(toSet())).containsExactly(change._number);
    info = gApi.changes().id(change._number).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) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 with CheckProjectInput

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

the class CheckProjectIT method skipCommits.

@Test
public void skipCommits() 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.skipCommits = 1;
    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)

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