TestProjectCreation: add owners setting
Change-Id: I3364c044338663326ab11b1f748495d50bbd9d43
This commit is contained in:
		| @@ -96,7 +96,7 @@ public class ProjectOperationsImpl implements ProjectOperations { | ||||
|     args.createEmptyCommit = projectCreation.createEmptyCommit().orElse(true); | ||||
|     projectCreation.parent().ifPresent(p -> args.newParent = p); | ||||
|     // ProjectCreator wants non-null owner IDs. | ||||
|     args.ownerIds = new ArrayList<>(); | ||||
|     args.ownerIds = new ArrayList<>(projectCreation.owners()); | ||||
|     projectCreation.submitType().ifPresent(st -> args.submitType = st); | ||||
|     projectCreator.createProject(args); | ||||
|     return Project.nameKey(name); | ||||
|   | ||||
| @@ -14,8 +14,12 @@ | ||||
|  | ||||
| package com.google.gerrit.acceptance.testsuite.project; | ||||
|  | ||||
| import static java.util.Objects.requireNonNull; | ||||
|  | ||||
| import com.google.auto.value.AutoValue; | ||||
| import com.google.common.collect.ImmutableSet; | ||||
| import com.google.gerrit.acceptance.testsuite.ThrowingFunction; | ||||
| import com.google.gerrit.entities.AccountGroup; | ||||
| import com.google.gerrit.entities.Project; | ||||
| import com.google.gerrit.extensions.client.SubmitType; | ||||
| import java.util.Optional; | ||||
| @@ -33,6 +37,8 @@ public abstract class TestProjectCreation { | ||||
|  | ||||
|   public abstract Optional<SubmitType> submitType(); | ||||
|  | ||||
|   public abstract ImmutableSet<AccountGroup.UUID> owners(); | ||||
|  | ||||
|   abstract ThrowingFunction<TestProjectCreation, Project.NameKey> projectCreator(); | ||||
|  | ||||
|   public static Builder builder( | ||||
| @@ -57,6 +63,13 @@ public abstract class TestProjectCreation { | ||||
|       return createEmptyCommit(false); | ||||
|     } | ||||
|  | ||||
|     public TestProjectCreation.Builder addOwner(AccountGroup.UUID owner) { | ||||
|       ownersBuilder().add(requireNonNull(owner, "owner")); | ||||
|       return this; | ||||
|     } | ||||
|  | ||||
|     abstract ImmutableSet.Builder<AccountGroup.UUID> ownersBuilder(); | ||||
|  | ||||
|     abstract TestProjectCreation.Builder projectCreator( | ||||
|         ThrowingFunction<TestProjectCreation, Project.NameKey> projectCreator); | ||||
|  | ||||
|   | ||||
| @@ -38,8 +38,10 @@ import static java.util.stream.Collectors.toList; | ||||
| import com.google.common.collect.ImmutableList; | ||||
| import com.google.common.collect.ImmutableListMultimap; | ||||
| import com.google.gerrit.acceptance.AbstractDaemonTest; | ||||
| import com.google.gerrit.acceptance.testsuite.group.GroupOperations; | ||||
| import com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.TestPermission; | ||||
| import com.google.gerrit.common.data.Permission; | ||||
| import com.google.gerrit.entities.AccountGroup; | ||||
| import com.google.gerrit.entities.Project; | ||||
| import com.google.gerrit.entities.RefNames; | ||||
| import com.google.gerrit.extensions.api.projects.BranchInfo; | ||||
| @@ -57,6 +59,7 @@ import org.junit.Test; | ||||
| public class ProjectOperationsImplTest extends AbstractDaemonTest { | ||||
|  | ||||
|   @Inject private ProjectOperations projectOperations; | ||||
|   @Inject private GroupOperations groupsOperations; | ||||
|  | ||||
|   @Test | ||||
|   public void defaultName() throws Exception { | ||||
| @@ -91,6 +94,13 @@ public class ProjectOperationsImplTest extends AbstractDaemonTest { | ||||
|     assertThat(head).isEqualTo(RefNames.REFS_CONFIG); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void createWithOwners() throws Exception { | ||||
|     AccountGroup.UUID uuid = groupsOperations.newGroup().create(); | ||||
|     Project.NameKey key = projectOperations.newProject().addOwner(uuid).create(); | ||||
|     assertPermissions(key, groupRef(uuid), "refs/*", false, Permission.OWNER); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void getProjectConfig() throws Exception { | ||||
|     Project.NameKey key = projectOperations.newProject().create(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sven Selberg
					Sven Selberg