Search in sources :

Example 11 with SUser

use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testDefaults.

@Test
public void testDefaults() {
    final SProject project = createProject("prj", "project");
    final BuildTypeEx buildConf1 = (BuildTypeEx) project.createBuildType("buildConf1", "buildConf1");
    SUser user1 = createUser("user1");
    final BuildPromotion build10 = build().in(buildConf1).finish().getBuildPromotion();
    final BuildPromotion build15 = build().in(buildConf1).personalForUser("user1").finish().getBuildPromotion();
    final BuildPromotion build20 = build().in(buildConf1).failedToStart().finish().getBuildPromotion();
    final BuildPromotion build30 = build().in(buildConf1).cancel(user1).getBuildPromotion();
    SFinishedBuild finishedBuild40 = build().in(buildConf1).withBranch("branch1").tag("tag").finish();
    finishedBuild40.setPinned(true, null, null);
    final BuildPromotion build40 = finishedBuild40.getBuildPromotion();
    final BuildPromotion build45 = build().in(buildConf1).withBranch("branch1").personalForUser("user1").finish().getBuildPromotion();
    final BuildPromotion build50 = build().in(buildConf1).withBranch("branch1").failedToStart().by(user1).finish().getBuildPromotion();
    final BuildPromotion build60 = build().in(buildConf1).withBranch("branch1").cancel(user1).getBuildPromotion();
    final BuildPromotion build100 = build().in(buildConf1).run().getBuildPromotion();
    myFixture.createEnabledAgent("agent2", "runner1");
    myFixture.createEnabledAgent("agent3", "runner1");
    final BuildPromotion build110 = build().in(buildConf1).withBranch("branch1").by(user1).run().getBuildPromotion();
    final BuildPromotion build120 = build().in(buildConf1).withBranch("branch1").personalForUser("user1").failedToStart().tag("tag").run().getBuildPromotion();
    final BuildPromotion build130 = build().in(buildConf1).addToQueue().getBuildPromotion();
    final BuildPromotion build140 = build().in(buildConf1).withBranch("branch1").addToQueue().getBuildPromotion();
    final BuildPromotion build150 = build().in(buildConf1).withBranch("branch1").personalForUser("user1").addToQueue().getBuildPromotion();
    check("defaultFilter:false", build130, build140, build150, build120, build110, build100, build60, build50, build45, build40, build30, build20, build15, build10);
    check(null, build10);
    check("state:finished", build10);
    check("state:(finished:true)", build10);
    check("running:false", build10);
    // bug here with state processing    check("state:(finished:false)", build130, build140, build150, build120, build110, build100);
    // bug here with state processing    check("state:(finished:any)", build130, build140, build150, build120, build110, build100, build60, build50, build45, build40, build30, build20, build15, build10);
    check("state:(finished:true,running:true)", build100, build10);
    check("state:(finished:true,running:true),defaultFilter:false", build120, build110, build100, build60, build50, build45, build40, build30, build20, build15, build10);
    check("state:(finished:true,running:true),defaultFilter:true", build100, build10);
    check("state:(finished:true,queued:true)", build130, build10);
    check("running:true,defaultFilter:true", build100);
    check("running:true", build120, build110, build100);
    check("state:(running)", build120, build110, build100);
    check("state:(running:true)", build120, build110, build100);
    check("branch:(branch1)", build40);
    check("branch:(branch1),running:true", build120, build110);
    check("agent:(id:" + build100.getAssociatedBuild().getAgent().getId() + ")", build60, build50, build45, build40, build30, build20, build15, build10);
    check("agent:(id:" + build110.getAssociatedBuild().getAgent().getId() + ")");
    check("agent:(id:" + build100.getAssociatedBuild().getAgent().getId() + "),running:any", build100, build60, build50, build45, build40, build30, build20, build15, build10);
    check("agent:(id:" + build100.getAssociatedBuild().getAgent().getId() + "),running:true", build100);
    check("agent:(id:" + build110.getAssociatedBuild().getAgent().getId() + "),running:true", build110);
    check("agent:(id:" + build120.getAssociatedBuild().getAgent().getId() + "),running:true", build120);
    check("agentName:" + build120.getAssociatedBuild().getAgent().getName() + ",running:true", build120);
    check("user:id:" + user1.getId(), build50, build45, build15);
    check("user:id:" + user1.getId() + ",state:any", build150, build120, build110, build50, build45, build15);
    check("triggered:(user:id:" + user1.getId() + ")", build50);
    check("triggered:(user:id:" + user1.getId() + "),state:any", build110, build50);
    check("id:" + build50.getId(), build50);
    check("id:" + build60.getId(), build60);
    check("id:" + build120.getId(), build120);
    check("id:" + build150.getId(), build150);
    check("state:queued", build130, build140, build150);
    check("state:(queued:true,running:true)", build130, build140, build150, build120, build110, build100);
    check("buildType:" + buildConf1.getExternalId(), build10);
    check("buildType:" + buildConf1.getExternalId() + ",running:any", build100, build10);
    check("buildType:" + buildConf1.getExternalId() + ",running:any,defaultFilter:false", build120, build110, build100, build60, build50, build45, build40, build30, build20, build15, build10);
    // bug here with state processing    check("buildType:" + buildConf1.getExternalId() + ",state:(queued:any)", build130, build100, build10);
    check("buildType:" + buildConf1.getExternalId() + ",state:(queued:true,running:true,finished:true)", build130, build100, build10);
    check("buildType:" + buildConf1.getExternalId() + ",state:(queued:true,running:true,finished:true),defaultFilter:false", build130, build140, build150, build120, build110, build100, build60, build50, build45, build40, build30, build20, build15, build10);
    check("tag:tag");
    check("tag:tag,running:true", build120);
    check("pinned:true");
}
Also used : SUser(jetbrains.buildServer.users.SUser) Test(org.testng.annotations.Test)

