use of jetbrains.buildServer.vcs.VcsRootInstanceEx 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)");
}
Aggregations