Search in sources :

Example 1 with CalledMethods

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

the class DependencyManager method findAddedTests.

/**
 * A method is unknown if a class-wide change happened, e.g. if a new subclass is declared and because of this change a new testcase needs to be called.
 *
 * @param oldDepdendencies
 * @param changes
 */
private void findAddedTests(final Map<TestCase, Map<ChangedEntity, Set<String>>> oldDepdendencies, final TestExistenceChanges changes) {
    for (final Map.Entry<TestCase, CalledMethods> newDependency : dependencies.getDependencyMap().entrySet()) {
        // testclass -> depending class -> method
        final TestCase testcase = newDependency.getKey();
        if (!oldDepdendencies.containsKey(testcase)) {
            changes.addAddedTest(testcase.onlyClazzEntity(), testcase);
            for (final Map.Entry<ChangedEntity, Set<String>> newCallees : newDependency.getValue().getCalledMethods().entrySet()) {
                final ChangedEntity changedclass = newCallees.getKey();
                for (final String changedMethod : newCallees.getValue()) {
                    // Since the testcase is new, is is always caused
                    // primarily by a change of the test class, and not of
                    // any other changed class
                    final ChangedEntity methodEntity = changedclass.copy();
                    methodEntity.setMethod(changedMethod);
                    changes.addAddedTest(methodEntity, testcase);
                }
            }
        }
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) CalledMethods(de.dagere.peass.dependency.analysis.data.CalledMethods) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with CalledMethods

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

the class InitialVersionReader method createInitialVersion.

private InitialVersion createInitialVersion() {
    int jdkversion = dependencyManager.getExecutor().getJDKVersion();
    final InitialVersion initialversion = new InitialVersion();
    initialversion.setVersion(iterator.getTag());
    initialversion.setJdk(jdkversion);
    LOG.debug("Starting writing: {}", dependencyMap.getDependencyMap().size());
    for (final Entry<TestCase, CalledMethods> dependencyEntry : dependencyMap.getDependencyMap().entrySet()) {
        final TestCase testcase = dependencyEntry.getKey();
        for (final Map.Entry<ChangedEntity, Set<String>> calledClassEntry : dependencyEntry.getValue().getCalledMethods().entrySet()) {
            final ChangedEntity dependentclass = calledClassEntry.getKey();
            if (!dependentclass.getJavaClazzName().contains("junit") && !dependentclass.getJavaClazzName().contains("log4j")) {
                for (final String dependentmethod : calledClassEntry.getValue()) {
                    final ChangedEntity callee = new ChangedEntity(dependentclass.getClazz(), dependentclass.getModule(), dependentmethod);
                    initialversion.addDependency(testcase, callee);
                }
            }
        }
        initialversion.sort(testcase);
    }
    return initialversion;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) CalledMethods(de.dagere.peass.dependency.analysis.data.CalledMethods) InitialVersion(de.dagere.peass.dependency.persistence.InitialVersion) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

CalledMethods (de.dagere.peass.dependency.analysis.data.CalledMethods)2 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)2 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)2 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)2 Map (java.util.Map)2 Set (java.util.Set)2 InitialVersion (de.dagere.peass.dependency.persistence.InitialVersion)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 TreeSet (java.util.TreeSet)1