Search in sources :

Example 1 with TestCountersData

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

the class TestScopeTreeCollector method buildTree.

@NotNull
private ScopeTree<STestRun, TestCountersData> buildTree(@NotNull Locator locator) {
    Locator scopesLocator = prepareScopesLocator(locator);
    Stream<TestScope> testScopes = myScopeCollector.getItems(scopesLocator);
    return new ScopeTree<STestRun, TestCountersData>(TestScopeInfo.ROOT, new TestCountersData(), // this is a bit fragile as we require all of those to be CLASS
    testScopes.collect(Collectors.toList()));
}
Also used : Locator(jetbrains.buildServer.server.rest.data.Locator) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with TestCountersData

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

the class TestScopeTreeCollector method getSlicedTreeFromBuildPromotions.

@NotNull
public List<ScopeTree.Node<STestRun, TestCountersData>> getSlicedTreeFromBuildPromotions(@NotNull Stream<BuildPromotion> promotions, @NotNull Locator treeLocator) {
    treeLocator.addSupportedDimensions(NEW_FAILURE, SUBTREE_ROOT_ID);
    final String testRunsLocator = "build:%d,status:failure,muted:false,ignored:false" + (treeLocator.isAnyPresent(NEW_FAILURE) ? ",newFailure:" + treeLocator.getSingleDimensionValue(NEW_FAILURE) : "");
    Stream<STestRun> testRunStream = promotions.filter(promotion -> promotion.getAssociatedBuildId() != null).flatMap(promotion -> myTestOccurrenceFinder.getItems(String.format(testRunsLocator, promotion.getAssociatedBuildId())).myEntries.stream());
    Stream<TestScope> scopeStream = myScopeCollector.groupByClass(testRunStream, new TestScopeFilterImpl(Collections.emptyList(), ""));
    scopeStream = myScopeCollector.splitByBuildType(scopeStream);
    List<TestScope> scopes = scopeStream.collect(Collectors.toList());
    ScopeTree<STestRun, TestCountersData> tree = new ScopeTree<STestRun, TestCountersData>(TestScopeInfo.ROOT, new TestCountersData(), scopes);
    if (treeLocator.isAnyPresent(SUBTREE_ROOT_ID)) {
        String subTreeRootId = treeLocator.getSingleDimensionValue(SUBTREE_ROOT_ID);
        treeLocator.checkLocatorFullyProcessed();
        // noinspection ConstantConditions
        return tree.getFullNodeAndSlicedOrderedSubtree(subTreeRootId, DEFAULT_MAX_CHILDREN, STestRun.NEW_FIRST_NAME_COMPARATOR, SUPPORTED_ORDERS.getComparator(DEFAULT_NODE_ORDER_BY_NEW_FAILED_COUNT));
    }
    treeLocator.checkLocatorFullyProcessed();
    return tree.getSlicedOrderedTree(DEFAULT_MAX_CHILDREN, STestRun.NEW_FIRST_NAME_COMPARATOR, SUPPORTED_ORDERS.getComparator(DEFAULT_NODE_ORDER_BY_NEW_FAILED_COUNT));
}
Also used : LocatorProcessException(jetbrains.buildServer.server.rest.errors.LocatorProcessException) java.util(java.util) BuildPromotion(jetbrains.buildServer.serverSide.BuildPromotion) STestRun(jetbrains.buildServer.serverSide.STestRun) Locator(jetbrains.buildServer.server.rest.data.Locator) Collectors(java.util.stream.Collectors) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) jetbrains.buildServer.server.rest.data.problem.tree(jetbrains.buildServer.server.rest.data.problem.tree) Stream(java.util.stream.Stream) Orders(jetbrains.buildServer.server.rest.data.problem.Orders) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) NotNull(org.jetbrains.annotations.NotNull) PagerData(jetbrains.buildServer.server.rest.model.PagerData) STestRun(jetbrains.buildServer.serverSide.STestRun) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with TestCountersData

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

the class TestOccurrences method makeCountersFromItems.

