Search in sources :

Example 31 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testRevision.

@Test
public void testRevision() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
    SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
    VcsRootInstance root2 = buildConf.getVcsRootInstanceForParent(parentRoot2);
    assert root1 != null;
    assert root2 != null;
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    changesPolicy.setCurrentState(root1, createVersionState("master", map("master", "rev_Vcs1_1")));
    changesPolicy.setCurrentState(root2, createVersionState("master", map("master", "xxx")));
    final BuildPromotion build10 = build().in(buildConf).finish().getBuildPromotion();
    changesPolicy.setCurrentState(root1, createVersionState("master", map("master", "rev_Vcs1_2")));
    final BuildPromotion build20 = build().in(buildConf).finish().getBuildPromotion();
    changesPolicy.setCurrentState(root1, createVersionState("master", map("master", "xxx")));
    changesPolicy.setCurrentState(root2, createVersionState("master", map("master", "rev_Vcs2_3")));
    final BuildPromotion build30 = build().in(buildConf).finish().getBuildPromotion();
    final MockVcsModification modification = new MockVcsModification(null, "comment", new Date(), "change_v1") {

        @Override
        public String getDisplayVersion() {
            return "change_V1_display";
        }
    }.setRoot(root1);
    vcs.addChange(root1, modification);
    changesPolicy.setCurrentState(root1, createVersionState("master", map("master", "change_v1")));
    final BuildPromotion build40 = build().in(buildConf).onModifications(modification).finish().getBuildPromotion();
    checkBuilds("revision:rev_Vcs1_2", build20);
    checkBuilds("revision:rev_Vcs1_");
    checkBuilds("revision:(version:rev_Vcs1_2)", build20);
    checkBuilds("revision:(version:rev_Vcs1_)");
    checkBuilds("revision:(version:(value:rev_Vcs1_2))", build20);
    checkBuilds("revision:(version:(value:rev_Vcs1_,matchType:equals))");
    checkBuilds("revision:(version:(value:rev_Vcs1_2,matchType:contains))", build20);
    checkBuilds("revision:(version:(value:rev_Vcs1_,matchType:contains))", build20, build10);
    checkBuilds("revision:(version:(value:abra,matchType:contains))");
    checkBuilds("revision:(internalVersion:change_v1)", build40);
    checkBuilds("revision:(version:change_V1_display)", build40);
    checkBuilds("revision:(version:change_V1_display,vcsRoot:(id:" + root1.getParent().getExternalId() + "))", build40);
    checkBuilds("revision:(internalVersion:xxx)", build30, build20, build10);
    checkBuilds("revision:(internalVersion:xxx,vcsRoot:(id:" + root1.getParent().getExternalId() + "))", build30);
}
Also used : SVcsRootEx(jetbrains.buildServer.vcs.SVcsRootEx) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

Aggregations

VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)31 Test (org.testng.annotations.Test)15 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)14 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)12 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)6 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 BuildFinderTestBase (jetbrains.buildServer.server.rest.data.BuildFinderTestBase)4 Nullable (org.jetbrains.annotations.Nullable)4 SUser (jetbrains.buildServer.users.SUser)3 NotNull (org.jetbrains.annotations.NotNull)3 Logger (com.intellij.openapi.diagnostic.Logger)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ActionErrors (jetbrains.buildServer.controllers.ActionErrors)2 Branches (jetbrains.buildServer.server.rest.model.build.Branches)2 jetbrains.buildServer.serverSide (jetbrains.buildServer.serverSide)2