use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.
the class BuildTypeTest method testBranchesCaseDiff.
// TW-49294
@Test
public void testBranchesCaseDiff() throws ExecutionException, InterruptedException {
final BuildTypeEx bt = getRootProject().createProject("Project1", "Project test 1").createBuildType("testBT", "My test build type");
final BuildTypeRequest buildTypeRequest = new BuildTypeRequest();
buildTypeRequest.setInTests(myBuildTypeFinder, myBranchFinder, myBeanContext);
MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(collectChangesPolicy);
final SVcsRoot vcsRoot = bt.getProject().createVcsRoot("vcs", "extId", "name");
bt.addVcsRoot(vcsRoot);
final VcsRootInstance vcsRootInstance = bt.getVcsRootInstances().get(0);
collectChangesPolicy.setCurrentState(vcsRootInstance, createVersionState("master", map("master", "1", "aaa", "2", "bbb", "2", "Aaa", "3")));
setBranchSpec(vcsRootInstance, "+:*");
myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
Branches branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", Fields.ALL_NESTED.getFieldsSpec());
assertEquals("<default>", branches.branches.get(0).getInternalName());
assertEquals("Aaa", branches.branches.get(1).getInternalName());
assertEquals("aaa", branches.branches.get(2).getInternalName());
assertEquals("bbb", branches.branches.get(3).getInternalName());
}
use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.
the class ProjectRequestTest method testBranches.
@Test
public void testBranches() {
String prjId = "Project1";
ProjectEx project1 = getRootProject().createProject(prjId, "Project test 1");
String bt1Id = "testBT1";
String bt2Id = "testBT2";
final BuildTypeEx bt1 = project1.createBuildType(bt1Id, "My test build type 1");
final BuildTypeEx bt2 = project1.createBuildType(bt2Id, "My test build type 2");
final ProjectRequest request = new ProjectRequest();
request.setInTests(myProjectFinder, myBranchFinder, myBeanContext);
Branches branches = request.getBranches("id:" + prjId, null, null);
assertBranchesEquals(branches.branches, "<default>", true, null);
branches = request.getBranches("id:" + prjId, null, Fields.ALL_NESTED.getFieldsSpec());
assertBranchesEquals(branches.branches, "<default>", true, false);
MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(collectChangesPolicy);
setCurrentBranches(bt1, collectChangesPolicy, "master", map("master", "1", "branch20", "2", "branch30", "3"));
setCurrentBranches(bt2, collectChangesPolicy, "master", map("master", "1", "branch10", "2", "branch20", "3"));
branches = request.getBranches("id:" + prjId, null, null);
// active branches by default
assertBranchesEquals(branches.branches, "master", true, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "master", true, null, "branch10", null, null, "branch20", null, null, "branch30", null, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,default:true", null);
assertBranchesEquals(branches.branches, "master", true, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,default:false", null);
assertBranchesEquals(branches.branches, "branch10", null, null, "branch20", null, null, "branch30", null, null);
setCurrentBranches(bt2, collectChangesPolicy, "master2", map("branch10", "2", "master2", "4", "branch20", "3"));
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "branch10", null, null, "branch20", null, null, "branch30", null, null);
// no default branch option test
bt1.setOption(Option.fromKey("branchFilter"), "+:*\n-:<default>");
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "master2", true, null, "branch10", null, null, "branch20", null, null, "branch30", null, null);
bt2.setOption(Option.fromKey("branchFilter"), "+:*\n-:<default>");
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "branch10", null, null, "branch20", null, null, "branch30", null, null);
// revert
bt1.setOption(Option.fromKey("branchFilter"), "+:*");
bt2.setOption(Option.fromKey("branchFilter"), "+:*");
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,default:true", null);
assertBranchesEquals(branches.branches, "<default>", true, null);
setCurrentBranches(bt2, collectChangesPolicy, "master2", map("master", "1", "branch10", "2", "master2", "4", "branch20", "3"));
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "branch10", null, null, "branch20", null, null, "branch30", null, null, "master", null, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,default:true", null);
assertBranchesEquals(branches.branches, "<default>", true, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,default:false", null);
assertBranchesEquals(branches.branches, "branch10", null, null, "branch20", null, null, "branch30", null, null, "master", null, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,buildType:(id:" + bt1.getExternalId() + ")", null);
assertBranchesEquals(branches.branches, "master", true, null, "branch20", null, null, "branch30", null, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,buildType:(id:" + bt2.getExternalId() + ")", null);
assertBranchesEquals(branches.branches, "master2", true, null, "branch10", null, null, "branch20", null, null, "master", null, null);
// subproject
ProjectEx project1_1 = project1.createProject("Project1_1", "Project test 1.1");
final BuildTypeEx bt11 = project1_1.createBuildType("testBT1_1", "My test build type 1");
final BuildTypeEx bt12 = project1_1.createBuildType("testBT1_2", "My test build type 2");
final BuildTypeEx bt13 = project1_1.createBuildType("testBT1_3", "My test build type 3");
setCurrentBranches(bt11, collectChangesPolicy, "master", map("master", "1", "branch30", "3", "branch120", "2"));
setCurrentBranches(bt12, collectChangesPolicy, "master", map("master", "1", "branch10", "2", "master2", "4", "branch120", "3"));
setCurrentBranches(bt13, collectChangesPolicy, "master", map("master", "1", "branch10", "2", "master2", "4", "branch120", "3"));
bt13.addVcsRoot(bt13.getProject().createVcsRoot("vcs", "extId13_2", "name13_2"));
final VcsRootInstance vcsRootInstance2 = bt13.getVcsRootInstances().get(1);
collectChangesPolicy.setCurrentState(vcsRootInstance2, createVersionState("master3", map("branch10", "2", "master3", "2", "branch2", "3")));
setBranchSpec(vcsRootInstance2, "+:*");
myFixture.getVcsModificationChecker().checkForModifications(bt13.getVcsRootInstances(), OperationRequestor.UNKNOWN);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "branch10", null, null, "branch20", null, null, "branch30", null, null, "master", null, null);
branches = request.getBranches("id:" + project1_1.getExternalId(), "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "branch10", null, null, "branch120", null, null, "branch2", null, null, "branch30", null, null, "master2", null, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,buildType:(affectedProject:(id:" + prjId + "))", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "branch10", null, null, "branch120", null, null, "branch2", null, null, "branch20", null, null, "branch30", null, null, "master", null, null, "master2", null, null);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,buildType:(affectedProject:(id:" + prjId + "))", Fields.ALL_NESTED.getFieldsSpec());
assertBranchesEquals(branches.branches, "<default>", true, false, "branch10", false, false, "branch120", false, false, "branch2", false, false, "branch20", false, false, "branch30", false, false, "master", false, false, "master2", false, false);
branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES,buildType:(id:" + bt13.getExternalId() + ")", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "branch10", null, null, "branch120", null, null, "branch2", null, null, "master2", null, null);
// not quite valid, but works for now
branches = request.getBranches("id:" + project1_1.getExternalId(), "policy:ALL_BRANCHES,buildType:(id:" + bt1Id + ")", null);
assertBranchesEquals(branches.branches, "master", true, null, "branch20", null, null, "branch30", null, null);
}
use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.
the class ProjectRequestTest method testBranchesDiffInCaseOnly.
@Test
public void testBranchesDiffInCaseOnly() {
String prjId = "Project1";
ProjectEx project1 = getRootProject().createProject(prjId, "Project test 1");
String bt1Id = "testBT1";
String bt2Id = "testBT2";
final BuildTypeEx bt1 = project1.createBuildType(bt1Id, "My test build type 1");
final BuildTypeEx bt2 = project1.createBuildType(bt2Id, "My test build type 2");
final ProjectRequest request = new ProjectRequest();
request.setInTests(myProjectFinder, myBranchFinder, myBeanContext);
MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(collectChangesPolicy);
setCurrentBranches(bt1, collectChangesPolicy, "master", map("master", "1", "aaa", "2", "bbb", "3", "Aaa", "3"));
setCurrentBranches(bt2, collectChangesPolicy, "Master", map("Master", "1", "bBb", "2", "ccc", "3"));
Branches branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "Aaa", null, null, "aaa", null, null, "bBb", null, null, "bbb", null, null, "ccc", null, null);
}
use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.
the class ChangeFinderTest method testChangedVcsRootAndDAG.
@Test
public void testChangedVcsRootAndDAG() {
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);
VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
assert root1 != null;
setBranchSpec(root1, "+:*");
final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
SVcsModification m40 = myFixture.addModification(modification().in(root1).version("40").parentVersions("10"));
SVcsModification m45 = myFixture.addModification(modification().in(root1).version("45").parentVersions("40"));
SVcsModification m50 = myFixture.addModification(modification().in(root1).version("50").parentVersions("10"));
SVcsModification m60 = myFixture.addModification(modification().in(root1).version("60").parentVersions("20"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "30", "branch1", "45", "branch2", "50", "branch3", "60")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
build().in(buildConf).onModifications(m20).finish();
build().in(buildConf).withBranch("branch1").onModifications(m40).finish();
String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
check(null, m60, m50, m45, m40, m30, m20);
// documenting current behavior should be check(btLocator, m30, m20);
check(btLocator, m60, m50, m45, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m60, m50, m45, m40, m30, m20);
check(btLocator + ",pending:true", m30);
check(btLocator + ",pending:true,branch:branch1", m45);
check(btLocator + ",pending:true,branch:(default:false)", m60, m50, m45);
check(btLocator + ",pending:true,branch:(default:any)", m60, m50, m45, m30);
buildConf.removeVcsRoot(parentRoot1);
SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
VcsRootInstance root2 = buildConf.getVcsRootInstanceForParent(parentRoot2);
assert root2 != null;
setBranchSpec(root2, "+:*");
SVcsModification m200 = myFixture.addModification(modification().in(root2).version("200").parentVersions("199"));
SVcsModification m210 = myFixture.addModification(modification().in(root2).version("210").parentVersions("199"));
changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "210", "branch1", "200")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m210, m200, m60, m50, m45, m40, m30, m20);
check(btLocator, m210, m200, m60, m50, m45, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m210, m200, m60, m50, m45, m40, m30, m20);
check(btLocator + ",pending:true", m210);
check(btLocator + ",pending:true,branch:branch1", m200);
check(btLocator + ",pending:true,branch:(default:true)", m210);
check(btLocator + ",pending:true,branch:(default:false)", m200);
check(btLocator + ",pending:true,branch:(default:any)", m210, m200);
}
use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.
the class ChangeFinderTest method testBranches1.
@Test
public void testBranches1() {
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;
setBranchSpec(root1, "+:*\n" + "+:prefix/*");
final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(changesPolicy);
SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
SVcsModification m40 = myFixture.addModification(modification().in(root1).version("40").parentVersions("10"));
SVcsModification m50 = myFixture.addModification(modification().in(root1).version("50").parentVersions("40"));
SVcsModification m60 = myFixture.addModification(modification().in(root1).version("60").parentVersions("15"));
SVcsModification m70 = myFixture.addModification(modification().in(root1).version("70").parentVersions("10"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "30", "branch1", "40", "branch2", "50", "branch3", "60", "prefix/aaa", "70", "branch10", "100")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m70, m60, m50, m40, m30, m20);
String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
// documenting current behavior, should be check(btLocator, m30, m20);
check(btLocator, m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:<any>", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m70, m60, m50, m40, m30, m20);
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(aaa:bbb)");
// no buildType is not supported
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(default:true)");
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(name:branch1)");
checkExceptionOnItemsSearch(BadRequestException.class, btLocator + ",branch:(name:master,aaa:bbb)");
// no branches match here
check(btLocator + ",branch:(name:master,default:false)");
check(btLocator + ",branch:(name:master)", m30, m20);
check(btLocator + ",branch:(name:<default>)", m30, m20);
checkExceptionOnItemsSearch(BadRequestException.class, "branch:(branch1)");
check(btLocator + ",branch:(master)", m30, m20);
check(btLocator + ",branch:(<default>)", m30, m20);
check(btLocator + ",branch:(name:aaa)", m70);
check(btLocator + ",branch:(aaa)", m70);
check(btLocator + ",branch:(name:<any>)", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(default:any)", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(<any>)", m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(name:bbb)");
check(btLocator + ",branch:(prefix/aaa)");
check(btLocator + ",branch:(name:branch1)", m40);
check(btLocator + ",branch:(default:true)", m30, m20);
check(btLocator + ",branch:(default:false)", m70, m60, m50, m40);
check(btLocator + ",branch:(default:false),unique:true", m70, m60, m50, m40);
// test pending
check(btLocator + ",branch:(name:master),pending:true", m30, m20);
check(btLocator + ",branch:(name:<default>),pending:true", m30, m20);
check(btLocator + ",branch:(name:branch1),pending:true", m40);
check(btLocator + ",branch:(name:master),pending:false");
check(btLocator + ",branch:(name:<default>),pending:false");
check(btLocator + ",branch:(name:branch1),pending:false");
check(btLocator + ",branch:(name:branch1),pending:any", m40);
changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "11")));
build().in(buildConf).withDefaultBranch().finish();
build().in(buildConf).withBranch("branch1").finish();
SVcsModification m80 = myFixture.addModification(modification().in(root1).version("80").parentVersions("30"));
SVcsModification m90 = myFixture.addModification(modification().in(root1).version("90").parentVersions("40"));
changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "80", "branch1", "90", "branch2", "50", "branch3", "60", "prefix/aaa", "70", "branch10", "100")));
myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
check(null, m90, m80, m70, m60, m50, m40, m30, m20);
check(btLocator + ",branch:(name:master)", m80, m30, m20);
check(btLocator + ",branch:(name:<default>)", m80, m30, m20);
check(btLocator + ",branch:(name:branch1)", m90, m40);
check(btLocator + ",branch:(name:master),pending:true", m80);
check(btLocator + ",branch:(name:<default>),pending:true", m80);
check(btLocator + ",branch:(name:branch1),pending:true", m90);
check(btLocator + ",branch:(name:master),pending:false", m30, m20);
check(btLocator + ",branch:(name:<default>),pending:false", m30, m20);
check(btLocator + ",branch:(name:branch1),pending:false", m40);
check(btLocator + ",branch:(name:branch1),pending:any", m90, m40);
}
Aggregations