private void makeCountersFromItems(@NotNull final Collection<STestRun> testRuns) {
    // We want lazy calculations of counters and do not want to duplicate that in TestCounters
    // To ensure that we do calculations once lets check if the field is requested in TestOccurrences or in TestCounters
    Fields countersFields = myFields.getNestedField("testCounters");
    boolean failedIncluded = myFields.isIncluded("failed", false, true) || BooleanUtils.isTrue(countersFields.isIncluded("failed"));
    boolean mutedIncluded = myFields.isIncluded("muted", false, true) || BooleanUtils.isTrue(countersFields.isIncluded("muted"));
    boolean successIncluded = myFields.isIncluded("passed", false, true) || BooleanUtils.isTrue(countersFields.isIncluded("success"));
    boolean ignoredIncluded = myFields.isIncluded("ignored", false, true) || BooleanUtils.isTrue(countersFields.isIncluded("ignored"));
    boolean newFailureIncluded = myFields.isIncluded("newFailed", false, true) || countersFields.isIncluded("newFailed", false, true);
    boolean durationIncluded = countersFields.isIncluded("duration", false, true);
    myTestCountersData = new TestCountersData(testRuns, successIncluded, failedIncluded, mutedIncluded, ignoredIncluded, newFailureIncluded, durationIncluded);
}
Also used : Fields(jetbrains.buildServer.server.rest.model.Fields) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData)

Example 4 with TestCountersData

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

the class TestScopes method getTestCounters.

@XmlElement(name = "testCounters")
public TestCounters getTestCounters() {
    return ValueWithDefault.decideDefault(myFields.isIncluded("testCounters"), () -> {
        Fields testCounters = myFields.getNestedField("testCounters");
        List<STestRun> runs = myTestScopes.stream().flatMap(scope -> scope.getTestRuns().stream()).collect(Collectors.toList());
        // Will just calculate all counters for simplicity
        TestCountersData data = new TestCountersData(runs);
        return new TestCounters(testCounters, data);
    });
}
Also used : XmlAttribute(javax.xml.bind.annotation.XmlAttribute) Fields(jetbrains.buildServer.server.rest.model.Fields) STestRun(jetbrains.buildServer.serverSide.STestRun) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) ValueWithDefault(jetbrains.buildServer.server.rest.util.ValueWithDefault) Collectors(java.util.stream.Collectors) TestCounters(jetbrains.buildServer.server.rest.model.problem.TestCounters) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) XmlType(javax.xml.bind.annotation.XmlType) UriInfo(javax.ws.rs.core.UriInfo) ModelBaseType(jetbrains.buildServer.server.rest.swagger.annotations.ModelBaseType) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) NotNull(org.jetbrains.annotations.NotNull) ObjectType(jetbrains.buildServer.server.rest.swagger.constants.ObjectType) XmlElement(javax.xml.bind.annotation.XmlElement) PagerData(jetbrains.buildServer.server.rest.model.PagerData) Fields(jetbrains.buildServer.server.rest.model.Fields) STestRun(jetbrains.buildServer.serverSide.STestRun) TestCountersData(jetbrains.buildServer.server.rest.data.problem.TestCountersData) TestCounters(jetbrains.buildServer.server.rest.model.problem.TestCounters) XmlElement(javax.xml.bind.annotation.XmlElement)

Aggregations

TestCountersData (jetbrains.buildServer.server.rest.data.problem.TestCountersData)4 NotNull (org.jetbrains.annotations.NotNull)3 Collectors (java.util.stream.Collectors)2 Locator (jetbrains.buildServer.server.rest.data.Locator)2 Fields (jetbrains.buildServer.server.rest.model.Fields)2 PagerData (jetbrains.buildServer.server.rest.model.PagerData)2 STestRun (jetbrains.buildServer.serverSide.STestRun)2 java.util (java.util)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 UriInfo (javax.ws.rs.core.UriInfo)1 XmlAttribute (javax.xml.bind.annotation.XmlAttribute)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 XmlRootElement (javax.xml.bind.annotation.XmlRootElement)1 XmlType (javax.xml.bind.annotation.XmlType)1 Orders (jetbrains.buildServer.server.rest.data.problem.Orders)1 TestOccurrenceFinder (jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder)1 jetbrains.buildServer.server.rest.data.problem.tree (jetbrains.buildServer.server.rest.data.problem.tree)1 LocatorProcessException (jetbrains.buildServer.server.rest.errors.LocatorProcessException)1 TestCounters (jetbrains.buildServer.server.rest.model.problem.TestCounters)1