Search in sources :

Example 1 with RunningBuildEx

use of jetbrains.buildServer.serverSide.RunningBuildEx 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 2 with RunningBuildEx

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

the class ChangeStatusTest method testSuccessfulRunning.

public void testSuccessfulRunning() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    RunningBuildEx runningBuildEx = build().in(buildConf).onModifications(m20).run();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    myFixture.finishBuild(runningBuildEx, false);
    assertEquals(0, (int) status.getFinished());
    assertEquals(1, (int) status.getRunning());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(1, (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)

Example 3 with RunningBuildEx

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

the class ChangeStatusTest method testFailedFinished.

public void testFailedFinished() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    RunningBuildEx runningBuildEx = build().in(buildConf).onModifications(m20).run();
    myFixture.finishBuild(runningBuildEx, true);
    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(0, (int) status.getRunning());
}
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)

Example 4 with RunningBuildEx

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

the class ChangeStatusTest method testCancelled.

@Test(enabled = false, description = "Cancelled builds are not counted at all, as MergedChangeStatus does not contain them for some reason.")
public void testCancelled() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    SUser user = createUser("testuser");
    RunningBuildEx runningBuildEx = build().in(buildConf).onModifications(m20).withFailedTests("failedTestName").run();
    runningBuildEx.stop(user, "Stopped manually");
    finishBuild(runningBuildEx, false);
    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.getCancelled());
    assertEquals(1, (int) status.getPendingBuildTypes());
}
Also used : SVcsModification(jetbrains.buildServer.vcs.SVcsModification) RunningBuildEx(jetbrains.buildServer.serverSide.RunningBuildEx) ChangeStatus(jetbrains.buildServer.server.rest.model.change.ChangeStatus) SUser(jetbrains.buildServer.users.SUser) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 5 with RunningBuildEx

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

the class ChangeStatusTest method testFailedRunning.

public void testFailedRunning() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    RunningBuildEx runningBuildEx = build().in(buildConf).onModifications(m20).run();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m20), Fields.ALL_NESTED, getBeanContext(myFixture));
    myFixture.finishBuild(runningBuildEx, true);
    assertEquals(0, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(0, (int) status.getFailed());
    assertEquals(1, (int) status.getRunning());
}
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)

Aggregations

RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)7 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)5 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)5 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)5 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)5 MockTimeService (jetbrains.buildServer.MockTimeService)2 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Test (org.testng.annotations.Test)2 SUser (jetbrains.buildServer.users.SUser)1