use of jetbrains.buildServer.server.rest.request.BuildTypeRequest in project teamcity-rest by JetBrains.
the class BuildTypeTest method testBranches.
@Test
public void testBranches() 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);
Branches branches = buildTypeRequest.serveBranches("id:testBT", null, null);
ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, null);
branches = buildTypeRequest.serveBranches("id:testBT", null, Fields.ALL_NESTED.getFieldsSpec());
ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, false);
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", "branch1", "2", "branch2", "3")));
setBranchSpec(vcsRootInstance, "+:*");
branches = buildTypeRequest.serveBranches("id:testBT", null, null);
// why default before checking for changes???
ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, null);
myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
branches = buildTypeRequest.serveBranches("id:testBT", null, null);
ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null);
branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", null);
ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null, "branch1", null, null, "branch2", null, null);
assertNull(branches.branches.get(0).getInternalName());
branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", Fields.ALL_NESTED.getFieldsSpec());
assertEquals("<default>", branches.branches.get(0).getInternalName());
assertEquals("branch1", branches.branches.get(1).getInternalName());
assertEquals("branch2", branches.branches.get(2).getInternalName());
branches = buildTypeRequest.serveBranches("id:testBT", "policy:all_branches", null);
ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null, "branch1", null, null, "branch2", null, null);
branches = buildTypeRequest.serveBranches("id:testBT", "default:true", null);
ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null);
bt.addVcsRoot(bt.getProject().createVcsRoot("vcs", "extId2", "name2"));
final VcsRootInstance vcsRootInstance2 = bt.getVcsRootInstances().get(1);
collectChangesPolicy.setCurrentState(vcsRootInstance2, createVersionState("master2", map("master2", "1", "branch1", "2", "branch2", "3")));
setBranchSpec(vcsRootInstance2, "+:*");
myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", Fields.ALL_NESTED.getFieldsSpec());
ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, false, "branch1", false, false, "branch2", false, false);
assertEquals("<default>", branches.branches.get(0).getInternalName());
checkException(LocatorProcessException.class, new Runnable() {
public void run() {
buildTypeRequest.serveBranches("id:testBT", "changesFromDependencies:any", null);
}
}, "searching with wrong changesFromDependencies");
checkException(BadRequestException.class, new Runnable() {
public void run() {
buildTypeRequest.serveBranches("id:testBT", "policy:INVALID_POLICY", null);
}
}, "searching with wrong changesFromDependencies");
// can also add test for branches from builds
// can also add test for "changesFromDependencies:true" locator and several defaults in different branches
}
use of jetbrains.buildServer.server.rest.request.BuildTypeRequest 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());
}
Aggregations