Example 12 with SUser

use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testUserDimension.

@Test
public void testUserDimension() {
    final SProject project = createProject("prj", "project");
    final BuildTypeEx buildConf = (BuildTypeEx) project.createBuildType("buildConf", "buildConf");
    SUser user1 = createUser("user1");
    SUser user2 = createUser("user2");
    BuildPromotion build10 = build().in(buildConf).number("1").finish().getBuildPromotion();
    BuildPromotion build20 = build().in(buildConf).number("1").personalForUser(user1.getUsername()).finish().getBuildPromotion();
    BuildPromotion build30 = build().in(buildConf).number("1").by(user1).finish().getBuildPromotion();
    BuildPromotion build40 = build().in(buildConf).number("1").personalForUser(user2.getUsername()).by(user1).finish().getBuildPromotion();
    BuildPromotion build50 = build().in(buildConf).personalForUser(user1.getUsername()).addToQueue().getBuildPromotion();
    assertNull(build20.getAssociatedBuild().getTriggeredBy().getUser());
    // searches with "number:1" execute only filter part of the logic, but shold result in the same set of builds
    check("state:any,defaultFilter:false", build50, build40, build30, build20, build10);
    check("state:any,defaultFilter:false,number:1", build40, build30, build20, build10);
    check("state:any,defaultFilter:false,user:user1", build50, build30, build20);
    check("state:any,defaultFilter:false,user:user1,number:1", build30, build20);
    check("state:any,defaultFilter:false,user:user2", build40);
    check("state:any,defaultFilter:false,user:user2,number:1", build40);
    check("state:any,defaultFilter:false,user:user1,personal:true", build50, build20);
    check("state:any,defaultFilter:false,user:user1,personal:true,number:1", build20);
    check("state:any,defaultFilter:false,user:user2,personal:true", build40);
    check("state:any,defaultFilter:false,user:user2,personal:true,number:1", build40);
    check("state:any,defaultFilter:false,user:user1,personal:false", build30);
    check("state:any,defaultFilter:false,user:user1,personal:false,number:1", build30);
    check("state:any,defaultFilter:false,user:user2,personal:false");
    check("state:any,defaultFilter:false,user:user2,personal:false,number:1");
    check("state:any,defaultFilter:false,triggered:(user:user1)", build40, build30);
    check("state:any,defaultFilter:false,triggered:(user:user1),user:user2", build40);
    check("state:any,defaultFilter:false,user:user1,not:(triggered:(user:user1))", build50, build20);
    check("state:any,defaultFilter:false,triggered:(type:user)", build40, build30);
}
Also used : SUser(jetbrains.buildServer.users.SUser) Test(org.testng.annotations.Test)

Example 13 with SUser

use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testDefaultFiltering.

@Test
public void testDefaultFiltering() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    final SUser user = createUser("uuser");
    SBuild build1 = build().in(buildConf).finish();
    SBuild build2failed = build().in(buildConf).failed().finish();
    SBuild build5personal = build().in(buildConf).personalForUser(user.getUsername()).finish();
    RunningBuildEx build7running = startBuild(buildConf);
    build7running.stop(user, "cancel comment");
    SBuild build7canceled = finishBuild(build7running, false);
    final RunningBuildEx build8running = startBuild(buildConf);
    // make the build failed
    build8running.addBuildProblem(createBuildProblem());
    build8running.stop(user, "cancel comment");
    SBuild build8canceledFailed = finishBuild(build8running, true);
    SBuild build9failedToStart = build().in(buildConf).failedToStart().finish();
    SBuild build11inBranch = build().in(buildConf).withBranch("branch").finish();
    SBuild build13running = startBuild(buildConf);
    SQueuedBuild build14queued = addToQueue(buildConf);
    checkBuilds(null, getBuildPromotions(build2failed, build1));
    checkBuilds("defaultFilter:false", getBuildPromotions(build14queued, build13running, build11inBranch, build9failedToStart, build8canceledFailed, build7canceled, build5personal, build2failed, build1));
    checkBuilds("defaultFilter:true", getBuildPromotions(build2failed, build1));
    checkBuilds("canceled:true", getBuildPromotions(build8canceledFailed, build7canceled));
    checkBuilds("canceled:true,state:(queued:true)");
    checkBuilds("failedToStart:true,state:(queued:true)");
    checkBuilds("canceled:false", getBuildPromotions(build2failed, build1));
    checkBuilds("canceled:false,defaultFilter:false", getBuildPromotions(build14queued, build13running, build11inBranch, build9failedToStart, build5personal, build2failed, build1));
    checkBuilds("canceled:any", getBuildPromotions(build8canceledFailed, build7canceled, build2failed, build1));
    checkBuilds("personal:true", getBuildPromotions(build5personal));
    checkBuilds("personal:any", getBuildPromotions(build5personal, build2failed, build1));
    checkBuilds("state:any", getBuildPromotions(build14queued, build13running, build2failed, build1));
}
Also used : SUser(jetbrains.buildServer.users.SUser) Test(org.testng.annotations.Test)

