Search in sources :

Example 6 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testNoTestRunsFromOthersPersonalBuild.

@Test
public void testNoTestRunsFromOthersPersonalBuild() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    SUser user = myFixture.createUserAccount("andrey");
    final SFinishedBuild personalBuild = build().in(buildType).personalForUser(user.getUsername()).withTest(BuildBuilder.TestData.test("aaa")).finish();
    final SFinishedBuild regularBuild = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa")).finish();
    TestRunDataWithBuild regularRun = t("aaa", Status.NORMAL, 2, regularBuild.getBuildId());
    check("test:(name:aaa)", TEST_MATCHER, regularRun);
    check("test:(name:aaa),includePersonal:true", TEST_MATCHER, regularRun);
    check("test:(name:aaa),includePersonal:false", TEST_MATCHER, regularRun);
}
Also used : SUser(jetbrains.buildServer.users.SUser) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 7 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testTestFromOtherUsersPersonalBuildByBuildLocator.

@Test
public void testTestFromOtherUsersPersonalBuildByBuildLocator() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    SUser user = myFixture.createUserAccount("andrey");
    final SFinishedBuild personalBuild = build().in(buildType).personalForUser(user.getUsername()).withTest(BuildBuilder.TestData.test("aaa")).finish();
    TestRunDataWithBuild personalRun = t("aaa", Status.NORMAL, 1, personalBuild.getBuildId());
    check(String.format("build:(id:%d)", personalBuild.getBuildId()), TEST_MATCHER, personalRun);
}
Also used : SUser(jetbrains.buildServer.users.SUser) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 8 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testBranchFiltering.

@Test
public void testBranchFiltering() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    BuildBuilder.TestData test10, test20, test30, test40, test50, test60;
    final SFinishedBuild build10 = build().in(buildType).withTest(test10 = BuildBuilder.TestData.test("test").duration(10)).finish();
    final SFinishedBuild build20 = build().in(buildType).withBranch("branch1").withTest(test20 = BuildBuilder.TestData.test("test").duration(20)).finish();
    final SFinishedBuild build30 = build().in(buildType).withDefaultBranch().withTest(test30 = BuildBuilder.TestData.test("test").duration(30)).finish();
    final SFinishedBuild build40 = build().in(buildType).personalForUser("user").withTest(test40 = BuildBuilder.TestData.test("test").duration(40)).finish();
    final SFinishedBuild build50 = build().in(buildType).withTest(test50 = BuildBuilder.TestData.test("test").duration(50)).cancel(null);
    final SFinishedBuild build60 = build().in(buildType).withBranch("branch3:(a)").withTest(test60 = BuildBuilder.TestData.test("test").duration(60)).finish();
    Matcher<BuildBuilder.TestData, STestRun> matcher = (testData, sTestRun) -> testData.duration == sTestRun.getDuration();
    check("buildType:(id:" + buildType.getExternalId() + "),test:(name:test)", matcher, test60, test50, test30, test20, test10);
    // comparing the branch filtering with behavior while filtering builds
    String locatorPartTests__ = "buildType:(id:" + buildType.getExternalId() + "),test:(name:test),";
    String locatorPartBuilds = "buildType:(id:" + buildType.getExternalId() + "),build:(defaultFilter:false,personal:false,buildType:(id:" + buildType.getExternalId() + "),";
    check(locatorPartTests__ + "branch:(default:true)", matcher, test50, test30, test10);
    check(locatorPartBuilds + "branch:(default:true))", matcher, test50, test30, test10);
    // the build is not branched in this test
    check(locatorPartTests__ + "branch:(<default>)", matcher);
    check(locatorPartBuilds + "branch:(<default>))", matcher);
    check(locatorPartTests__ + "branch:(branch1)", matcher, test20);
    check(locatorPartBuilds + "branch:(branch1))", matcher, test20);
    check(locatorPartTests__ + "branch:(Branch1)", matcher, test20);
    check(locatorPartBuilds + "branch:(Branch1))", matcher, test20);
    check(locatorPartTests__ + "branch:(name:(branch1))", matcher, test20);
    check(locatorPartBuilds + "branch:(name:(branch1)))", matcher, test20);
    check(locatorPartTests__ + "branch:(name:Branch1,unknown:false)", matcher);
    checkExceptionOnItemsSearch(jetbrains.buildServer.server.rest.errors.BadRequestException.class, "buildType:(id:" + buildType.getExternalId() + "),build:(buildType:(id:" + buildType.getExternalId() + "),branch:(name:Branch1,unknown:false))");
    check(locatorPartTests__ + "branch:(branch3:(a))", matcher, test60);
    checkExceptionOnItemsSearch(jetbrains.buildServer.server.rest.errors.BadRequestException.class, "buildType:(id:" + buildType.getExternalId() + "),build:(buildType:(id:" + buildType.getExternalId() + "),branch:(branch3:(a)))");
    check(locatorPartTests__ + "branch:missing", matcher);
    check("buildType:(id:" + buildType.getExternalId() + "),build:(buildType:(id:" + buildType.getExternalId() + "),branch:missing)", matcher);
}
Also used : LocatorProcessException(jetbrains.buildServer.server.rest.errors.LocatorProcessException) Fields(jetbrains.buildServer.server.rest.model.Fields) TestNameResponsibilityFacade(jetbrains.buildServer.responsibility.TestNameResponsibilityFacade) Date(java.util.Date) TestFor(jetbrains.buildServer.util.TestFor) BuildBuilder(jetbrains.buildServer.buildTriggers.vcs.BuildBuilder) Status(jetbrains.buildServer.messages.Status) Test(org.testng.annotations.Test) RoleScope(jetbrains.buildServer.serverSide.auth.RoleScope) TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) BigDecimal(java.math.BigDecimal) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) TestMetadata(jetbrains.buildServer.messages.TestMetadata) StringUtil(jetbrains.buildServer.util.StringUtil) Objects(com.google.common.base.Objects) TestRoles(jetbrains.buildServer.serverSide.impl.auth.TestRoles) TestNameResponsibilityEntryImpl(jetbrains.buildServer.responsibility.impl.TestNameResponsibilityEntryImpl) TypedValue(jetbrains.buildServer.server.rest.model.problem.TypedValue) StandardProperties(jetbrains.buildServer.users.StandardProperties) jetbrains.buildServer.serverSide(jetbrains.buildServer.serverSide) BeforeMethod(org.testng.annotations.BeforeMethod) StandardCharsets(java.nio.charset.StandardCharsets) ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Nullable(org.jetbrains.annotations.Nullable) Base64(java.util.Base64) List(java.util.List) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) ResponsibilityEntry(jetbrains.buildServer.responsibility.ResponsibilityEntry) TestName(jetbrains.buildServer.tests.TestName) NotNull(org.jetbrains.annotations.NotNull) SUser(jetbrains.buildServer.users.SUser) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) BuildBuilder(jetbrains.buildServer.buildTriggers.vcs.BuildBuilder) Test(org.testng.annotations.Test)

