Push down remaining AbstractDaemonTest#createProject() calls
Change-Id: I4dc5f41b27bb39a7354139bf5c373686fa993d17
This commit is contained in:
committed by
David Pursehouse
parent
f6b69bc2dd
commit
63f120d942
@@ -38,7 +38,6 @@ import com.google.common.jimfs.Jimfs;
|
||||
import com.google.common.primitives.Chars;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope.Context;
|
||||
import com.google.gerrit.acceptance.testsuite.account.TestSshKeys;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GroupDescription;
|
||||
@@ -295,7 +294,6 @@ public abstract class AbstractDaemonTest {
|
||||
@Inject private AccountIndexer accountIndexer;
|
||||
@Inject private Groups groups;
|
||||
@Inject private GroupIndexer groupIndexer;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
private ProjectResetter resetter;
|
||||
private List<Repository> toClose;
|
||||
@@ -552,43 +550,6 @@ public abstract class AbstractDaemonTest {
|
||||
return resourcePrefix + name;
|
||||
}
|
||||
|
||||
protected Project.NameKey createProject(String nameSuffix, Project.NameKey parent)
|
||||
throws Exception {
|
||||
// Default for createEmptyCommit should match TestProjectConfig.
|
||||
return projectOperations.newProject().parent(parent).create();
|
||||
}
|
||||
|
||||
protected Project.NameKey createProject(
|
||||
String nameSuffix, Project.NameKey parent, boolean createEmptyCommit) throws Exception {
|
||||
// Default for createEmptyCommit should match TestProjectConfig.
|
||||
if (parent == null) {
|
||||
return projectOperations.newProject().createEmptyCommit(createEmptyCommit).create();
|
||||
}
|
||||
return projectOperations
|
||||
.newProject()
|
||||
.parent(parent)
|
||||
.createEmptyCommit(createEmptyCommit)
|
||||
.create();
|
||||
}
|
||||
|
||||
protected Project.NameKey createProject(
|
||||
String nameSuffix, Project.NameKey parent, boolean createEmptyCommit, SubmitType submitType)
|
||||
throws Exception {
|
||||
if (parent == null) {
|
||||
return projectOperations
|
||||
.newProject()
|
||||
.createEmptyCommit(createEmptyCommit)
|
||||
.submitType(submitType)
|
||||
.create();
|
||||
}
|
||||
return projectOperations
|
||||
.newProject()
|
||||
.submitType(submitType)
|
||||
.parent(parent)
|
||||
.createEmptyCommit(createEmptyCommit)
|
||||
.create();
|
||||
}
|
||||
|
||||
protected Project.NameKey createProjectOverAPI(
|
||||
String nameSuffix, Project.NameKey parent, boolean createEmptyCommit, SubmitType submitType)
|
||||
throws RestApiException {
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
@@ -73,6 +74,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
private static final String JIRA_MATCH = "(jira\\\\s+#?)(\\\\d+)";
|
||||
|
||||
@Inject private DynamicSet<ProjectIndexedListener> projectIndexedListeners;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Inject
|
||||
@IndexExecutor(BATCH)
|
||||
@@ -429,7 +431,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void reindexProject() throws Exception {
|
||||
createProject("child", project);
|
||||
projectOperations.newProject().parent(project).create();
|
||||
projectIndexedCounter.clear();
|
||||
|
||||
gApi.projects().name(allProjects.get()).index(false);
|
||||
@@ -438,8 +440,8 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void reindexProjectWithChildren() throws Exception {
|
||||
Project.NameKey middle = createProject("middle", project);
|
||||
Project.NameKey leave = createProject("leave", middle);
|
||||
Project.NameKey middle = projectOperations.newProject().parent(project).create();
|
||||
Project.NameKey leave = projectOperations.newProject().parent(middle).create();
|
||||
projectIndexedCounter.clear();
|
||||
|
||||
gApi.projects().name(project.get()).index(true);
|
||||
@@ -473,7 +475,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.inheritProjectMaxObjectSizeLimit", value = "true")
|
||||
public void maxObjectSizeIsInheritedFromParentProject() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("100k");
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
|
||||
@@ -489,7 +491,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void maxObjectSizeIsNotInheritedFromParentProject() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("100k");
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
|
||||
@@ -504,7 +506,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void maxObjectSizeOverridesParentProjectWhenNotSetOnParent() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("0");
|
||||
assertThat(info.maxObjectSizeLimit.value).isNull();
|
||||
@@ -519,7 +521,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void maxObjectSizeOverridesParentProjectWhenLower() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("200k");
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800");
|
||||
@@ -535,7 +537,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.inheritProjectMaxObjectSizeLimit", value = "true")
|
||||
public void maxObjectSizeDoesNotOverrideParentProjectWhenHigher() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("100k");
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
|
||||
@@ -552,7 +554,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
|
||||
public void maxObjectSizeIsInheritedFromGlobalConfig() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = getConfig();
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800");
|
||||
@@ -577,7 +579,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "300k")
|
||||
public void inheritedMaxObjectSizeOverridesGlobalConfigWhenLower() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("200k");
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800");
|
||||
@@ -594,7 +596,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
|
||||
@GerritConfig(name = "receive.inheritProjectMaxObjectSizeLimit", value = "true")
|
||||
public void maxObjectSizeDoesNotOverrideGlobalConfigWhenHigher() throws Exception {
|
||||
Project.NameKey child = createProject(name("child"), project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
ConfigInfo info = setMaxObjectSize("300k");
|
||||
assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800");
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gerrit.index.RefState;
|
||||
@@ -45,6 +46,7 @@ public class ProjectIndexerIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectIndexCollection indexes;
|
||||
@Inject private IndexConfig indexConfig;
|
||||
@Inject private StalenessChecker stalenessChecker;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
private static final ImmutableSet<String> FIELDS =
|
||||
ImmutableSet.of(ProjectField.NAME.getName(), ProjectField.REF_STATE.getName());
|
||||
@@ -96,8 +98,8 @@ public class ProjectIndexerIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void stalenessChecker_hierarchyChange_isStale() throws Exception {
|
||||
Project.NameKey p1 = createProject("p1", allProjects);
|
||||
Project.NameKey p2 = createProject("p2", allProjects);
|
||||
Project.NameKey p1 = projectOperations.newProject().create();
|
||||
Project.NameKey p2 = projectOperations.newProject().create();
|
||||
try (ProjectConfigUpdate u = updateProject(project)) {
|
||||
u.getConfig().getProject().setParentName(p1);
|
||||
u.save();
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -27,14 +28,17 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class SetParentIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Test
|
||||
public void setParentNotAllowed() throws Exception {
|
||||
String parent = createProject("parent", null, true).get();
|
||||
String parent = this.projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
@@ -43,7 +47,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.allowProjectOwnersToChangeParent", value = "true")
|
||||
public void setParentNotAllowedForNonOwners() throws Exception {
|
||||
String parent = createProject("parent", null, true).get();
|
||||
String parent = this.projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
@@ -52,7 +56,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.allowProjectOwnersToChangeParent", value = "true")
|
||||
public void setParentAllowedByAdminWhenAllowProjectOwnersEnabled() throws Exception {
|
||||
String parent = createProject("parent", null, true).get();
|
||||
String parent = this.projectOperations.newProject().create().get();
|
||||
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
assertThat(gApi.projects().name(project.get()).parent()).isEqualTo(parent);
|
||||
@@ -67,7 +71,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "receive.allowProjectOwnersToChangeParent", value = "true")
|
||||
public void setParentAllowedForOwners() throws Exception {
|
||||
String parent = createProject("parent", null, true).get();
|
||||
String parent = this.projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
grant(project, "refs/*", Permission.OWNER, false, SystemGroupBackend.REGISTERED_USERS);
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
@@ -76,7 +80,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void setParent() throws Exception {
|
||||
String parent = createProject("parent", null, true).get();
|
||||
String parent = this.projectOperations.newProject().create().get();
|
||||
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
assertThat(gApi.projects().name(project.get()).parent()).isEqualTo(parent);
|
||||
@@ -104,7 +108,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void setParentToOwnChildNotAllowed() throws Exception {
|
||||
String child = createProject("child", project, true).get();
|
||||
String child = projectOperations.newProject().parent(project).create().get();
|
||||
exception.expect(ResourceConflictException.class);
|
||||
exception.expectMessage("cycle exists between");
|
||||
gApi.projects().name(project.get()).parent(child);
|
||||
@@ -112,8 +116,8 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void setParentToGrandchildNotAllowed() throws Exception {
|
||||
Project.NameKey child = createProject("child", project, true);
|
||||
String grandchild = createProject("grandchild", child, true).get();
|
||||
Project.NameKey child = this.projectOperations.newProject().parent(project).create();
|
||||
String grandchild = this.projectOperations.newProject().parent(child).create().get();
|
||||
exception.expect(ResourceConflictException.class);
|
||||
exception.expectMessage("cycle exists between");
|
||||
gApi.projects().name(project.get()).parent(grandchild);
|
||||
@@ -137,7 +141,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
public void setParentForAllUsersMustBeAllProjects() throws Exception {
|
||||
gApi.projects().name(allUsers.get()).parent(allProjects.get());
|
||||
|
||||
String parent = createProject("parent", null, true).get();
|
||||
String parent = this.projectOperations.newProject().create().get();
|
||||
|
||||
exception.expect(BadRequestException.class);
|
||||
exception.expectMessage("All-Users must inherit from All-Projects");
|
||||
|
||||
@@ -20,7 +20,6 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.SubscribeSection;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
@@ -104,15 +103,14 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
protected Project.NameKey createProjectForPush(
|
||||
String name,
|
||||
@Nullable Project.NameKey parent,
|
||||
boolean createEmptyCommit,
|
||||
SubmitType submitType)
|
||||
throws Exception {
|
||||
Project.NameKey project = createProject(name, parent, createEmptyCommit, submitType);
|
||||
protected void grantPush(Project.NameKey project) throws Exception {
|
||||
grant(project, "refs/heads/*", Permission.PUSH);
|
||||
grant(project, "refs/for/refs/heads/*", Permission.SUBMIT);
|
||||
}
|
||||
|
||||
protected Project.NameKey createProjectForPush(SubmitType submitType) throws Exception {
|
||||
Project.NameKey project = this.projectOperations.newProject().submitType(submitType).create();
|
||||
grantPush(project);
|
||||
return project;
|
||||
}
|
||||
|
||||
@@ -120,8 +118,8 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
superKey = createProjectForPush("super", null, true, getSubmitType());
|
||||
subKey = createProjectForPush("sub", null, true, getSubmitType());
|
||||
superKey = createProjectForPush(getSubmitType());
|
||||
subKey = createProjectForPush(getSubmitType());
|
||||
superRepo = cloneProject(superKey);
|
||||
subRepo = cloneProject(subKey);
|
||||
}
|
||||
|
||||
@@ -403,12 +403,16 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
|
||||
@Test
|
||||
public void subscriptionInheritACL() throws Exception {
|
||||
Project.NameKey configKey = createProjectForPush("config-repo", null, true, getSubmitType());
|
||||
Project.NameKey configKey =
|
||||
this.projectOperations.newProject().submitType(getSubmitType()).create();
|
||||
grantPush(configKey);
|
||||
Project.NameKey config2Key =
|
||||
createProjectForPush("config-repo2", configKey, true, getSubmitType());
|
||||
projectOperations.newProject().parent(configKey).submitType(getSubmitType()).create();
|
||||
grantPush(config2Key);
|
||||
cloneProject(config2Key);
|
||||
|
||||
subKey = createProjectForPush("subrepo", config2Key, true, getSubmitType());
|
||||
subKey = projectOperations.newProject().parent(config2Key).submitType(getSubmitType()).create();
|
||||
grantPush(subKey);
|
||||
subRepo = cloneProject(subKey);
|
||||
|
||||
allowMatchingSubmoduleSubscription(configKey, "refs/heads/*", superKey, "refs/heads/*");
|
||||
@@ -445,8 +449,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
|
||||
@Test
|
||||
public void subscriptionDeepRelative() throws Exception {
|
||||
Project.NameKey nest =
|
||||
createProjectForPush("nested/subscribed-to-project", null, true, getSubmitType());
|
||||
Project.NameKey nest = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> subRepo = cloneProject(nest);
|
||||
// master is allowed to be subscribed to any superprojects branch:
|
||||
allowMatchingSubmoduleSubscription(nest, "refs/heads/master", superKey, null);
|
||||
@@ -511,8 +514,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestTimeUtil.resetWithClockStep(1, SECONDS);
|
||||
try {
|
||||
|
||||
Project.NameKey proj2 =
|
||||
createProjectForPush("subscribed-to-project-2", null, true, getSubmitType());
|
||||
Project.NameKey proj2 = createProjectForPush(getSubmitType());
|
||||
|
||||
TestRepository<?> subRepo2 = cloneProject(proj2);
|
||||
allowMatchingSubmoduleSubscription(
|
||||
@@ -559,8 +561,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
// is afterwards.
|
||||
TestTimeUtil.resetWithClockStep(1, SECONDS);
|
||||
try {
|
||||
Project.NameKey proj2 =
|
||||
createProjectForPush("subscribed-to-project-2", null, true, getSubmitType());
|
||||
Project.NameKey proj2 = createProjectForPush(getSubmitType());
|
||||
TestRepository<InMemoryRepository> repo2 = cloneProject(proj2, user);
|
||||
|
||||
allowMatchingSubmoduleSubscription(
|
||||
@@ -604,10 +605,8 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
|
||||
@Test
|
||||
public void updateOnlyRelevantSubmodules() throws Exception {
|
||||
Project.NameKey subkey1 =
|
||||
createProjectForPush("subscribed-to-project-1", null, true, getSubmitType());
|
||||
Project.NameKey subkey2 =
|
||||
createProjectForPush("subscribed-to-project-2", null, true, getSubmitType());
|
||||
Project.NameKey subkey1 = createProjectForPush(getSubmitType());
|
||||
Project.NameKey subkey2 = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> subRepo1 = cloneProject(subkey1);
|
||||
TestRepository<?> subRepo2 = cloneProject(subkey2);
|
||||
|
||||
|
||||
@@ -367,8 +367,20 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
@Test
|
||||
public void doNotUseFastForward() throws Exception {
|
||||
// like setup, but without empty commit
|
||||
superKey = createProjectForPush("super-nc", null, false, getSubmitType());
|
||||
subKey = createProjectForPush("sub-nc", null, false, getSubmitType());
|
||||
superKey =
|
||||
this.projectOperations
|
||||
.newProject()
|
||||
.submitType(getSubmitType())
|
||||
.createEmptyCommit(false)
|
||||
.create();
|
||||
grantPush(superKey);
|
||||
subKey =
|
||||
this.projectOperations
|
||||
.newProject()
|
||||
.submitType(getSubmitType())
|
||||
.createEmptyCommit(false)
|
||||
.create();
|
||||
grantPush(subKey);
|
||||
superRepo = cloneProject(superKey);
|
||||
subRepo = cloneProject(subKey);
|
||||
|
||||
@@ -395,8 +407,20 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
@Test
|
||||
public void useFastForwardWhenNoSubmodule() throws Exception {
|
||||
// like setup, but without empty commit
|
||||
superKey = createProjectForPush("super-nc", null, false, getSubmitType());
|
||||
subKey = createProjectForPush("sub-nc", null, false, getSubmitType());
|
||||
superKey =
|
||||
this.projectOperations
|
||||
.newProject()
|
||||
.submitType(getSubmitType())
|
||||
.createEmptyCommit(false)
|
||||
.create();
|
||||
grantPush(superKey);
|
||||
subKey =
|
||||
this.projectOperations
|
||||
.newProject()
|
||||
.submitType(getSubmitType())
|
||||
.createEmptyCommit(false)
|
||||
.create();
|
||||
grantPush(subKey);
|
||||
superRepo = cloneProject(superKey);
|
||||
subRepo = cloneProject(subKey);
|
||||
|
||||
@@ -493,7 +517,7 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
|
||||
@Test
|
||||
public void nonSubmoduleInSameTopic() throws Exception {
|
||||
Project.NameKey standaloneKey = createProjectForPush("standalone", null, true, getSubmitType());
|
||||
Project.NameKey standaloneKey = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> standAlone = cloneProject(standaloneKey);
|
||||
|
||||
allowMatchingSubmoduleSubscription(subKey, "refs/heads/master", superKey, "refs/heads/master");
|
||||
@@ -533,9 +557,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
|
||||
@Test
|
||||
public void recursiveSubmodules() throws Exception {
|
||||
Project.NameKey topKey = createProjectForPush("top-project", null, true, getSubmitType());
|
||||
Project.NameKey midKey = createProjectForPush("mid-project", null, true, getSubmitType());
|
||||
Project.NameKey botKey = createProjectForPush("bottom-project", null, true, getSubmitType());
|
||||
Project.NameKey topKey = createProjectForPush(getSubmitType());
|
||||
Project.NameKey midKey = createProjectForPush(getSubmitType());
|
||||
Project.NameKey botKey = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> topRepo = cloneProject(topKey);
|
||||
TestRepository<?> midRepo = cloneProject(midKey);
|
||||
TestRepository<?> bottomRepo = cloneProject(botKey);
|
||||
@@ -563,9 +587,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
|
||||
@Test
|
||||
public void triangleSubmodules() throws Exception {
|
||||
Project.NameKey topKey = createProjectForPush("top-project", null, true, getSubmitType());
|
||||
Project.NameKey midKey = createProjectForPush("mid-project", null, true, getSubmitType());
|
||||
Project.NameKey botKey = createProjectForPush("bottom-project", null, true, getSubmitType());
|
||||
Project.NameKey topKey = createProjectForPush(getSubmitType());
|
||||
Project.NameKey midKey = createProjectForPush(getSubmitType());
|
||||
Project.NameKey botKey = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> topRepo = cloneProject(topKey);
|
||||
TestRepository<?> midRepo = cloneProject(midKey);
|
||||
TestRepository<?> bottomRepo = cloneProject(botKey);
|
||||
@@ -597,9 +621,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
}
|
||||
|
||||
private String prepareBranchCircularSubscription() throws Exception {
|
||||
Project.NameKey topKey = createProjectForPush("top-project", null, true, getSubmitType());
|
||||
Project.NameKey midKey = createProjectForPush("mid-project", null, true, getSubmitType());
|
||||
Project.NameKey botKey = createProjectForPush("bottom-project", null, true, getSubmitType());
|
||||
Project.NameKey topKey = createProjectForPush(getSubmitType());
|
||||
Project.NameKey midKey = createProjectForPush(getSubmitType());
|
||||
Project.NameKey botKey = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> topRepo = cloneProject(topKey);
|
||||
TestRepository<?> midRepo = cloneProject(midKey);
|
||||
TestRepository<?> bottomRepo = cloneProject(botKey);
|
||||
@@ -662,8 +686,8 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
|
||||
@Test
|
||||
public void projectNoSubscriptionWholeTopic() throws Exception {
|
||||
Project.NameKey keyA = createProjectForPush("project-a", null, true, getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush("project-b", null, true, getSubmitType());
|
||||
Project.NameKey keyA = createProjectForPush(getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush(getSubmitType());
|
||||
|
||||
TestRepository<?> repoA = cloneProject(keyA);
|
||||
TestRepository<?> repoB = cloneProject(keyB);
|
||||
@@ -733,8 +757,8 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
|
||||
@Test
|
||||
public void twoProjectsMultipleBranchesWholeTopic() throws Exception {
|
||||
Project.NameKey keyA = createProjectForPush("project-a", null, true, getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush("project-b", null, true, getSubmitType());
|
||||
Project.NameKey keyA = createProjectForPush(getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoA = cloneProject(keyA);
|
||||
TestRepository<?> repoB = cloneProject(keyB);
|
||||
// bootstrap the dev branch
|
||||
@@ -782,9 +806,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
public void retrySubmitAfterTornTopicOnLockFailure() throws Exception {
|
||||
assume().that(notesMigration.disableChangeReviewDb()).isTrue();
|
||||
|
||||
Project.NameKey subKey1 = createProjectForPush("sub1", null, true, getSubmitType());
|
||||
Project.NameKey subKey1 = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> sub1 = cloneProject(subKey1);
|
||||
Project.NameKey subKey2 = createProjectForPush("sub2", null, true, getSubmitType());
|
||||
Project.NameKey subKey2 = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> sub2 = cloneProject(subKey2);
|
||||
|
||||
allowMatchingSubmoduleSubscription(subKey1, "refs/heads/master", superKey, "refs/heads/master");
|
||||
@@ -844,9 +868,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
||||
|
||||
@Test
|
||||
public void skipUpdatingBrokenGitlinkPointer() throws Exception {
|
||||
Project.NameKey subKey1 = createProjectForPush("sub1", null, true, getSubmitType());
|
||||
Project.NameKey subKey1 = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> sub1 = cloneProject(subKey1);
|
||||
Project.NameKey subKey2 = createProjectForPush("sub2", null, true, getSubmitType());
|
||||
Project.NameKey subKey2 = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> sub2 = cloneProject(subKey2);
|
||||
|
||||
allowMatchingSubmoduleSubscription(subKey1, "refs/heads/master", superKey, "refs/heads/master");
|
||||
|
||||
@@ -27,11 +27,13 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.rest.util.RestApiCallHelper;
|
||||
import com.google.gerrit.acceptance.rest.util.RestCall;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.api.projects.TagInput;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@@ -156,6 +158,7 @@ public class ProjectsRestApiBindingsIT extends AbstractDaemonTest {
|
||||
ImmutableList.of(RestCall.get("/projects/%s/commits/%s/files/%s/content"));
|
||||
|
||||
private static final String FILENAME = "test.txt";
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Test
|
||||
public void projectEndpoints() throws Exception {
|
||||
@@ -164,7 +167,7 @@ public class ProjectsRestApiBindingsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void childProjectEndpoints() throws Exception {
|
||||
Project.NameKey childProject = createProject("test-child-repo", project);
|
||||
Project.NameKey childProject = projectOperations.newProject().parent(project).create();
|
||||
RestApiCallHelper.execute(
|
||||
adminRestSession, CHILD_PROJECT_ENDPOINTS, project.get(), childProject.get());
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.TestProjectCreation;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||
@@ -67,7 +65,6 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.Project.NameKey;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.ApprovalsUtil;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
@@ -389,9 +386,9 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
String topic = "test-topic";
|
||||
|
||||
// Create test projects
|
||||
Project.NameKey keyA = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyA = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoA = cloneProject(keyA);
|
||||
Project.NameKey keyB = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoB = cloneProject(keyB);
|
||||
|
||||
// Create changes on project-a
|
||||
@@ -425,7 +422,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
String topic = "test-topic";
|
||||
|
||||
// Create test project
|
||||
Project.NameKey keyA = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyA = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoA = cloneProject(keyA);
|
||||
|
||||
RevCommit initialHead = getRemoteHead(keyA, "master");
|
||||
@@ -775,9 +772,9 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
String topic = "test-topic";
|
||||
|
||||
// Create test projects
|
||||
Project.NameKey keyA = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyA = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoA = cloneProject(keyA);
|
||||
Project.NameKey keyB = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoB = cloneProject(keyB);
|
||||
|
||||
// Create changes on project-a
|
||||
@@ -940,8 +937,8 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
|
||||
String topic = "test-topic";
|
||||
|
||||
Project.NameKey keyA = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush(null, getSubmitType());
|
||||
Project.NameKey keyA = createProjectForPush(getSubmitType());
|
||||
Project.NameKey keyB = createProjectForPush(getSubmitType());
|
||||
TestRepository<?> repoA = cloneProject(keyA);
|
||||
TestRepository<?> repoB = cloneProject(keyB);
|
||||
|
||||
@@ -1362,13 +1359,8 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
// TODO(hanwen): the submodule tests have a similar method; maybe we could share code?
|
||||
protected Project.NameKey createProjectForPush(@Nullable NameKey parent, SubmitType submitType)
|
||||
throws Exception {
|
||||
TestProjectCreation.Builder b = projectOperations.newProject().submitType(submitType);
|
||||
if (parent != null) {
|
||||
b.parent(parent);
|
||||
}
|
||||
Project.NameKey project = b.create();
|
||||
protected Project.NameKey createProjectForPush(SubmitType submitType) throws Exception {
|
||||
Project.NameKey project = projectOperations.newProject().submitType(submitType).create();
|
||||
grant(project, "refs/heads/*", Permission.PUSH);
|
||||
grant(project, "refs/for/refs/heads/*", Permission.SUBMIT);
|
||||
return project;
|
||||
|
||||
@@ -19,11 +19,13 @@ import com.google.gerrit.acceptance.AcceptanceTestRequestScope.Context;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.junit.Before;
|
||||
@@ -32,6 +34,7 @@ import org.junit.Test;
|
||||
public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
|
||||
private TestAccount user2;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -63,7 +66,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
public void testChangeOwner_OwnerACLGrantedOnParentProject() throws Exception {
|
||||
setApiUser(admin);
|
||||
grantApproveToChangeOwner(project);
|
||||
Project.NameKey child = createProject("child", project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
setApiUser(user);
|
||||
TestRepository<InMemoryRepository> childRepo = cloneProject(child, user);
|
||||
@@ -74,7 +77,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
public void testChangeOwner_BlockedOnParentProject() throws Exception {
|
||||
setApiUser(admin);
|
||||
blockApproveForChangeOwner(project);
|
||||
Project.NameKey child = createProject("child", project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
setApiUser(user);
|
||||
grantApproveToAll(child);
|
||||
@@ -92,7 +95,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
public void testChangeOwner_BlockedOnParentProjectAndExclusiveAllowOnChild() throws Exception {
|
||||
setApiUser(admin);
|
||||
blockApproveForChangeOwner(project);
|
||||
Project.NameKey child = createProject("child", project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
setApiUser(user);
|
||||
grantExclusiveApproveToAll(child);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PrivateByDefaultIT extends AbstractDaemonTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
project1 = projectOperations.newProject().create();
|
||||
project2 = createProject("project-2", project1);
|
||||
project2 = this.projectOperations.newProject().parent(project1).create();
|
||||
setPrivateByDefault(project1, InheritableBoolean.FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void getGrandChildProject_NotFound() throws Exception {
|
||||
Project.NameKey child = projectOperations.newProject().create();
|
||||
Project.NameKey grandChild = createProject("p1.1", child);
|
||||
Project.NameKey grandChild = this.projectOperations.newProject().parent(child).create();
|
||||
|
||||
assertChildNotFound(allProjects, grandChild.get());
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void getGrandChildProjectWithRecursiveFlag() throws Exception {
|
||||
Project.NameKey child = projectOperations.newProject().create();
|
||||
Project.NameKey grandChild = createProject("p1.1", child);
|
||||
Project.NameKey grandChild = this.projectOperations.newProject().parent(child).create();
|
||||
|
||||
ProjectInfo grandChildInfo =
|
||||
gApi.projects().name(allProjects.get()).child(grandChild.get()).get(true);
|
||||
|
||||
@@ -44,8 +44,8 @@ public class ListChildProjectsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listChildren() throws Exception {
|
||||
Project.NameKey child1 = projectOperations.newProject().create();
|
||||
Project.NameKey child1_1 = createProject("p1.1", child1);
|
||||
Project.NameKey child1_2 = createProject("p1.2", child1);
|
||||
Project.NameKey child1_1 = this.projectOperations.newProject().parent(child1).create();
|
||||
Project.NameKey child1_2 = this.projectOperations.newProject().parent(child1).create();
|
||||
|
||||
assertThatNameList(gApi.projects().name(child1.get()).children()).isOrdered();
|
||||
assertThatNameList(gApi.projects().name(child1.get()).children())
|
||||
|
||||
@@ -104,7 +104,6 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void listProjectsWithPrefix() throws Exception {
|
||||
// Default for createEmptyCommit should match TestProjectConfig.
|
||||
Project.NameKey someProject = projectOperations.newProject().name("listtest-p1").create();
|
||||
Project.NameKey someOtherProject = projectOperations.newProject().name("listtest-p2").create();
|
||||
projectOperations.newProject().name("other-prefix-project").create();
|
||||
@@ -171,10 +170,8 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void listProjectsWithTree() throws Exception {
|
||||
// Default for createEmptyCommit should match TestProjectConfig.
|
||||
Project.NameKey someParentProject =
|
||||
projectOperations.newProject().name("some-parent-project").create();
|
||||
// Default for createEmptyCommit should match TestProjectConfig.
|
||||
Project.NameKey someChildProject =
|
||||
projectOperations
|
||||
.newProject()
|
||||
|
||||
@@ -19,9 +19,11 @@ import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@@ -29,6 +31,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
fetch(testRepo, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
@@ -82,7 +86,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
.to(RefNames.REFS_CONFIG)
|
||||
.assertOkStatus();
|
||||
|
||||
Project.NameKey childProject = createProject("child", project);
|
||||
Project.NameKey childProject = projectOperations.newProject().parent(project).create();
|
||||
TestRepository<?> childTestRepo = cloneProject(childProject);
|
||||
fetch(childTestRepo, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
childTestRepo.reset("refs/heads/config");
|
||||
@@ -137,7 +141,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
.to(RefNames.REFS_CONFIG)
|
||||
.assertOkStatus();
|
||||
|
||||
Project.NameKey childProject = createProject("child", project);
|
||||
Project.NameKey childProject = projectOperations.newProject().parent(project).create();
|
||||
TestRepository<?> childTestRepo = cloneProject(childProject);
|
||||
fetch(childTestRepo, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
childTestRepo.reset("refs/heads/config");
|
||||
|
||||
Reference in New Issue
Block a user