Example 14 with SUser

use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.

the class BuildTypeFinderTest method testSnapshotAndSelected.

@Test
public void testSnapshotAndSelected() throws Exception {
    myBuildType.remove();
    final SBuildType buildConf01 = myProject.createBuildType("buildConf01", "build conf 01");
    final SBuildType buildConf02 = myProject.createBuildType("buildConf02", "build conf 02");
    final SBuildType buildConf1 = myProject.createBuildType("buildConf1", "build conf 1");
    final SBuildType buildConf2 = myProject.createBuildType("buildConf2", "build conf 2");
    final SBuildType buildConf31 = myProject.createBuildType("buildConf31", "build conf 31");
    final SBuildType buildConf32 = myProject.createBuildType("buildConf32", "build conf 32");
    final SBuildType buildConf4 = myProject.createBuildType("buildConf4", "build conf 4");
    addDependency(buildConf4, buildConf31);
    addDependency(buildConf4, buildConf32);
    addDependency(buildConf31, buildConf2);
    addDependency(buildConf32, buildConf2);
    addDependency(buildConf2, buildConf1);
    addDependency(buildConf2, buildConf01);
    addDependency(buildConf1, buildConf01);
    addDependency(buildConf1, buildConf02);
    checkBuildTypes("snapshotDependency:(to:(id:" + buildConf4.getExternalId() + "))", buildConf31, buildConf32, buildConf2, buildConf1, buildConf01, buildConf02);
    final SUser user1 = createUser("user1");
    user1.addRole(RoleScope.projectScope(myProject.getProjectId()), getProjectViewerRole());
    user1.setBuildTypesOrder(myProject, Arrays.asList(buildConf1, buildConf01, buildConf31, buildConf2, buildConf02), Arrays.asList(buildConf32));
    checkBuildTypes("snapshotDependency:(to:(id:" + buildConf4.getExternalId() + ")),selectedByUser:(username:user1)", buildConf1, buildConf01, buildConf31, buildConf2, buildConf02);
}
Also used : SUser(jetbrains.buildServer.users.SUser) Test(org.testng.annotations.Test)

Example 15 with SUser

use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.

the class TestOccurrenceFinderTest method testDoesNotReturnOtherUsersPersonalBuilds.

@Test
public void testDoesNotReturnOtherUsersPersonalBuilds() {
    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();
    STestRun testInPersonalBuild = personalBuild.getFullStatistics().getAllTests().get(0);
    TestRunDataWithBuild personalRun = t("aaa", Status.NORMAL, 1, personalBuild.getBuildId());
    check(String.format("id:%d,build:%d", testInPersonalBuild.getTestRunId(), personalBuild.getBuildId()), TEST_MATCHER, personalRun);
}
Also used : SUser(jetbrains.buildServer.users.SUser) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Aggregations

SUser (jetbrains.buildServer.users.SUser)125 Test (org.testng.annotations.Test)70 ApiOperation (io.swagger.annotations.ApiOperation)35 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)35 Build (jetbrains.buildServer.server.rest.model.build.Build)20 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)18 NotNull (org.jetbrains.annotations.NotNull)18 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)15 SecurityContextEx (jetbrains.buildServer.serverSide.SecurityContextEx)13 Fields (jetbrains.buildServer.server.rest.model.Fields)12 SUserGroup (jetbrains.buildServer.groups.SUserGroup)11 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)10 ServiceLocator (jetbrains.buildServer.ServiceLocator)9 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)9 Nullable (org.jetbrains.annotations.Nullable)9 LocatorProcessException (jetbrains.buildServer.server.rest.errors.LocatorProcessException)8 SecurityContextImpl (jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl)8 java.util (java.util)7 Collectors (java.util.stream.Collectors)7 jetbrains.buildServer.serverSide (jetbrains.buildServer.serverSide)7