Search in sources :

Example 1 with BuildTypeRequest

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
}
Also used : SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) BuildTypeRequest(jetbrains.buildServer.server.rest.request.BuildTypeRequest) Branches(jetbrains.buildServer.server.rest.model.build.Branches) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildFinderTestBase(jetbrains.buildServer.server.rest.data.BuildFinderTestBase) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 2 with BuildTypeRequest

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());
}
Also used : SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) BuildTypeRequest(jetbrains.buildServer.server.rest.request.BuildTypeRequest) Branches(jetbrains.buildServer.server.rest.model.build.Branches) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildFinderTestBase(jetbrains.buildServer.server.rest.data.BuildFinderTestBase) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Aggregations

BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)2 BuildFinderTestBase (jetbrains.buildServer.server.rest.data.BuildFinderTestBase)2 Branches (jetbrains.buildServer.server.rest.model.build.Branches)2 BuildTypeRequest (jetbrains.buildServer.server.rest.request.BuildTypeRequest)2 ProjectRequestTest (jetbrains.buildServer.server.rest.request.ProjectRequestTest)2 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)2 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)2 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)2 Test (org.testng.annotations.Test)2