Example 9 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testTestRunFromOthersPersonalBuild.

@Test
public void testTestRunFromOthersPersonalBuild() throws Throwable {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    SUser user = myFixture.createUserAccount("andrey");
    SUser requester = myFixture.createUserAccount("requester");
    requester.setUserProperty(StandardProperties.SHOW_ALL_PERSONAL_BUILDS, "true");
    requester.addRole(RoleScope.projectScope(buildType.getProjectId()), getTestRoles().getProjectViewerRole());
    final SFinishedBuild personalBuild = build().in(buildType).personalForUser(user.getUsername()).withTest(BuildBuilder.TestData.test("aaa")).finish();
    final SFinishedBuild regularBuild = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa")).finish();
    TestRunDataWithBuild personalRun = t("aaa", Status.NORMAL, 1, personalBuild.getBuildId());
    TestRunDataWithBuild regularRun = t("aaa", Status.NORMAL, 2, regularBuild.getBuildId());
    myServer.getSecurityContext().runAs(requester, () -> {
        check("test:(name:aaa)", TEST_MATCHER, regularRun);
        check("test:(name:aaa),includePersonal:true", TEST_MATCHER, personalRun, regularRun);
    });
}
Also used : SUser(jetbrains.buildServer.users.SUser) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 10 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testTestStatus.

@Test
public void testTestStatus() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = createBuildWithSuccessFailedIgnoredTests(buildType);
    long bId = build10.getBuildId();
    TestRunDataWithBuild aaa = t("aaa", Status.NORMAL, 1, bId);
    TestRunDataWithBuild bbb = t("bbb", Status.FAILURE, 2, bId);
    TestRunDataWithBuild ccc = t("ccc", Status.UNKNOWN, 3, bId);
    check("build:(id:" + bId + ")", TEST_WITH_BUILD_MATCHER, aaa, bbb, ccc);
    check("build:(id:" + bId + "),status:SUCCESS", TEST_WITH_BUILD_MATCHER, aaa);
    check("build:(id:" + bId + "),status:FAILURE", TEST_WITH_BUILD_MATCHER, bbb);
    check("build:(id:" + bId + "),status:failure", TEST_WITH_BUILD_MATCHER, bbb);
    check("build:(id:" + bId + "),status:unknown", TEST_WITH_BUILD_MATCHER, ccc);
    checkExceptionOnItemsSearch(BadRequestException.class, "build:(id:" + bId + "),status:AAA");
    check("build:(id:" + bId + "),ignored:true", TEST_WITH_BUILD_MATCHER, ccc);
    check("build:(id:" + bId + "),ignored:false", TEST_WITH_BUILD_MATCHER, aaa, bbb);
    check("build:(id:" + bId + "),ignored:any", TEST_WITH_BUILD_MATCHER, aaa, bbb, ccc);
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Aggregations

BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)80 Test (org.testng.annotations.Test)68 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)19 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)12 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)12 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)12 SUser (jetbrains.buildServer.users.SUser)11 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)10 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)9 TestOccurrence (jetbrains.buildServer.server.rest.model.problem.TestOccurrence)7 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)7 TestFor (jetbrains.buildServer.util.TestFor)7 BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)6 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)5 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)4 TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)4