Search in sources :

Example 1 with ImpactedTestEngine

use of com.teamscale.test_impacted.engine.ImpactedTestEngine in project teamscale-jacoco-agent by cqse.

the class AvailableTests method convertToUniqueIds.

/**
 * Converts the {@link PrioritizableTest}s which are match the {@link UniqueId}s returned by the {@link TestEngine}s
 * used by the {@link ImpactedTestEngine}.
 */
public Set<UniqueId> convertToUniqueIds(List<PrioritizableTest> impactedTests) {
    Set<UniqueId> list = new HashSet<>();
    for (PrioritizableTest impactedTest : impactedTests) {
        LOGGER.info(() -> impactedTest.uniformPath + " " + impactedTest.selectionReason);
        UniqueId testUniqueId = uniformPathToUniqueIdMapping.get(impactedTest.uniformPath);
        if (testUniqueId == null) {
            LOGGER.error(() -> "Retrieved invalid test '" + impactedTest.uniformPath + "' from Teamscale server!");
            LOGGER.error(() -> "The following seem related:");
            uniformPathToUniqueIdMapping.keySet().stream().sorted(Comparator.comparing(testPath -> StringUtils.editDistance(impactedTest.uniformPath, testPath))).limit(5).forEach(testAlternative -> LOGGER.error(() -> " - " + testAlternative));
            LOGGER.error(() -> "Falling back to execute all...");
            return new HashSet<>(uniformPathToUniqueIdMapping.values());
        }
        list.add(testUniqueId);
    }
    return list;
}
Also used : ImpactedTestEngine(com.teamscale.test_impacted.engine.ImpactedTestEngine) Logger(org.junit.platform.commons.logging.Logger) TestEngine(org.junit.platform.engine.TestEngine) Set(java.util.Set) HashMap(java.util.HashMap) UniqueId(org.junit.platform.engine.UniqueId) PrioritizableTest(com.teamscale.client.PrioritizableTest) StringUtils(com.teamscale.client.StringUtils) LoggerFactory(org.junit.platform.commons.logging.LoggerFactory) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) TestDetails(com.teamscale.client.TestDetails) Map(java.util.Map) ClusteredTestDetails(com.teamscale.client.ClusteredTestDetails) Comparator(java.util.Comparator) UniqueId(org.junit.platform.engine.UniqueId) HashSet(java.util.HashSet) PrioritizableTest(com.teamscale.client.PrioritizableTest)

Aggregations

ClusteredTestDetails (com.teamscale.client.ClusteredTestDetails)1 PrioritizableTest (com.teamscale.client.PrioritizableTest)1 StringUtils (com.teamscale.client.StringUtils)1 TestDetails (com.teamscale.client.TestDetails)1 ImpactedTestEngine (com.teamscale.test_impacted.engine.ImpactedTestEngine)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Logger (org.junit.platform.commons.logging.Logger)1 LoggerFactory (org.junit.platform.commons.logging.LoggerFactory)1 TestEngine (org.junit.platform.engine.TestEngine)1 UniqueId (org.junit.platform.engine.UniqueId)1