Search in sources :

Example 1 with SVcsModification

use of jetbrains.buildServer.vcs.SVcsModification 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 SVcsModification

use of jetbrains.buildServer.vcs.SVcsModification 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 SVcsModification

use of jetbrains.buildServer.vcs.SVcsModification 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 SVcsModification

use of jetbrains.buildServer.vcs.SVcsModification 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 SVcsModification

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

the class ChangeStatusTest method testSomeNewFailedTests.

public void testSomeNewFailedTests() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    VcsRootInstance root1 = prepareSingleVscRoot(buildConf);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
    build().in(buildConf).onModifications(m20).withFailedTests("failedTestName").finish();
    // same test failed
    build().in(buildConf).onModifications(m30).withFailedTests("failedTestName", "newFailedTestName").finish();
    ChangeStatus status = new ChangeStatus(myFixture.getChangeStatusProvider().getMergedChangeStatus(m30), Fields.ALL_NESTED, getBeanContext(myFixture));
    assertEquals(1, (int) status.getFinished());
    assertEquals(0, (int) status.getSuccessful());
    assertEquals(1, (int) status.getFailed());
    assertEquals(1, (int) status.getNewFailedTests());
    assertEquals(1, (int) status.getOtherFailedTests());
    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)

Aggregations

SVcsModification (jetbrains.buildServer.vcs.SVcsModification)24 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)14 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)12 ApiOperation (io.swagger.annotations.ApiOperation)7 Fields (jetbrains.buildServer.server.rest.model.Fields)7 ChangeStatus (jetbrains.buildServer.vcs.ChangeStatus)7 ChangeStatusProvider (jetbrains.buildServer.vcs.ChangeStatusProvider)7 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 Test (org.testng.annotations.Test)5 BuildPromotion (jetbrains.buildServer.serverSide.BuildPromotion)4 ServiceLocator (jetbrains.buildServer.ServiceLocator)3 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)3 Locator (jetbrains.buildServer.server.rest.data.Locator)3 Objects (java.util.Objects)2 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)2 BuildTypes (jetbrains.buildServer.server.rest.model.buildType.BuildTypes)2 SVcsRootImpl (jetbrains.buildServer.vcs.impl.SVcsRootImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1