Search in sources :

Example 46 with ChangedEntity

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

the class CoverageBasedSelector method getCallSum.

private static int getCallSum(final Set<ChangedEntity> changes, final TraceCallSummary summary) {
    summary.getSelectedChanges().clear();
    int currentCallSum = 0;
    LOG.debug("Changes: {} Test: {}", changes.size(), summary.getTestcase());
    LOG.debug("Trace Callcounts: {}", summary.getCallCounts().keySet());
    for (ChangedEntity change : changes) {
        String changeSignature = change.toString();
        LOG.debug("Change signature: " + changeSignature);
        if (change.getMethod() != null) {
            currentCallSum = addExactCallCount(summary, currentCallSum, changeSignature);
        } else {
            currentCallSum = addClassbasedCallCount(summary, currentCallSum, changeSignature);
        }
    }
    LOG.debug("Sum: " + currentCallSum);
    return currentCallSum;
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 47 with ChangedEntity

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

the class DependencyManager method removeNotExistingClazzes.

private void removeNotExistingClazzes(final Map<ChangedEntity, Set<String>> calledClasses) {
    for (final Iterator<ChangedEntity> iterator = calledClasses.keySet().iterator(); iterator.hasNext(); ) {
        final ChangedEntity entity = iterator.next();
        final String wholeClassName = entity.getJavaClazzName();
        // ignore inner class part, because it is in the same file - if the file exists, it is very likely that a subclass, which is in the logs, exists also
        final String outerClazzName = ClazzFileFinder.getOuterClass(wholeClassName);
        LOG.trace("Testing: " + outerClazzName);
        if (!executor.getExistingClasses().contains(outerClazzName)) {
            // Removes classes not in package
            iterator.remove();
        } else {
            LOG.trace("Existing: " + outerClazzName);
        }
    }
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 48 with ChangedEntity

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

the class DependencyManager method updateDependenciesOnce.

/**
 * Updates Dependencies of the given testClassName and the given testMethodName based upon the file where the kieker-results are stored
 *
 * @param testClassName
 * @param testMethodName
 * @param parent
 */
public void updateDependenciesOnce(final TestCase testcase, final File parent, final ModuleClassMapping mapping) {
    LOG.debug("Parent: " + parent);
    final File moduleResultsFolder = KiekerFolderUtil.getModuleResultFolder(folders, testcase);
    final File[] kiekerResultFolders = KiekerFolderUtil.getClazzMethodFolder(testcase, moduleResultsFolder);
    if (kiekerResultFolders == null) {
        LOG.error("No kieker folder found: " + parent);
        return;
    }
    final Map<ChangedEntity, Set<String>> allCalledClasses = getCalledMethods(mapping, kiekerResultFolders);
    removeNotExistingClazzes(allCalledClasses);
    for (final Iterator<ChangedEntity> iterator = allCalledClasses.keySet().iterator(); iterator.hasNext(); ) {
        final ChangedEntity clazz = iterator.next();
        if (clazz.getModule() == null) {
            throw new RuntimeException("Class " + clazz.getJavaClazzName() + " has no module!");
        }
    }
    LOG.debug("Test: {} ", testcase);
    LOG.debug("Dependencies: {}", allCalledClasses.size());
    dependencies.setDependencies(testcase, allCalledClasses);
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File)

Example 49 with ChangedEntity

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

the class CalledMethodLoader method loadMethods.

private Map<ChangedEntity, Set<String>> loadMethods() {
    Set<String> calledMethods = OneCallReader.getCalledMethods(kiekerTraceFolder);
    Map<ChangedEntity, Set<String>> calledMethodResult = new HashMap<>();
    for (String calledMethod : calledMethods) {
        LOG.debug("Adding called method: {}", calledMethod);
        ChangedEntity entity = EntityUtil.determineEntityWithDotSeparator(calledMethod);
        final String outerClazzName = ClazzFileFinder.getOuterClass(entity.getClazz());
        final String moduleOfClass = mapping.getModuleOfClass(outerClazzName);
        ChangedEntity fullClassEntity = new ChangedEntity(entity.getClazz(), moduleOfClass);
        Set<String> currentMethodSet = calledMethodResult.get(fullClassEntity);
        if (currentMethodSet == null) {
            currentMethodSet = new HashSet<>();
            calledMethodResult.put(fullClassEntity, currentMethodSet);
        }
        currentMethodSet.add(entity.getMethod() + entity.getParameterString());
    }
    return calledMethodResult;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 50 with ChangedEntity

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

the class CalledMethodLoader method readOneCallTrace.

private ArrayList<TraceElement> readOneCallTrace() {
    ArrayList<TraceElement> result = new ArrayList<>();
    Set<String> calledMethods = OneCallReader.getCalledMethods(kiekerTraceFolder);
    for (String calledMethod : calledMethods) {
        ChangedEntity entity = EntityUtil.determineEntityWithDotSeparator(calledMethod);
        final String outerClazzName = ClazzFileFinder.getOuterClass(entity.getClazz());
        final String moduleOfClass = mapping.getModuleOfClass(outerClazzName);
        TraceElement traceelement = new TraceElement(entity.getClazz(), entity.getMethod(), 0, moduleOfClass);
        if (calledMethod.contains(" static ")) {
            traceelement.setStatic(true);
        }
        traceelement.setParameterTypes(entity.getParameterTypes());
        result.add(traceelement);
    }
    return result;
}
Also used : TraceElement(de.dagere.peass.dependency.analysis.data.TraceElement) ArrayList(java.util.ArrayList) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

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