Search in sources :

Example 31 with BuildTypeImpl

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

the class ProblemOccurrenceFinderTest method testCurrentlyFailing.

@Test
public void testCurrentlyFailing() {
    final BuildTypeImpl buildType1 = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildType2 = registerBuildType("buildConf2", "project");
    final BuildPromotionEx build10 = (BuildPromotionEx) build().in(buildType1).withProblem(BuildProblemData.createBuildProblem("id1", "type1", "descr")).withProblem(BuildProblemData.createBuildProblem("id1", "type2", "descr")).finish().getBuildPromotion();
    final BuildPromotionEx build20 = (BuildPromotionEx) build().in(buildType1).withProblem(BuildProblemData.createBuildProblem("id1", "type1", "descr")).finish().getBuildPromotion();
    final BuildPromotionEx build30 = (BuildPromotionEx) build().in(buildType2).withProblem(BuildProblemData.createBuildProblem("id1", "type2", "descr")).finish().getBuildPromotion();
    checkProblem("problem:(id:1)", pd(1, "id1", "type1", build20.getId()), pd(1, "id1", "type1", build10.getId()));
    checkProblem("problem:(id:2)", pd(2, "id1", "type2", build30.getId()), pd(2, "id1", "type2", build10.getId()));
    checkProblem("build:(id:" + build10.getId() + ")", pd(1, "id1", "type1", build10.getId()), pd(2, "id1", "type2", build10.getId()));
    checkProblem("build:(id:" + build20.getId() + ")", pd(1, "id1", "type1", build20.getId()));
    checkProblem("currentlyFailing:true", pd(1, "id1", "type1", build20.getId()), pd(2, "id1", "type2", build30.getId()));
    checkProblem("currentlyFailing:true,build:(id:" + build10.getId() + ")", pd(1, "id1", "type1", build10.getId()));
    checkProblem("currentlyFailing:false,build:(id:" + build10.getId() + ")", pd(2, "id1", "type2", build10.getId()));
    checkProblem("currentlyFailing:true,build:(id:" + build20.getId() + ")", pd(1, "id1", "type1", build20.getId()));
    checkProblem("currentlyFailing:false,build:(id:" + build20.getId() + ")");
    checkProblem("currentlyFailing:true,problem:(id:1)", pd(1, "id1", "type1", build20.getId()));
    checkProblem("currentlyFailing:false,problem:(id:1)");
    checkProblem("currentlyFailing:true,problem:(id:2)", pd(2, "id1", "type2", build30.getId()));
    checkProblem("currentlyFailing:false,problem:(id:2)", pd(2, "id1", "type2", build10.getId()));
    checkExceptionOnItemsSearch(BadRequestException.class, "currentlyFailing:false");
}
Also used : BuildPromotionEx(jetbrains.buildServer.serverSide.BuildPromotionEx) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 32 with BuildTypeImpl

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

the class BuildTypeResolverTest method basicAncestorProjects.

public void basicAncestorProjects() throws Exception {
    ProjectEx p0 = myFixture.createProject("p0");
    ProjectEx p1 = myFixture.createProject("p1", p0);
    ProjectEx p2 = myFixture.createProject("p2", p1);
    ProjectEx p3 = myFixture.createProject("p3", p2);
    BuildTypeImpl realBuildType = myFixture.createBuildType(p3, "testBT", "test");
    ProjectsConnection ancestors = myResolver.ancestorProjects(new jetbrains.buildServer.server.graphql.model.buildType.BuildType(realBuildType), myDataFetchingEnvironment);
    // _Root, p0 .. p3
    assertEquals(5, ancestors.getCount());
    // Ancestors must be from closest to _Root
    assertExtensibleEdges(ancestors.getEdges().getData(), new Project(p3), new Project(p2), new Project(p1), new Project(p0), new Project(myFixture.getProjectManager().getRootProject()));
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Project(jetbrains.buildServer.server.graphql.model.Project) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) ProjectsConnection(jetbrains.buildServer.server.graphql.model.connections.ProjectsConnection)

Example 33 with BuildTypeImpl

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

the class TestOccurrenceRequestTest method testInvocationsAreFoundCorrectly.

