Search in sources :

Example 36 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class WorkInProgressByDefaultIT method createChangeBypassWorkInProgressByDefaultForProjectEnabled.

@Test
public void createChangeBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
    Project.NameKey project = projectOperations.newProject().create();
    setWorkInProgressByDefaultForProject(project);
    ChangeInput input = new ChangeInput(project.get(), "master", "empty change");
    input.workInProgress = false;
    assertThat(gApi.changes().create(input).get().workInProgress).isNull();
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 37 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class WorkInProgressByDefaultIT method createChangeBypassWorkInProgressByDefaultForUserEnabled.

@Test
public void createChangeBypassWorkInProgressByDefaultForUserEnabled() throws Exception {
    Project.NameKey project = projectOperations.newProject().create();
    setWorkInProgressByDefaultForUser();
    ChangeInput input = new ChangeInput(project.get(), "master", "empty change");
    input.workInProgress = false;
    assertThat(gApi.changes().create(input).get().workInProgress).isNull();
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 38 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class WorkInProgressByDefaultIT method pushNewPatchSetAndNewChangeAtOnceWithWorkInProgressByDefaultForUserEnabled.

@Test
public void pushNewPatchSetAndNewChangeAtOnceWithWorkInProgressByDefaultForUserEnabled() throws Exception {
    Project.NameKey project = projectOperations.newProject().create();
    // Create change.
    TestRepository<InMemoryRepository> testRepo = cloneProject(project);
    RevCommit initialHead = getHead(testRepo.getRepository(), "HEAD");
    RevCommit commit1a = testRepo.commit().parent(initialHead).message("Change 1").insertChangeId().create();
    String changeId1 = GitUtil.getChangeId(testRepo, commit1a).get();
    testRepo.reset(commit1a);
    PushResult result = pushHead(testRepo, "refs/for/master", false);
    assertPushOk(result, "refs/for/master");
    assertThat(gApi.changes().id(changeId1).get().workInProgress).isNull();
    setWorkInProgressByDefaultForUser();
    // Clone the repo again. The test connection keeps an AccountState internally, so we need to
    // create a new connection after changing account properties.
    PatchSet.Id ps1OfChange1 = PatchSet.id(Change.id(gApi.changes().id(changeId1).get()._number), 1);
    testRepo = cloneProject(project);
    testRepo.git().fetch().setRefSpecs(RefNames.patchSetRef(ps1OfChange1) + ":c1").call();
    testRepo.reset("c1");
    // Create a new patch set on the existing change and in the same push create a new successor
    // change.
    RevCommit commit1b = testRepo.amend(commit1a).create();
    testRepo.reset(commit1b);
    RevCommit commit2 = testRepo.commit().parent(commit1b).message("Change 2").insertChangeId().create();
    String changeId2 = GitUtil.getChangeId(testRepo, commit2).get();
    testRepo.reset(commit2);
    result = pushHead(testRepo, "refs/for/master", false);
    assertPushOk(result, "refs/for/master");
    // Check that the existing change (changeId1) is not marked as WIP, but only the newly created
    // change (changeId2).
    assertThat(gApi.changes().id(changeId1).get().workInProgress).isNull();
    assertThat(gApi.changes().id(changeId2).get().workInProgress).isTrue();
}
Also used : Project(com.google.gerrit.entities.Project) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PatchSet(com.google.gerrit.entities.PatchSet) PushResult(org.eclipse.jgit.transport.PushResult) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 39 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class WorkInProgressByDefaultIT method createChangeWithWorkInProgressByDefaultForUserEnabled.

@Test
public void createChangeWithWorkInProgressByDefaultForUserEnabled() throws Exception {
    Project.NameKey project = projectOperations.newProject().create();
    setWorkInProgressByDefaultForUser();
    ChangeInput input = new ChangeInput(project.get(), "master", "empty change");
    assertThat(gApi.changes().create(input).get().workInProgress).isTrue();
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 40 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class ChangeFieldTest method tolerateNullValuesForInsertion.

@Test
public void tolerateNullValuesForInsertion() {
    Project.NameKey project = Project.nameKey("project");
    ChangeData cd = ChangeData.createForTest(project, Change.id(1), 1, ObjectId.zeroId());
    assertThat(ChangeField.ADDED.setIfPossible(cd, new FakeStoredValue(null))).isTrue();
}
Also used : Project(com.google.gerrit.entities.Project) FakeStoredValue(com.google.gerrit.index.testing.FakeStoredValue) ChangeData(com.google.gerrit.server.query.change.ChangeData) Test(org.junit.Test)

Aggregations

Project (com.google.gerrit.entities.Project)184 Test (org.junit.Test)109 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)67 Change (com.google.gerrit.entities.Change)43 Repository (org.eclipse.jgit.lib.Repository)34 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)33 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)32 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)31 BranchNameKey (com.google.gerrit.entities.BranchNameKey)30 Config (org.eclipse.jgit.lib.Config)26 ObjectId (org.eclipse.jgit.lib.ObjectId)26 IOException (java.io.IOException)25 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)24 ProjectState (com.google.gerrit.server.project.ProjectState)23 Inject (com.google.inject.Inject)23 List (java.util.List)23 AuthException (com.google.gerrit.extensions.restapi.AuthException)22 ChangeData (com.google.gerrit.server.query.change.ChangeData)22 RevCommit (org.eclipse.jgit.revwalk.RevCommit)22 PatchSet (com.google.gerrit.entities.PatchSet)20