use of jetbrains.buildServer.vcs.SVcsRootEx in project teamcity-rest by JetBrains.
the class BuildFinderTest method testBranchDimension2.
@Test
public void testBranchDimension2() throws Exception {
final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
// not branched build
final SFinishedBuild build5 = build().in(buildConf).finish();
// settings to make display name for branch != branch name
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);
VcsRootInstanceEx root1 = (VcsRootInstanceEx) buildConf.getVcsRootInstanceForParent(parentRoot1);
VcsRootInstanceEx root2 = (VcsRootInstanceEx) buildConf.getVcsRootInstanceForParent(parentRoot2);
assert root1 != null;
assert root2 != null;
setBranchSpec(root1, "+:b1");
setBranchSpec(root2, "+:b2");
final MockCollectRepositoryChangesPolicy changesPolicy = new MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
changesPolicy.setCurrentState(root1, createVersionState("master", map("master", "rev1", "b1", "revB1")));
changesPolicy.setCurrentState(root2, createVersionState("master", map("master", "rev1", "b2", "revB2")));
final SFinishedBuild build10 = build().in(buildConf).finish();
final SFinishedBuild build20 = build().in(buildConf).withBranch(Branch.DEFAULT_BRANCH_NAME).finish();
final SFinishedBuild build30 = build().in(buildConf).withBranch("master").finish();
final SFinishedBuild build40 = build().in(buildConf).withBranch("b1").finish();
final Branch branch = build20.getBranch();
assert branch != null;
assertEquals("<default>", branch.getName());
assertEquals("master", branch.getDisplayName());
// by default no branched builds should be listed
checkBuilds(null, build20, build10, build5);
final String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
checkBuilds(btLocator, build20, build10, build5);
checkBuilds("pinned:any", build20, build10, build5);
checkBuilds("branch:<default>", build20, build10);
checkBuilds("branch:(default:true)", build20, build10, build5);
checkBuilds("branch:(default:any)", build40, build30, build20, build10, build5);
checkBuilds("branch:<any>", build40, build30, build20, build10, build5);
checkBuilds("branch:(default:false)", build40, build30);
checkBuilds("branch:(b1)", build40);
checkBuilds("branch:(name:b1)", build40);
checkBuilds("branch:(name:branchName)");
checkBuilds("branch:(name:master)", build30, build20, build10);
checkBuilds("branch:(name:master,default:true)", build20, build10);
checkBuilds("branch:(branched:true)", build40, build30, build20, build10);
checkBuilds("branch:(branched:false)", build5);
checkBuilds("branch:(name:master,branched:true)", build30, build20, build10);
checkBuilds(btLocator + ",branch:<default>", build20, build10);
checkBuilds(btLocator + ",branch:(default:true)", build20, build10, build5);
checkBuilds(btLocator + ",branch:(default:any)", build40, build30, build20, build10, build5);
checkBuilds(btLocator + ",branch:<any>", build40, build30, build20, build10, build5);
checkBuilds(btLocator + ",branch:(default:false)", build40, build30);
checkBuilds(btLocator + ",branch:(b1)", build40);
checkBuilds(btLocator + ",branch:(name:b1)", build40);
checkBuilds(btLocator + ",branch:(name:branchName)");
checkBuilds(btLocator + ",branch:(name:master)", build30, build20, build10);
checkBuilds(btLocator + ",branch:(name:master,default:true)", build20, build10);
checkBuilds(btLocator + ",branch:(branched:true)", build40, build30, build20, build10);
checkBuilds(btLocator + ",branch:(branched:false)", build5);
checkBuilds(btLocator + ",branch:(name:master,branched:true)", build30, build20, build10);
// invalid branch locator
checkExceptionOnBuildSearch(LocatorProcessException.class, "branch:(::)");
// unused/unknown dimension
checkExceptionOnBuildSearch(LocatorProcessException.class, "branch:(name:branchName,aaa:bbb)");
checkExceptionOnBuildSearch(LocatorProcessException.class, "branch:(aaa:bbb)");
}
use of jetbrains.buildServer.vcs.SVcsRootEx in project teamcity-rest by JetBrains.
the class ChangeStatusTest method prepareSingleVscRoot.
private VcsRootInstance prepareSingleVscRoot(@NotNull BuildTypeImpl buildConf) {
SVcsRootEx parentRoot1 = myFixture.addVcsRoot(myVcs.getName(), "", buildConf);
VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
assert root1 != null;
setBranchSpec(root1, "+:*");
final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
myVcs.setCollectChangesPolicy(changesPolicy);
return root1;
}
use of jetbrains.buildServer.vcs.SVcsRootEx in project teamcity-rest by JetBrains.
the class BuildFinderByPromotionTest method testBranchDimension2.
@Test
public void testBranchDimension2() throws Exception {
final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
// not branched build
final SFinishedBuild build5 = build().in(buildConf).finish();
// settings to make display name for branch != branch name
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;
setBranchSpec(root1, "+:b1");
setBranchSpec(root2, "+:b2");
final MockCollectRepositoryChangesPolicy changesPolicy = new MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
changesPolicy.setCurrentState(root1, createVersionState("master", map("master", "rev1", "b1", "revB1")));
changesPolicy.setCurrentState(root2, createVersionState("master", map("master", "rev1", "b2", "revB2")));
final SFinishedBuild build10 = build().in(buildConf).finish();
final SFinishedBuild build20 = build().in(buildConf).withBranch(Branch.DEFAULT_BRANCH_NAME).finish();
final SFinishedBuild build30 = build().in(buildConf).withBranch("master").finish();
final SFinishedBuild build40 = build().in(buildConf).withBranch("b1").finish();
final Branch branch = build20.getBranch();
assert branch != null;
assertEquals("<default>", branch.getName());
assertEquals("master", branch.getDisplayName());
// by default no branched builds should be listed
checkBuilds(null, build20, build10, build5);
final String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
checkBuilds(btLocator, build20, build10, build5);
checkBuilds("pinned:any", build20, build10, build5);
checkBuilds("branch:<default>", build20, build10);
checkBuilds("branch:(default:true)", build20, build10, build5);
checkBuilds("branch:(default:any)", build40, build30, build20, build10, build5);
checkBuilds("branch:<any>", build40, build30, build20, build10, build5);
checkBuilds("branch:(default:false)", build40, build30);
checkBuilds("branch:(b1)", build40);
checkBuilds("branch:(name:b1)", build40);
checkBuilds("branch:(name:branchName)");
checkBuilds("branch:(name:master)", build30, build20, build10);
checkBuilds("branch:(name:master,default:true)", build20, build10);
checkBuilds("branch:(branched:true)", build40, build30, build20, build10);
checkBuilds("branch:(branched:false)", build5);
checkBuilds("branch:(name:master,branched:true)", build30, build20, build10);
checkBuilds(btLocator + ",branch:<default>", build20, build10);
checkBuilds(btLocator + ",branch:(default:true)", build20, build10, build5);
checkBuilds(btLocator + ",branch:(default:any)", build40, build30, build20, build10, build5);
checkBuilds(btLocator + ",branch:<any>", build40, build30, build20, build10, build5);
checkBuilds(btLocator + ",branch:(default:false)", build40, build30);
checkBuilds(btLocator + ",branch:(b1)", build40);
checkBuilds(btLocator + ",branch:(name:b1)", build40);
checkBuilds(btLocator + ",branch:(name:branchName)");
checkBuilds(btLocator + ",branch:(name:master)", build30, build20, build10);
checkBuilds(btLocator + ",branch:(name:master,default:true)", build20, build10);
checkBuilds(btLocator + ",branch:(branched:true)", build40, build30, build20, build10);
checkBuilds(btLocator + ",branch:(branched:false)", build5);
checkBuilds(btLocator + ",branch:(name:master,branched:true)", build30, build20, build10);
// invalid branch locator
checkExceptionOnBuildSearch(LocatorProcessException.class, "branch:(::)");
// unused/unknown dimension
checkExceptionOnBuildSearch(BadRequestException.class, "branch:(name:branchName,aaa:bbb)");
checkExceptionOnBuildSearch(BadRequestException.class, "branch:(aaa:bbb)");
}
use of jetbrains.buildServer.vcs.SVcsRootEx 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);
}
Aggregations