Search in sources :

Example 1 with SubmoduleSectionParser

use of com.google.gerrit.server.util.SubmoduleSectionParser in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withSubProjectFound.

@Test
public void withSubProjectFound() throws Exception {
    Project.NameKey p1 = createProject("a/b");
    Project.NameKey p2 = createProject("b");
    Config cfg = new Config();
    cfg.fromText("\n" + "[submodule \"a/b\"]\n" + "path = a/b\n" + "url = ssh://localhost/" + p1.get() + "\n" + "branch = .\n" + "[submodule \"b\"]\n" + "path = b\n" + "url = http://localhost/" + p2.get() + "\n" + "branch = .\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p2, "master"), "b"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p1, "master"), "a/b"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with SubmoduleSectionParser

use of com.google.gerrit.server.util.SubmoduleSectionParser in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withSectionToOtherServer.

@Test
public void withSectionToOtherServer() throws Exception {
    Project.NameKey p1 = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]" + "path = a" + "url = ssh://non-localhost/" + p1.get() + "\n" + "branch = .");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    assertThat(res).isEmpty();
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with SubmoduleSectionParser

use of com.google.gerrit.server.util.SubmoduleSectionParser in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method followMasterBranch.

@Test
public void followMasterBranch() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = localpath-to-a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = master\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "localpath-to-a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with SubmoduleSectionParser

use of com.google.gerrit.server.util.SubmoduleSectionParser in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withAnotherURI.

@Test
public void withAnotherURI() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with SubmoduleSectionParser

use of com.google.gerrit.server.util.SubmoduleSectionParser in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method followMatchingBranch.

@Test
public void followMatchingBranch() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = .\n");
    Branch.NameKey targetBranch1 = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res1 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch1).parseAllSections();
    Set<SubmoduleSubscription> expected1 = Sets.newHashSet(new SubmoduleSubscription(targetBranch1, new Branch.NameKey(p, "master"), "a"));
    assertThat(res1).containsExactlyElementsIn(expected1);
    Branch.NameKey targetBranch2 = new Branch.NameKey(new Project.NameKey("project"), "somebranch");
    Set<SubmoduleSubscription> res2 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch2).parseAllSections();
    Set<SubmoduleSubscription> expected2 = Sets.newHashSet(new SubmoduleSubscription(targetBranch2, new Branch.NameKey(p, "somebranch"), "a"));
    assertThat(res2).containsExactlyElementsIn(expected2);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)14 Branch (com.google.gerrit.reviewdb.client.Branch)14 Project (com.google.gerrit.reviewdb.client.Project)14 SubmoduleSubscription (com.google.gerrit.reviewdb.client.SubmoduleSubscription)14 SubmoduleSectionParser (com.google.gerrit.server.util.SubmoduleSectionParser)14 Config (org.eclipse.jgit.lib.Config)14 Test (org.junit.Test)14