Search in sources :

Example 46 with Project

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

the class ChangeOperationsImplTest method changeCanBeCreatedInEmptyRepository.

@Test
public void changeCanBeCreatedInEmptyRepository() throws Exception {
    Project.NameKey project = projectOperations.newProject().noEmptyCommit().create();
    Change.Id changeId = changeOperations.newChange().project(project).create();
    ChangeInfo change = getChangeFromServer(changeId);
    assertThat(change.project).isEqualTo(project.get());
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Change(com.google.gerrit.entities.Change) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 47 with Project

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

the class ChangeOperationsImplTest method createdChangeIsInSpecifiedProject.

@Test
public void createdChangeIsInSpecifiedProject() throws Exception {
    Project.NameKey project = projectOperations.newProject().create();
    Change.Id changeId = changeOperations.newChange().project(project).create();
    ChangeInfo change = getChangeFromServer(changeId);
    assertThat(change.project).isEqualTo(project.get());
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Change(com.google.gerrit.entities.Change) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 48 with Project

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

the class ChangeOperationsImplTest method specifiedParentBranchMayHaveShortName.

@Test
public void specifiedParentBranchMayHaveShortName() throws Exception {
    Project.NameKey project = projectOperations.newProject().branches("test-branch").create();
    Change.Id changeId = changeOperations.newChange().project(project).childOf().tipOfBranch("test-branch").create();
    ChangeInfo change = getChangeFromServer(changeId);
    CommitInfo currentPatchsetCommit = change.revisions.get(change.currentRevision).commit;
    ObjectId parentCommitId = projectOperations.project(project).getHead("test-branch").getId();
    assertThat(currentPatchsetCommit).parents().onlyElement().commit().isEqualTo(parentCommitId.name());
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ObjectId(org.eclipse.jgit.lib.ObjectId) Change(com.google.gerrit.entities.Change) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 49 with Project

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

the class ChangeOperationsImplTest method changeOwnerDoesNotNeedAnyPermissionsForChangeCreation.

@Test
public void changeOwnerDoesNotNeedAnyPermissionsForChangeCreation() throws Exception {
    Account.Id changeOwner = accountOperations.newAccount().create();
    Project.NameKey project = projectOperations.newProject().branches("test-branch").create();
    // Remove any read and push permissions which might potentially exist. Without read, users
    // shouldn't be able to do anything. The newly created project should only inherit from
    // All-Projects.
    projectOperations.project(project).forUpdate().remove(permissionKey(Permission.READ).ref("refs/heads/test-branch")).remove(permissionKey(Permission.PUSH).ref("refs/heads/test-branch")).update();
    projectOperations.allProjectsForUpdate().remove(permissionKey(Permission.READ).ref("refs/heads/test-branch")).remove(permissionKey(Permission.PUSH).ref("refs/heads/test-branch")).update();
    Change.Id changeId = changeOperations.newChange().owner(changeOwner).branch("test-branch").project(project).create();
    ChangeInfo change = getChangeFromServer(changeId);
    assertThat(change.owner._accountId).isEqualTo(changeOwner.get());
}
Also used : Account(com.google.gerrit.entities.Account) Project(com.google.gerrit.entities.Project) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Change(com.google.gerrit.entities.Change) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 50 with Project

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

the class ChangeOperationsImplTest method createdChangeUsesTipOfTargetBranchAsParentByDefault.

@Test
public void createdChangeUsesTipOfTargetBranchAsParentByDefault() throws Exception {
    Project.NameKey project = projectOperations.newProject().branches("test-branch").create();
    ObjectId parentCommitId = projectOperations.project(project).getHead("test-branch").getId();
    Change.Id changeId = changeOperations.newChange().project(project).branch("test-branch").create();
    ChangeInfo change = getChangeFromServer(changeId);
    CommitInfo currentPatchsetCommit = change.revisions.get(change.currentRevision).commit;
    assertThat(currentPatchsetCommit).parents().onlyElement().commit().isEqualTo(parentCommitId.name());
}
Also used : Project(com.google.gerrit.entities.Project) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ObjectId(org.eclipse.jgit.lib.ObjectId) Change(com.google.gerrit.entities.Change) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

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