use of com.google.gerrit.server.submit.SubscriptionGraph.DefaultFactory in project gerrit by GerritCodeReview.
the class SubscriptionGraphTest method multipleSuperprojectsToMultipleSubmodules.
@Test
public void multipleSuperprojectsToMultipleSubmodules() throws Exception {
// Create superprojects and subprojects.
Project.NameKey superProject1 = Project.nameKey("superproject1");
Project.NameKey superProject2 = Project.nameKey("superproject2");
Project.NameKey subProject1 = Project.nameKey("subproject1");
Project.NameKey subProject2 = Project.nameKey("subproject2");
TestRepository<Repository> superProjectRepo1 = createRepo(superProject1);
TestRepository<Repository> superProjectRepo2 = createRepo(superProject2);
TestRepository<Repository> submoduleRepo1 = createRepo(subProject1);
TestRepository<Repository> submoduleRepo2 = createRepo(subProject2);
// Initialize super branches.
BranchNameKey superBranch1 = BranchNameKey.create(superProject1, "refs/heads/one");
BranchNameKey superBranch2 = BranchNameKey.create(superProject2, "refs/heads/one");
createBranch(superProjectRepo1, superBranch1, superProjectRepo1.commit().message("Initial commit").create());
createBranch(superProjectRepo2, superBranch2, superProjectRepo2.commit().message("Initial commit").create());
// Initialize sub branches.
BranchNameKey submoduleBranch1 = BranchNameKey.create(subProject1, "refs/heads/one");
BranchNameKey submoduleBranch2 = BranchNameKey.create(subProject1, "refs/heads/two");
BranchNameKey submoduleBranch3 = BranchNameKey.create(subProject2, "refs/heads/one");
createBranch(submoduleRepo1, submoduleBranch1, submoduleRepo1.commit().message("Commit1").create());
createBranch(submoduleRepo1, submoduleBranch2, submoduleRepo1.commit().message("Commit2").create());
createBranch(submoduleRepo2, submoduleBranch3, submoduleRepo2.commit().message("Commit1").create());
allowSubscription(submoduleBranch1);
allowSubscription(submoduleBranch2);
allowSubscription(submoduleBranch3);
// Initialize subscriptions.
setSubscription(submoduleBranch1, ImmutableList.of(superBranch1, superBranch2));
setSubscription(submoduleBranch2, ImmutableList.of(superBranch1));
setSubscription(submoduleBranch3, ImmutableList.of(superBranch1, superBranch2));
SubscriptionGraph.Factory factory = new DefaultFactory(mockGitModulesFactory, mockProjectCache);
SubscriptionGraph subscriptionGraph = factory.compute(ImmutableSet.of(submoduleBranch1, submoduleBranch2), mergeOpRepoManager);
assertThat(subscriptionGraph.getAffectedSuperProjects()).containsExactly(superProject1, superProject2);
assertThat(subscriptionGraph.getAffectedSuperBranches(superProject1)).containsExactly(superBranch1);
assertThat(subscriptionGraph.getAffectedSuperBranches(superProject2)).containsExactly(superBranch2);
assertThat(subscriptionGraph.getSubscriptions(superBranch1)).containsExactly(new SubmoduleSubscription(superBranch1, submoduleBranch1, TEST_PATH), new SubmoduleSubscription(superBranch1, submoduleBranch2, TEST_PATH));
assertThat(subscriptionGraph.getSubscriptions(superBranch2)).containsExactly(new SubmoduleSubscription(superBranch2, submoduleBranch1, TEST_PATH));
assertThat(subscriptionGraph.hasSuperproject(submoduleBranch1)).isTrue();
assertThat(subscriptionGraph.hasSuperproject(submoduleBranch2)).isTrue();
assertThat(subscriptionGraph.hasSuperproject(submoduleBranch3)).isFalse();
assertThat(subscriptionGraph.getSortedSuperprojectAndSubmoduleBranches()).containsExactly(submoduleBranch2, submoduleBranch1, superBranch2, superBranch1).inOrder();
}
use of com.google.gerrit.server.submit.SubscriptionGraph.DefaultFactory in project gerrit by GerritCodeReview.
the class SubscriptionGraphTest method oneSuperprojectOneSubmodule.
@Test
public void oneSuperprojectOneSubmodule() throws Exception {
SubscriptionGraph.Factory factory = new DefaultFactory(mockGitModulesFactory, mockProjectCache);
SubscriptionGraph subscriptionGraph = factory.compute(ImmutableSet.of(SUB_BRANCH), mergeOpRepoManager);
assertThat(subscriptionGraph.getAffectedSuperProjects()).containsExactly(SUPER_PROJECT);
assertThat(subscriptionGraph.getAffectedSuperBranches(SUPER_PROJECT)).containsExactly(SUPER_BRANCH);
assertThat(subscriptionGraph.getSubscriptions(SUPER_BRANCH)).containsExactly(new SubmoduleSubscription(SUPER_BRANCH, SUB_BRANCH, TEST_PATH));
assertThat(subscriptionGraph.hasSuperproject(SUB_BRANCH)).isTrue();
assertThat(subscriptionGraph.getSortedSuperprojectAndSubmoduleBranches()).containsExactly(SUB_BRANCH, SUPER_BRANCH).inOrder();
}
Aggregations