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()));
}
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));
}
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);
}
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);
});
}
Aggregations