use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class VcsRootInstanceFinderTest method testSingleDimensions.
@SuppressWarnings("ConstantConditions")
@Test
public void testSingleDimensions() throws Exception {
myFixture.registerVcsSupport("svn");
myFixture.registerVcsSupport("cvs");
myFixture.registerVcsSupport("custom");
final ProjectEx project10 = getRootProject().createProject("project10", "Project name 10");
final ProjectEx project20 = project10.createProject("project20", "Project name 20");
final ProjectEx project25 = project20.createProject("project25", "Project name 25");
final ProjectEx project30 = project10.createProject("project30", "Project name 30");
project30.setArchived(true, null);
final SVcsRoot vcsRoot10 = getRootProject().createVcsRoot("svn", "id10", "VCS root 10 name");
final SVcsRoot vcsRoot12 = getRootProject().createVcsRoot("svn", "id12", "VCS root 12 name");
vcsRoot12.setProperties(CollectionsUtil.asMap("url", "", "aaa", "%ref%"));
final SVcsRoot vcsRoot15 = getRootProject().createVcsRoot("custom", "id15", "VCS root 15 name");
vcsRoot15.setProperties(CollectionsUtil.asMap("url", "", "aaa", "3"));
final SVcsRoot vcsRoot20 = project10.createVcsRoot("cvs", "id20", "VCS root 20 name");
vcsRoot20.setProperties(CollectionsUtil.asMap("url", "http://xxx", "aaa", "5", "ccc", "ddd"));
final SVcsRoot vcsRoot30 = project20.createVcsRoot("svn", "id30", "VCS root 30 name");
final SVcsRoot vcsRoot40 = project30.createVcsRoot("svn", "id40", "VCS root 40 name");
vcsRoot40.setProperties(CollectionsUtil.asMap("url", "http://xxx", "aaa", "3", "ccc", "ddd"));
final SVcsRoot vcsRoot50 = project25.createVcsRoot("cvs", "id50", "VCS root 50 name");
final SBuildType bt10 = project20.createBuildType("id10", "name 10");
final BuildTypeTemplate templ10 = project20.createBuildTypeTemplate("t_id10", "template name 10");
templ10.addVcsRoot(vcsRoot10);
templ10.addVcsRoot(vcsRoot12);
templ10.setCheckoutRules(vcsRoot10, new CheckoutRules("+:aaa=>bbb"));
final SBuildType bt20 = project20.createBuildType("id20", "name 20");
bt20.addParameter(new SimpleParameter("ref", "RESOLVED"));
bt20.attachToTemplate(templ10);
VcsRootInstance vInstance10 = bt20.getVcsRootInstanceForParent(vcsRoot10);
VcsRootInstance vInstance20 = bt20.getVcsRootInstanceForParent(vcsRoot12);
VcsRootInstance vInstance30 = attachVcsRoot(bt20, vcsRoot20);
final BuildTypeEx bt25 = project20.createBuildType("id25", "name 25");
bt25.attachToTemplate(templ10);
VcsRootInstance vInstance40 = bt25.getVcsRootInstanceForParent(vcsRoot10);
assertEquals(vInstance10, vInstance40);
VcsRootInstance vInstance50 = bt25.getVcsRootInstanceForParent(vcsRoot12);
final SBuildType bt30 = project20.createBuildType("id30", "name 30");
VcsRootInstance vInstance60 = attachVcsRoot(bt30, vcsRoot10);
assertEquals(vInstance10, vInstance60);
final SBuildType bt40 = project20.createBuildType("id40", "name 40");
VcsRootInstance vInstance70 = attachVcsRoot(bt40, vcsRoot30);
final BuildTypeEx bt50 = project30.createBuildType("id50", "name 50");
VcsRootInstance vInstance80 = attachVcsRoot(bt50, vcsRoot40);
final BuildTypeEx bt60 = project25.createBuildType("id60", "name 60");
VcsRootInstance vInstance90 = attachVcsRoot(bt60, vcsRoot50);
check(null, vInstance10, vInstance20, vInstance30, vInstance50, vInstance70, vInstance80, vInstance90);
check(String.valueOf(vInstance10.getId()), vInstance10);
check("id:" + vInstance10.getId(), vInstance10);
check("id:" + vInstance50.getId(), vInstance50);
check("id:" + vInstance80.getId(), vInstance80);
check("vcsRoot:(id:" + vcsRoot10.getExternalId() + ")", vInstance10);
check("vcsRoot:(id:" + vcsRoot12.getExternalId() + ")", vInstance20, vInstance50);
check("vcsRoot:(type:cvs)", vInstance30, vInstance90);
check("type:svn", vInstance10, vInstance20, vInstance50, vInstance70, vInstance80);
check("type:custom");
// todo
check("project:(id:" + project20.getExternalId() + ")", vInstance70);
// todo
check("project:(id:" + project10.getExternalId() + ")", vInstance30);
check("affectedProject:(id:" + project20.getExternalId() + ")", vInstance10, vInstance20, vInstance30, vInstance50, vInstance70, vInstance90);
check("buildType:(id:" + bt20.getExternalId() + ")", vInstance10, vInstance20, vInstance30);
check("buildType:(id:" + templ10.getExternalId() + ",template:true)", vInstance10, vInstance50);
check("property:(name:aaa,value:RESOLVED)", vInstance20);
check("property:(name:aaa,value:2,matchType:more-than)", vInstance30, vInstance80);
check("property:(name:aaa,value:4,matchType:more-than)", vInstance30);
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class VcsRootInstanceFinderTest method testPropertyFilteringWithReferences.
@Test
public void testPropertyFilteringWithReferences() throws Exception {
myFixture.registerVcsSupport("custom");
final ProjectEx project10 = getRootProject().createProject("project10", "Project name 10");
final SVcsRoot vcsRoot10 = getRootProject().createVcsRoot("custom", "id10", "VCS root 10 name");
vcsRoot10.setProperties(CollectionsUtil.asMap("url", "https://acme.com/repo"));
final SBuildType bt10 = project10.createBuildType("id10", "name 10");
bt10.addVcsRoot(vcsRoot10);
VcsRootInstance vInstance10 = bt10.getVcsRootInstanceForParent(vcsRoot10);
final SVcsRoot vcsRoot20 = getRootProject().createVcsRoot("custom", "id20", "VCS root 20 name");
vcsRoot20.setProperties(CollectionsUtil.asMap("url", "%ref%"));
final SBuildType bt20 = project10.createBuildType("id20", "name 20");
bt20.addVcsRoot(vcsRoot20);
bt20.addParameter(new SimpleParameter("ref", "https://acme.com/repo"));
VcsRootInstance vInstance20 = bt20.getVcsRootInstanceForParent(vcsRoot20);
final SVcsRoot vcsRoot30 = getRootProject().createVcsRoot("custom", "id30", "VCS root 30 name");
vcsRoot30.setProperties(CollectionsUtil.asMap("url", "https://acme2.com/repo"));
final SBuildType bt30 = project10.createBuildType("id30", "name 30");
bt30.addVcsRoot(vcsRoot30);
VcsRootInstance vInstance30 = bt30.getVcsRootInstanceForParent(vcsRoot30);
final SVcsRoot vcsRoot40 = getRootProject().createVcsRoot("custom", "id40", "VCS root 40 name");
vcsRoot40.setProperties(CollectionsUtil.asMap("url", "%ref%"));
final SBuildType bt40 = project10.createBuildType("id40", "name 40");
bt40.addVcsRoot(vcsRoot40);
bt40.addParameter(new SimpleParameter("ref", "https://acme2.com/repo"));
VcsRootInstance vInstance40 = bt40.getVcsRootInstanceForParent(vcsRoot40);
check(null, vInstance10, vInstance20, vInstance30, vInstance40);
check("vcsRoot:(property:(name:url,value:acme.com,matchType:contains,ignoreCase:true))", vInstance10);
check("property:(name:url,value:acme.com,matchType:contains,ignoreCase:true)", vInstance10, vInstance20);
check("vcsRoot:(type:custom)", vInstance10, vInstance20, vInstance30, vInstance40);
check("vcsRoot:(type:custom),property:(name:url,value:acme.com,matchType:contains,ignoreCase:true)", vInstance10, vInstance20);
check("vcsRoot:(type:custom),property:(name:(value:u,matchType:starts-with),value:acme.com,matchType:contains,ignoreCase:true)", vInstance10, vInstance20);
check("vcsRoot:(type:custom),property:(name:url,value:acme3.com,matchType:contains,ignoreCase:true)");
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class VcsRootInstanceFinderTest method testCount.
@SuppressWarnings("ConstantConditions")
@Test
public void testCount() throws Exception {
myFixture.registerVcsSupport("svn");
final ProjectEx project10 = getRootProject().createProject("project10", "Project name 10");
for (int i = 0; i < 15; i++) {
final SVcsRoot vcsRoot = getRootProject().createVcsRoot("svn", "id" + i, "VCS root " + i + " name");
final SBuildType bt = project10.createBuildType("id" + i, "name " + i);
attachVcsRoot(bt, vcsRoot);
}
assertEquals(3, getFinder().getItems("count:3").myEntries.size());
assertEquals(15, getFinder().getItems(null).myEntries.size());
assertEquals(5, getFinder().getItems("start:10").myEntries.size());
assertEquals(10, getFinder().getItems("lookupLimit:10").myEntries.size());
setInternalProperty("rest.defaultPageSize", "12");
assertEquals(12, getFinder().getItems(null).myEntries.size());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class BuildTypeRequestTest method testPasswordParams.
@Test
public void testPasswordParams() {
// see also alike setup in BuildTypeTest.testInheritance()
ProjectEx project10 = createProject("project10", "project 10");
final ParameterFactory parameterFactory = myFixture.getSingletonService(ParameterFactory.class);
project10.addParameter(parameterFactory.createTypedParameter("a_pwd", "secret", "password"));
project10.addParameter(new SimpleParameter("b_normal", "value"));
BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
// get buildType
BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt10), new Fields("$long"), getBeanContext(myServer));
assertNull(buildType.getParameters().properties.get(0).value);
project10.addParameter(parameterFactory.createTypedParameter("a_pwd", "", "password"));
assertEquals("", buildType.getParameters().properties.get(0).value);
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx 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);
}
Aggregations