@Test
@TestFor(issues = { "TW-70206" })
public void testInvocationsAreFoundCorrectly() {
    if (true)
        throw new SkipException("Ignored as current implementation does work only in a very specific number of cases when specific build is available when preparing TestOccurrences");
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build = build().in(buildType).withTest("aaa", false).withTest("aaa", true).withTest("aaa", true).finish();
    String fields = "testCounters(failed,success,all,duration),testOccurrence(id,name,muted,status,invocations($locator(count:90000),testCounters(all,success,failed),testOccurrence(id,name,status,muted)))";
    String locator = "currentlyFailing:true,affectedProject:" + buildType.getProject().getExternalId();
    FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
    mockRequest.setRequestURL(String.format("http://test/httpAuth/app/rest/testOccurrences?locator=%s&fields=%s", locator, fields));
    TestOccurrences testOccurrences = myRequest.getTestOccurrences(locator, fields, null, mockRequest);
    assertEquals("Should return exactly one 'grouping' test run.", 1, testOccurrences.items.size());
    TestOccurrence grouping = testOccurrences.items.get(0);
    assertNotNull("Should contain invocations node.", grouping.getInvocations());
    assertEquals("Should contain exactly 3 occurrences.", 3, grouping.getInvocations().items.size());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 34 with BuildTypeImpl

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

the class TestOccurrenceRequestTest method testShouldRespectExpandInvocationsDimension.

@Test
@TestFor(issues = { "TW-70331" })
public void testShouldRespectExpandInvocationsDimension() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build = build().in(buildType).withTest("aaa", false).withTest("aaa", false).withTest("aaa", true).finish();
    FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
    String fields = "testCounters(all,success,failed)";
    String locator = "build:" + build.getBuildId() + ",expandInvocations:true";
    mockRequest.setRequestURL(String.format("http://test/httpAuth/app/rest/testOccurrences?locator=%s&fields=%s", locator, fields));
    TestOccurrences testOccurrences = myRequest.getTestOccurrences(locator, fields, null, mockRequest);
    assertEquals(new Integer(3), testOccurrences.getTestCounters().getAll());
    assertEquals(new Integer(2), testOccurrences.getTestCounters().getFailed());
    assertEquals(new Integer(1), testOccurrences.getTestCounters().getSuccess());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 35 with BuildTypeImpl

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

the class BuildTypeRequestTest method testParameterTypeResourses.

@Test
public void testParameterTypeResourses() {
    BuildTypeImpl buildType1 = registerTemplateBasedBuildType("buildType1");
    ParameterFactory parameterFactory = myFixture.getSingletonService(ParameterFactory.class);
    ParameterDescriptionFactory parameterDescriptionFactory = myFixture.getSingletonService(ParameterDescriptionFactory.class);
    buildType1.addParameter(parameterFactory.createParameter("a1", "b10", parameterDescriptionFactory.createDescription("cType", CollectionsUtil.asMap("a", "b", "c", "d"))));
    buildType1.addParameter(new SimpleParameter("a2", "b9"));
    final String btLocator = "id:" + buildType1.getExternalId();
    TypedParametersSubResource parametersSubResource = myBuildTypeRequest.getParametersSubResource(btLocator);
    assertEquals(2, parametersSubResource.getParameters(null, "$long,property($long)").properties.size());
    {
        Property parameter = parametersSubResource.getParameter("a1", "$long");
        assertEquals("a1", parameter.name);
        assertEquals("b10", parameter.value);
        assertEquals("cType a='b' c='d'", parameter.type.rawValue);
    }
    {
        ParameterType parameterType = parametersSubResource.getParameterType("a1");
        assertEquals("cType a='b' c='d'", parameterType.rawValue);
    }
/*
    {
      assertEquals("cType", buildType1.getParameter("a1").getControlDescription().getParameterType());
      assertMap(buildType1.getParameter("a1").getControlDescription().getParameterTypeArguments(), "a", "b", "c", "d");
      ParameterType parameterType = new ParameterType();
      parameterType.rawValue = "cType a='b1' c='d'";
      ParameterType newParameterType = parametersSubResource.setParameterType("a1", parameterType);
      assertEquals("cType a='b1' c='d'", newParameterType.rawValue);
      assertEquals("cType", buildType1.getParameter("a1").getControlDescription().getParameterType());
      assertMap(buildType1.getParameter("a1").getControlDescription().getParameterTypeArguments(), "a", "b1", "c", "d");
    }
    */
}
Also used : ParameterFactory(jetbrains.buildServer.serverSide.parameters.ParameterFactory) ParameterDescriptionFactory(jetbrains.buildServer.serverSide.parameters.ParameterDescriptionFactory) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

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