Search in sources :

Example 1 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class ChangeStatusTest method testSuccessfulFinishedPersonal.

@Test(dataProvider = "allBooleans")
public void testSuccessfulFinishedPersonal(boolean viewPersonalBuilds) throws Throwable {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", myTestProject, "Ant");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    build().in(buildConf).onModifications(m20).personalForUser(myAnotherUser.getUsername()).finish();
    if (viewPersonalBuilds) {
        myUser.setUserProperty(StandardProperties.SHOW_ALL_PERSONAL_BUILDS, "true");
    } else {
        myUser.setUserProperty(StandardProperties.SHOW_ALL_PERSONAL_BUILDS, "false");
    }
    ChangeStatus status = myFixture.getSecurityContext().runAs(myUser, () -> new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture)));
    if (viewPersonalBuilds) {
        assertEquals(1, (int) status.getFinished());
        assertEquals(0, (int) status.getRunning());
        assertEquals(1, (int) status.getSuccessful());
    } else {
        assertEquals(0, (int) status.getFinished());
        assertEquals(0, (int) status.getRunning());
        assertEquals(0, (int) status.getSuccessful());
    }
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 2 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class ChangeStatusTest method testNewFailedTests.

public void testNewFailedTests() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    build().in(buildConf).onModifications(m20).withFailedTests("failedTestName", "secondFailedTesName").finish();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    assertEquals(1, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(1, (int) status.getFailed());
    assertEquals(2, (int) status.getNewFailedTests());
    assertEquals(1, (int) status.getNewTestsFailedBuilds().count);
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Example 3 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class ChangeStatusTest method testSuccessfulRunningPersonal.

@Test(dataProvider = "allBooleans")
public void testSuccessfulRunningPersonal(boolean viewPersonalBuilds) throws Throwable {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", myTestProject, "Ant");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    RunningBuildEx runningBuildEx = build().in(buildConf).personalForUser(myAnotherUser.getUsername()).onModifications(m20).run();
    if (viewPersonalBuilds) {
        myUser.setUserProperty(StandardProperties.SHOW_ALL_PERSONAL_BUILDS, "true");
    } else {
        myUser.setUserProperty(StandardProperties.SHOW_ALL_PERSONAL_BUILDS, "false");
    }
    jetbrains.buildServer.vcs.ChangeStatus mergedStatus = myFixture.getChangeStatusProvider().getMergedChangeStatus(m20);
    ChangeStatus status = myFixture.getSecurityContext().runAs(myUser, () -> new ChangeStatus(mergedStatus, Fields.ALL_NESTED, getBeanContext(myFixture)));
    myFixture.finishBuild(runningBuildEx, false);
    if (viewPersonalBuilds) {
        assertEquals(0, (int) status.getFinished());
        assertEquals(1, (int) status.getRunning());
        assertEquals(0, (int) status.getSuccessful());
        assertEquals(1, (int) status.getRunningSuccessfuly());
    } else {
        assertEquals(0, (int) status.getFinished());
        assertEquals(0, (int) status.getRunning());
        assertEquals(0, (int) status.getSuccessful());
        assertEquals(0, (int) status.getRunningSuccessfuly());
    }
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) RunningBuildEx(jetbrains.buildServer.serverSide.RunningBuildEx) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 4 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class ChangeStatusTest method testPendingConfiguration.

public void testPendingConfiguration() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    assertEquals(0, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(0, (int) status.getFailed());
    assertEquals(1, (int) status.getPendingBuildTypes());
    assertEquals(0, (int) status.getQueuedBuildsCount());
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance)

Example 5 with VcsRootInstance

use of jetbrains.buildServer.vcs.VcsRootInstance in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testStrobBranchedDimension.

@Test
public void testStrobBranchedDimension() throws ExecutionException, InterruptedException {
    final SProject project = createProject("prj", "project");
    final BuildTypeEx buildConf1 = (BuildTypeEx) project.createBuildType("buildConf1", "buildConf1");
    final BuildTypeEx buildConf2 = (BuildTypeEx) project.createBuildType("buildConf2", "buildConf2");
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(collectChangesPolicy);
    buildConf1.addVcsRoot(buildConf1.getProject().createVcsRoot("vcs", "extId", "name"));
    final VcsRootInstance vcsRootInstance = buildConf1.getVcsRootInstances().get(0);
    collectChangesPolicy.setCurrentState(vcsRootInstance, createVersionState("master", map("master", "1", "branch1", "2", "branch2", "3")));
    setBranchSpec(vcsRootInstance, "+:*");
    myFixture.getVcsModificationChecker().checkForModifications(buildConf1.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    final BuildPromotion build10 = build().in(buildConf1).finish().getBuildPromotion();
    final BuildPromotion build15 = build().in(buildConf1).withDefaultBranch().finish().getBuildPromotion();
    final BuildPromotion build20 = build().in(buildConf1).withBranch("branch1").finish().getBuildPromotion();
    final BuildPromotion build25 = build().in(buildConf1).withBranch("branch1").finish().getBuildPromotion();
    final BuildPromotion build30 = build().in(buildConf1).withBranch("branch").finish().getBuildPromotion();
    final BuildPromotion build35 = build().in(buildConf1).withBranch("branch").finish().getBuildPromotion();
    final BuildPromotion build40 = build().in(buildConf1).finish().getBuildPromotion();
    final BuildPromotion build50 = build().in(buildConf2).withBranch("branch1").finish().getBuildPromotion();
    final BuildPromotion build60 = build().in(buildConf2).withBranch("branch1").finish().getBuildPromotion();
    checkBuilds("strob:(buildType:(project:(id:" + project.getExternalId() + ")))", build40);
    checkBuilds("strob:(buildType:(project:(id:" + project.getExternalId() + ")),branch:(policy:ALL_BRANCHES))", build40, build35, build25, build60);
    checkBuilds("strob:(buildType:(project:(id:" + project.getExternalId() + ")),branch:(policy:VCS_BRANCHES))", build40, build25);
    checkBuilds("strob:(buildType:(project:(id:" + project.getExternalId() + ")),branch:(default:any))", build40, build35, build25, build60);
    checkBuilds("strob:(branch:(default:any,buildType:(id:" + buildConf1.getExternalId() + ")),locator:(buildType:(id:" + buildConf1.getExternalId() + ")))", build40, build35, build25);
    checkExceptionOnBuildsSearch(BadRequestException.class, "strob:(branch:(default:any),locator:(buildType:(id:" + buildConf1.getExternalId() + ")))");
    checkBuilds("strob:(branch:(default:any,buildType:(id:" + buildConf2.getExternalId() + ")),locator:(buildType:(id:" + buildConf1.getExternalId() + ")))", build40, build25);
}
Also used : VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test)

Aggregations

VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)31 Test (org.testng.annotations.Test)15 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)14 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)12 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)6 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 BuildFinderTestBase (jetbrains.buildServer.server.rest.data.BuildFinderTestBase)4 Nullable (org.jetbrains.annotations.Nullable)4 SUser (jetbrains.buildServer.users.SUser)3 NotNull (org.jetbrains.annotations.NotNull)3 Logger (com.intellij.openapi.diagnostic.Logger)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ActionErrors (jetbrains.buildServer.controllers.ActionErrors)2 Branches (jetbrains.buildServer.server.rest.model.build.Branches)2 jetbrains.buildServer.serverSide (jetbrains.buildServer.serverSide)2