com.teamscale.service.testimpact.prioritization.legacy.PrioritizableTestPre80 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
The newest version!
package com.teamscale.service.testimpact.prioritization.legacy;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.conqat.engine.sourcecode.coverage.TestUniformPathUtils;
import org.conqat.lib.commons.collections.CollectionUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.teamscale.service.testimpact.prioritization.ETestSelectionReason;
import com.teamscale.service.testimpact.prioritization.IPrioritizableTests;
import com.teamscale.service.testimpact.prioritization.PrioritizableTest;
/**
* Test with information about their partition as well as tracking data produced during
* prioritization of tests. This is the old DTO that Teamscale used up to 7.6.x and is superseded by
* {@link PrioritizableTest}.
*/
public class PrioritizableTestPre80 {
/**
* The uniform path the test (without -test-execution- prefix).
*/
@JsonProperty("uniformPath")
private String uniformPath;
/** The reason the test has been selected. */
@JsonProperty("selectionReason")
private ETestSelectionReason selectionReason;
/** Partition of the test. */
@JsonProperty("partition")
private String partition;
@JsonProperty("coveredMethodCount")
private int numberOfCoveredMethods = 0;
/** Duration in ms. May be null if not set. */
@JsonProperty("durationInMs")
@Nullable
protected Long durationInMs = null;
/**
* Field for tracking {@link IPrioritizableTests#getCurrentScore()}.
*/
@JsonProperty("currentScore")
private double currentScore;
@JsonProperty("additionallyCoveredMethodCount")
private int numberOfAdditionallyCoveredMethods = 0;
/**
* Field for storing the tests rank. The rank is the 1-based index of the test in the prioritized
* list.
*/
@JsonProperty("rank")
private Integer rank;
@JsonCreator
public PrioritizableTestPre80() {
}
private PrioritizableTestPre80(PrioritizableTest prioritizableTest) {
uniformPath = TestUniformPathUtils
.convertCoverageUnitPathToTestName(prioritizableTest.getUniformPath().toString());
selectionReason = CollectionUtils.getAny(prioritizableTest.getSelectionReasons());
partition = prioritizableTest.getPartition();
numberOfCoveredMethods = (int) prioritizableTest.getNumberOfCoveredMethods();
if (prioritizableTest.isDurationSet()) {
durationInMs = prioritizableTest.getDurationInMs(0);
}
currentScore = prioritizableTest.getCurrentScore();
numberOfAdditionallyCoveredMethods = prioritizableTest.getNumberOfAdditionallyCoveredMethods();
rank = prioritizableTest.getRank();
}
/**
* Converts a {@link PrioritizableTest} to the data format used up to Teamscale 7.7.
*/
public static List from(List prioritizableTests) {
return CollectionUtils.filterAndMap(prioritizableTests,
prioritizableTest -> prioritizableTest.getUniformPath().isTestExecutionPath(),
PrioritizableTestPre80::new);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy