Search in sources :

Example 41 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class TraceChangeHandler method addAddedTests.

public void addAddedTests(final VersionStaticSelection newVersionInfo, final TestSet testsToRun) {
    for (final ChangedEntity testName : newVersionInfo.getChangedClazzes().keySet()) {
        ChangedEntity simplyClazz = testName.getSourceContainingClazz();
        TestCase potentialTest = new TestCase(simplyClazz.getClazz(), null, testName.getModule());
        if (NonIncludedTestRemover.isTestClassIncluded(potentialTest, executionConfig)) {
            testsToRun.addTest(potentialTest, null);
        }
    }
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 42 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyStatisticAnalyzer method getChangeStatistics.

public static DependencyStatistics getChangeStatistics(final File dependenciesFile, final ExecutionData changedTests) throws JAXBException, JsonParseException, JsonMappingException, IOException {
    final StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(dependenciesFile, StaticTestSelection.class);
    final Map<String, VersionStaticSelection> versions = dependencies.getVersions();
    final int startTestCound = dependencies.getInitialversion().getInitialDependencies().size();
    final List<TestCase> currentContainedTests = new LinkedList<>();
    for (final TestCase dependency : dependencies.getInitialversion().getInitialDependencies().keySet()) {
        currentContainedTests.add(dependency);
    }
    LOG.trace("StartTest: {}", startTestCound);
    // final List<TestCase> sometimesChangedTest = new LinkedList<>(); // Nicht nur Vorkommen, auch Anzahl relevant
    final DependencyStatistics statistics = new DependencyStatistics();
    // final List<TestCase> onlyOnceChangedTests = new LinkedList<>();
    statistics.onceChangedTests.addAll(currentContainedTests);
    statistics.size = versions.size();
    // final int pruningRunTests = 0;
    for (final Entry<String, VersionStaticSelection> version : versions.entrySet()) {
        final Set<TestCase> currentIterationTests = new HashSet<>();
        for (final Map.Entry<ChangedEntity, TestSet> dependency : version.getValue().getChangedClazzes().entrySet()) {
            for (final Entry<TestCase, Set<String>> testcase : dependency.getValue().getTestcases().entrySet()) {
                final String testclass = testcase.getKey().getClazz();
                for (final String method : testcase.getValue()) {
                    final TestCase testcase2 = new TestCase(testclass, method);
                    // final String testname = testclass + "." + method;
                    if (currentContainedTests.contains(testcase2)) {
                        currentIterationTests.add(testcase2);
                    } else {
                        currentContainedTests.add(testcase2);
                        statistics.onceChangedTests.add(testcase2);
                    // LOG.info("Neuer Test: " + testname);
                    }
                }
            }
        }
        int currentTraceChangedTests = 0;
        if (changedTests != null) {
            for (final TestCase currentIterationTest : currentContainedTests) {
                if (changedTests.versionContainsTest(version.getKey(), currentIterationTest)) {
                    currentTraceChangedTests++;
                }
            }
        }
        LOG.trace("Version: {} Tests: {} Trace-Changed: {}", version.getKey(), currentIterationTests.size(), currentTraceChangedTests);
        statistics.multipleChangedTest.addAll(currentIterationTests);
        statistics.onceChangedTests.removeAll(currentIterationTests);
        statistics.changedTraceTests += currentTraceChangedTests;
        statistics.pruningRunTests += currentIterationTests.size();
        statistics.overallRunTests += currentContainedTests.size();
    }
    return statistics;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) LinkedList(java.util.LinkedList) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) Map(java.util.Map) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) HashSet(java.util.HashSet) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 43 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class ChangedEntityDeserializer method deserializeKey.

@Override
public ChangedEntity deserializeKey(final String key, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
    String value = key;
    final ChangedEntity entity;
    String method = null;
    if (value.contains(ChangedEntity.METHOD_SEPARATOR)) {
        method = value.substring(value.indexOf(ChangedEntity.METHOD_SEPARATOR) + 1);
        value = value.substring(0, value.indexOf(ChangedEntity.METHOD_SEPARATOR));
    }
    if (value.contains(ChangedEntity.MODULE_SEPARATOR)) {
        final String clazz = value.substring(value.indexOf(ChangedEntity.MODULE_SEPARATOR) + 1);
        final String module = value.substring(0, value.indexOf(ChangedEntity.MODULE_SEPARATOR));
        entity = new ChangedEntity(clazz, module, method);
    } else {
        entity = new ChangedEntity(value, "", method);
    }
    return entity;
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 44 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class ClazzChangeData method getUniqueChanges.

@JsonIgnore
public Set<ChangedEntity> getUniqueChanges() {
    Set<ChangedEntity> entities = new HashSet<>();
    for (Map.Entry<String, Set<String>> change : changedMethods.entrySet()) {
        String fullQualifiedClassname = getFQN(change.getKey());
        if (isOnlyMethodChange) {
            for (String method : change.getValue()) {
                ChangedEntity entitity = new ChangedEntity(fullQualifiedClassname, containingFile.getModule(), method);
                entities.add(entitity);
            }
        } else {
            ChangedEntity entitity = new ChangedEntity(fullQualifiedClassname, containingFile.getModule());
            entities.add(entitity);
        }
    }
    return entities;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 45 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class ClazzFinder method findClazz.

public static TypeDeclaration<?> findClazz(final ChangedEntity entity, final List<Node> nodes) {
    TypeDeclaration<?> declaration = null;
    for (final Node node : nodes) {
        if (node instanceof TypeDeclaration<?>) {
            final TypeDeclaration<?> temp = (TypeDeclaration<?>) node;
            final String nameAsString = temp.getNameAsString();
            if (nameAsString.equals(entity.getSimpleClazzName())) {
                declaration = (ClassOrInterfaceDeclaration) node;
                break;
            } else {
                if (entity.getSimpleClazzName().startsWith(nameAsString + ChangedEntity.CLAZZ_SEPARATOR)) {
                    ChangedEntity inner = new ChangedEntity(entity.getSimpleClazzName().substring(nameAsString.length() + 1), entity.getModule());
                    declaration = findClazz(inner, node.getChildNodes());
                }
            }
        }
    }
    return declaration;
}
Also used : Node(com.github.javaparser.ast.Node) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) TypeDeclaration(com.github.javaparser.ast.body.TypeDeclaration)

Aggregations

ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)138 Test (org.junit.jupiter.api.Test)58 File (java.io.File)57 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)41 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)25 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)21 ChangeManager (de.dagere.peass.dependency.ChangeManager)18 Set (java.util.Set)17 HashSet (java.util.HashSet)16 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)14 HashMap (java.util.HashMap)14 Map (java.util.Map)13 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)11 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)11 VersionIterator (de.dagere.peass.vcs.VersionIterator)10 TreeMap (java.util.TreeMap)9 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)8 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)6 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)6 LinkedList (java.util.LinkedList)6