Search in sources :

Example 1 with TestScope

use of jetbrains.buildServer.server.rest.data.problem.scope.TestScope in project teamcity-rest by JetBrains.

the class TestScopesCollectorTest method testCanGetSuites.

@Test
public void testCanGetSuites() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).startSuite("suite1").withTest("packageA.class1.aaa", true).withTest("packageA.class2.bbb", true).endSuite().startSuite("suite2").withTest("packageB.class1.ccc", true).withTest("packageB.class2.ddd", true).endSuite().finish();
    PagedSearchResult<TestScope> result = myTestScopesCollector.getPagedItems(Locator.createPotentiallyEmptyLocator("testOccurrences:(build:(id:" + build10.getBuildId() + ")),scopeType:suite"));
    for (TestScope scope : result.myEntries) {
        assertEquals(2, scope.getTestRuns().size());
    }
    Set<String> suites = result.myEntries.stream().peek(scope -> assertEquals(2, scope.getTestRuns().size())).peek(scope -> scope.getName().equals(scope.getSuite())).map(scope -> scope.getSuite()).collect(Collectors.toSet());
    assertEquals(2, suites.size());
    assertContains(suites, "suite1: ", "suite2: ");
}
Also used : TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Set(java.util.Set) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 2 with TestScope

use of jetbrains.buildServer.server.rest.data.problem.scope.TestScope in project teamcity-rest by JetBrains.

the class TestScopesCollectorTest method testCanFilterSuites.

@Test
public void testCanFilterSuites() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).startSuite("suite1").withTest("packageA.class1.aaa", true).withTest("packageA.class2.bbb", true).endSuite().startSuite("suite2").withTest("packageB.class1.ccc", true).withTest("packageB.class2.ddd", true).endSuite().finish();
    // $base64:c3VpdGUxOiA= is a base64 representation of a string 'suite1: '
    PagedSearchResult<TestScope> result = myTestScopesCollector.getPagedItems(Locator.createPotentiallyEmptyLocator("testOccurrences:(build:(id:" + build10.getBuildId() + ")),scopeType:suite,suite:(value:($base64:c3VpdGUxOiA=),matchType:equals)"));
    assertEquals(1, result.myEntries.size());
    assertEquals("suite1: ", result.myEntries.get(0).getName());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 3 with TestScope

use of jetbrains.buildServer.server.rest.data.problem.scope.TestScope in project teamcity-rest by JetBrains.

the class TestScopesCollectorTest method testCanGetPackages.

@Test
public void testCanGetPackages() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("package1.class1.aaa", true).withTest("package2.class2.bbb", true).withTest("package3.class1.ccc", true).withTest("package4.class2.ddd", true).finish();
    String locator = "scopeType:package,testOccurrences:(build:(id:" + build10.getBuildId() + "))";
    PagedSearchResult<TestScope> result = myTestScopesCollector.getPagedItems(Locator.locator(locator));
    assertEquals(4, result.myEntries.size());
    Set<String> packages = result.myEntries.stream().peek(scope -> assertEquals(1, scope.getTestRuns().size())).peek(scope -> scope.getName().equals(scope.getPackage())).map(scope -> scope.getPackage()).collect(Collectors.toSet());
    for (int i = 1; i <= 4; i++) {
        assertTrue(packages.contains("package" + i));
    }
}
Also used : TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Set(java.util.Set) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 4 with TestScope

use of jetbrains.buildServer.server.rest.data.problem.scope.TestScope in project teamcity-rest by JetBrains.

the class TestScopesCollectorTest method testCanGetClasses.

@Test
public void testCanGetClasses() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("packageA.class1.aaa", true).withTest("packageA.class2.bbb", true).withTest("packageB.class1.ccc", true).withTest("packageB.class2.ddd", true).finish();
    String locator = "scopeType:class,testOccurrences:(build:(id:" + build10.getBuildId() + "))";
    PagedSearchResult<TestScope> result = myTestScopesCollector.getPagedItems(Locator.locator(locator));
    assertEquals("Although there are only class1 and class 2, packageA.classX and packageB.classX are expected to be different", 4, result.myEntries.size());
    Set<String> classes = result.myEntries.stream().peek(scope -> assertEquals(1, scope.getTestRuns().size())).peek(scope -> scope.getName().equals(scope.getClass1())).map(scope -> scope.getClass1()).collect(Collectors.toSet());
    assertContains(classes, "class1", "class2");
}
Also used : TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Set(java.util.Set) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 5 with TestScope

use of jetbrains.buildServer.server.rest.data.problem.scope.TestScope in project teamcity-rest by JetBrains.

the class TestScopesRequest method serveGroupedTestOccurrences.

// Very highly experimental
@GET
@Path("/{scopeName}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(hidden = true, value = "highly experimental")
public TestScopes serveGroupedTestOccurrences(@QueryParam("locator") String locatorText, @PathParam("scopeName") String scopeName, @QueryParam("fields") String fields, @Context UriInfo uriInfo, @Context HttpServletRequest request) {
    Set<String> supportedGroupings = new HashSet<>(Arrays.asList("package", "suite", "class"));
    if (!supportedGroupings.contains(scopeName)) {
        throw new BadRequestException("Invalid scope. Only scopes " + String.join(",", supportedGroupings) + " are supported.");
    }
    Locator patchedLocator = new Locator(locatorText);
    patchedLocator.setDimension(TestScopesCollector.SCOPE_TYPE, scopeName);
    PagedSearchResult<TestScope> items = myTestScopesCollector.getPagedItems(patchedLocator);
    PagerData pager = new PagerData(uriInfo.getRequestUriBuilder(), request.getContextPath(), items, locatorText, "locator");
    return new TestScopes(items.myEntries, new Fields(fields), pager, uriInfo, myBeanContext);
}
Also used : ServiceLocator(jetbrains.buildServer.ServiceLocator) Locator(jetbrains.buildServer.server.rest.data.Locator) Fields(jetbrains.buildServer.server.rest.model.Fields) TestScope(jetbrains.buildServer.server.rest.data.problem.scope.TestScope) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) PagerData(jetbrains.buildServer.server.rest.model.PagerData) TestScopes(jetbrains.buildServer.server.rest.model.problem.scope.TestScopes) HashSet(java.util.HashSet) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)5 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)4 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)4 Test (org.testng.annotations.Test)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 ApiOperation (io.swagger.annotations.ApiOperation)1 HashSet (java.util.HashSet)1 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 Locator (jetbrains.buildServer.server.rest.data.Locator)1 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)1 Fields (jetbrains.buildServer.server.rest.model.Fields)1 PagerData (jetbrains.buildServer.server.rest.model.PagerData)1 TestScopes (jetbrains.buildServer.server.rest.model.problem.scope.TestScopes)1