Search in sources :

Example 51 with ChangedEntity

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

the class SourceWriter method readMethod.

private void readMethod(final GraphNode node, final String currentPattern) throws IOException {
    ChangedEntity methodEntity = getChangedEntity(node, currentPattern);
    final String key = KiekerPatternConverter.getKey(currentPattern);
    final File currentSourceFile = MethodChangeReader.getMethodMainFile(methodSourceFolder, version, methodEntity);
    final File oldSourceFile = MethodChangeReader.getMethodOldFile(methodSourceFolder, version, methodEntity);
    if (currentSourceFile.exists() && oldSourceFile.exists()) {
        node.setHasSourceChange(true);
        final String sourceCurrent = FileUtils.readFileToString(currentSourceFile, Charset.defaultCharset());
        nameSourceCurrent.put(key, sourceCurrent);
        final String sourceOld = FileUtils.readFileToString(oldSourceFile, Charset.defaultCharset());
        nameSourceOld.put(key, sourceOld);
    } else {
        final File diffSourceFile = MethodChangeReader.getMethodDiffFile(methodSourceFolder, version, methodEntity);
        if (diffSourceFile.exists()) {
            final String source = FileUtils.readFileToString(diffSourceFile, Charset.defaultCharset());
            nameSourceCurrent.put(key, source);
            nameSourceOld.put(key, source);
        } else {
            LOG.warn("Did not find file: {}", diffSourceFile);
        }
    }
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File)

Example 52 with ChangedEntity

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

the class SourceWriter method getChangedEntity.

private ChangedEntity getChangedEntity(final GraphNode node, final String currentPattern) {
    int openingParenthesis = currentPattern.lastIndexOf('(');
    final String call = currentPattern.substring(currentPattern.lastIndexOf(' ') + 1, openingParenthesis);
    final int dotIndex = call.lastIndexOf(".");
    String method = call.substring(dotIndex + 1);
    String clazz = call.substring(0, dotIndex);
    ChangedEntity methodEntity = new ChangedEntity(clazz, node.getModule(), method);
    final String parameterString = currentPattern.substring(openingParenthesis + 1, currentPattern.length() - 1);
    methodEntity.createParameters(parameterString);
    return methodEntity;
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 53 with ChangedEntity

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

the class ChangeManager method compareFiles.

private void compareFiles(final Map<ChangedEntity, ClazzChangeData> changedClassesMethods, final Iterator<ChangedEntity> clazzIterator, final ChangedEntity clazz, final ClazzChangeData changeData, final File newFile, final File oldFile) throws ParseException, IOException {
    FileComparisonUtil.getChangedMethods(newFile, oldFile, changeData);
    boolean isImportChange = false;
    ClazzFileFinder finder = new ClazzFileFinder(config);
    for (ChangedEntity entity : changeData.getImportChanges()) {
        final File entityFile = finder.getSourceFile(folders.getProjectFolder(), entity);
        if (entityFile != null && entityFile.exists()) {
            isImportChange = true;
            changeData.setChange(true);
            changeData.setOnlyMethodChange(false);
            changeData.addClazzChange(clazz);
        }
    }
    if (!changeData.isChange() && !isImportChange) {
        clazzIterator.remove();
        LOG.debug("Dateien gleich: {}", clazz);
    } else {
        changedClassesMethods.put(clazz, changeData);
    }
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File)

Example 54 with ChangedEntity

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

the class ClazzFileFinder method getSourceFile.

public File getSourceFile(final File folder, final ChangedEntity clazz) {
    final ChangedEntity sourceContainingClazz = clazz.getSourceContainingClazz();
    File moduleFolder;
    if (sourceContainingClazz.getModule().length() > 0) {
        moduleFolder = new File(folder, sourceContainingClazz.getModule());
        LOG.debug("Module: {}", sourceContainingClazz.getModule());
    } else {
        moduleFolder = folder;
    }
    return getClazzFile(moduleFolder, sourceContainingClazz);
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File)

Example 55 with ChangedEntity

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

the class PropertyReadHelper method getChanges.

private Map<ChangedEntity, ClazzChangeData> getChanges(final PeassFolders folders) {
    GitCommit firstCommit = new GitCommit(versionOld, null, null, null);
    List<GitCommit> commits = Arrays.asList(new GitCommit[] { new GitCommit(version, null, null, null), firstCommit });
    final VersionIteratorGit iterator = new VersionIteratorGit(projectFolder, commits, firstCommit);
    final ChangeManager changeManager = new ChangeManager(folders, iterator, config, testExecutor);
    final Map<ChangedEntity, ClazzChangeData> changes = changeManager.getChanges(versionOld, version);
    return changes;
}
Also used : VersionIteratorGit(de.dagere.peass.vcs.VersionIteratorGit) ChangeManager(de.dagere.peass.dependency.ChangeManager) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) GitCommit(de.dagere.peass.vcs.GitCommit) 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