Search in sources :

Example 6 with BuildTypeEx

use of jetbrains.buildServer.serverSide.BuildTypeEx 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);
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) Branches(jetbrains.buildServer.server.rest.model.build.Branches) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildFinderTestBase(jetbrains.buildServer.server.rest.data.BuildFinderTestBase) Test(org.testng.annotations.Test) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 7 with BuildTypeEx

use of jetbrains.buildServer.serverSide.BuildTypeEx in project teamcity-rest by JetBrains.

the class MuteRequestTest method test_unmuteBuildType.

@Test
public void test_unmuteBuildType() {
    final ProjectEx project = createProject("Project", "Project");
    final BuildTypeEx bt1 = project.createBuildType("bt1");
    final BuildTypeEx bt2 = project.createBuildType("bt2");
    // just a child project
    final ProjectEx projectChild = project.createProject("Project2", "Project2");
    final BuildTypeEx bt21 = projectChild.createBuildType("bt21");
    createBuild(bt1, new String[0], new String[] { "test1", "test2", "test3" });
    createBuild(bt2, new String[0], new String[] { "test1", "test2", "test3", "test4" });
    createBuild(bt21, new String[0], new String[] { "test1", "test2", "test3", "test4" });
    final STest test1 = myFixture.getTestManager().createTest(new TestName("test1"), project.getProjectId());
    final STest test2 = myFixture.getTestManager().createTest(new TestName("test2"), project.getProjectId());
    SUser user = createUser("user");
    {
        Mutes mutes = myRequest.getMutes(null, null, null, null);
        // assertEquals(Integer.valueOf(0), mutes.count); //todo: fix
        assertEmpty(mutes.items);
    }
    myMutingService.muteTestsInBuildTypes(user, null, false, null, Arrays.asList(bt1, bt2), Arrays.asList(test1, test2), false);
    {
        Mutes mutes = myRequest.getMutes(null, null, null, null);
        assertEquals(Integer.valueOf(1), mutes.count);
        assertEquals(1, mutes.items.size());
        assertNull(mutes.items.get(0).scope.project);
        assertNotNull(mutes.items.get(0).scope.buildTypes);
        assertEquals(2, mutes.items.get(0).scope.buildTypes.buildTypes.size());
        assertTrue(mutes.items.get(0).scope.buildTypes.buildTypes.stream().anyMatch(buildType -> bt1.getExternalId().equals(buildType.getId())));
        assertTrue(mutes.items.get(0).scope.buildTypes.buildTypes.stream().anyMatch(buildType -> bt2.getExternalId().equals(buildType.getId())));
        assertNull(mutes.items.get(0).target.problems);
        assertEquals(2, mutes.items.get(0).target.tests.items.size());
        assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test1.getTestNameId()).equals(test.id)));
        assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test2.getTestNameId()).equals(test.id)));
    }
    myMutingService.unmuteTests(user, null, bt1, Arrays.asList(test1, test2));
    {
        Mutes mutes = myRequest.getMutes(null, null, null, null);
        assertEquals(Integer.valueOf(1), mutes.count);
        assertEquals(1, mutes.items.size());
        assertNull(mutes.items.get(0).scope.project);
        assertNotNull(mutes.items.get(0).scope.buildTypes);
        assertEquals(1, mutes.items.get(0).scope.buildTypes.buildTypes.size());
        assertTrue(mutes.items.get(0).scope.buildTypes.buildTypes.stream().anyMatch(buildType -> bt2.getExternalId().equals(buildType.getId())));
        assertNull(mutes.items.get(0).target.problems);
        assertEquals(2, mutes.items.get(0).target.tests.items.size());
        assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test1.getTestNameId()).equals(test.id)));
        assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test2.getTestNameId()).equals(test.id)));
    }
    {
        setInternalProperty(Mutes.REST_MUTES_ACTUAL_STATE, "true");
        Mutes mutes = myRequest.getMutes(null, "$long,mute(target(tests(test(mutes(mute(scope(buildTypes($long))))))))", null, null);
        assertEquals(1, mutes.items.get(0).target.tests.items.get(0).mutes.items.get(0).scope.buildTypes.buildTypes.size());
    }
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) TestName(jetbrains.buildServer.tests.TestName) SUser(jetbrains.buildServer.users.SUser) STest(jetbrains.buildServer.serverSide.STest) Mutes(jetbrains.buildServer.server.rest.model.problem.Mutes) STest(jetbrains.buildServer.serverSide.STest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 8 with BuildTypeEx

use of jetbrains.buildServer.serverSide.BuildTypeEx in project teamcity-rest by JetBrains.

the class BaseTestScopesCollectorTest method buildTree.

protected void buildTree() {
    /* Builds a following tree:

                                 project
                               /        \
                       project1          project2
                      /        \                \
                buildconf1   subproject11    subproject21
                    |               \                    \
                  suite1          buildconf2            buildconf1
                 /      \             \             /        |    \
            packageA    packageB    suite2       suite1  suite2   suite0
             /     \        \          \           |         |         \
         class1   class2    class1   packageA   packageB   packageC    packageZ
         / | \       |         \        \          |         |            \
        b  a  c      a          b     class3    class1       class2      classZ
                                         \         |       / | | | | \      \
                                          c        a      h  g f e d  c      z
     */
    ProjectEx project = myFixture.createProject("project", "project");
    ProjectEx project1 = project.createProject("project1", "project1");
    ProjectEx project2 = project.createProject("project2", "project2");
    ProjectEx subproject11 = project1.createProject("subproject11", "subproject11");
    ProjectEx subproject21 = project2.createProject("subproject21", "subproject21");
    BuildTypeEx buildconf1 = project1.createBuildType("buildconf1");
    BuildTypeEx buildconf2 = subproject11.createBuildType("buildconf2");
    BuildTypeEx buildconf11 = subproject21.createBuildType("buildconf1");
    final SFinishedBuild build1 = build().in(buildconf1).startSuite("suite1").withTest("packageA.class1.b", false).withTest("packageA.class1.a", false).withTest("packageB.class1.b", false).withTest("packageA.class2.a", false).withTest("packageA.class1.c", false).endSuite().finish();
    final SFinishedBuild build2 = build().in(buildconf2).startSuite("suite2").withTest("packageA.class3.c", false).endSuite().finish();
    final SFinishedBuild build3 = build().in(buildconf11).startSuite("suite1").withTest("packageB.class1.a", false).endSuite().startSuite("suite2").withTest("packageC.class2.h", false).withTest("packageC.class2.g", false).withTest("packageC.class2.f", false).withTest("packageC.class2.e", false).withTest("packageC.class2.d", false).withTest("packageC.class2.c", false).endSuite().startSuite("suite0").withTest("packageZ.classZ.z", false).endSuite().finish();
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild)

Example 9 with BuildTypeEx

use of jetbrains.buildServer.serverSide.BuildTypeEx in project teamcity-rest by JetBrains.

the class BranchFinderTest method testBranchExistsLaziness.

@Test
public void testBranchExistsLaziness() {
    final BuildTypeEx bt1 = registerBuildType("10", "Project");
    final BuildTypeEx bt2 = registerBuildType("20", "Project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", bt1);
    SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", bt2);
    VcsRootInstance root1 = bt1.getVcsRootInstanceForParent(parentRoot1);
    VcsRootInstance root2 = bt2.getVcsRootInstanceForParent(parentRoot2);
    assert root1 != null && root2 != null;
    setBranchSpec(root1, "+:*");
    setBranchSpec(root2, "+:*");
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    SVcsModification m = myFixture.addModification(modification().in(root1).version("10").parentVersions("1"));
    SVcsModification n = myFixture.addModification(modification().in(root2).version("10").parentVersions("1"));
    changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("branch1", "10")));
    changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("branch1", "10")));
    myFixture.getVcsModificationChecker().checkForModifications(bt1.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    myFixture.getVcsModificationChecker().checkForModifications(bt2.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    assertTrue("Branch 'branch1' exists.", myBranchFinder.itemsExist(new Locator("buildType:(project:(name:Project)),name:branch1")));
    List<String> usedBuildTypes = ((BranchFinder1) myBranchFinder).getBuildTypeIdsUsedInGetBranches();
    assertTrue("Lazy lookup failed: we needed to get branches of exactly one build type, second one is excessive.", usedBuildTypes.contains(bt1.getBuildTypeId()) && !usedBuildTypes.contains(bt2.getBuildTypeId()) || usedBuildTypes.contains(bt2.getBuildTypeId()) && !usedBuildTypes.contains(bt1.getBuildTypeId()));
    assertFalse("Branch 'branch2' does not exist.", myBranchFinder.itemsExist(new Locator("buildType:(project:(name:Project)),name:branch2")));
    // We must look into both buildtypes as neither of them has a branch that we look for.
    assertContains(((BranchFinder1) myBranchFinder).getBuildTypeIdsUsedInGetBranches(), bt1.getBuildTypeId(), bt2.getBuildTypeId());
}
Also used : BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) ServiceLocator(jetbrains.buildServer.ServiceLocator) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) Test(org.testng.annotations.Test)

Aggregations

BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)9 Test (org.testng.annotations.Test)8 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)6 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)5 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)5 Mutes (jetbrains.buildServer.server.rest.model.problem.Mutes)3 STest (jetbrains.buildServer.serverSide.STest)3 TestName (jetbrains.buildServer.tests.TestName)3 SUser (jetbrains.buildServer.users.SUser)3 ServiceLocator (jetbrains.buildServer.ServiceLocator)2 BuildFinderTestBase (jetbrains.buildServer.server.rest.data.BuildFinderTestBase)2 Branches (jetbrains.buildServer.server.rest.model.build.Branches)2 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)1 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)1