Search in sources :

Example 16 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData 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)

Example 17 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class PropertyReadHelper method analyzeTraceFiles.

private void analyzeTraceFiles(final ChangeProperty property, final File traceFileCurrent, final File traceFileOld) throws IOException, FileNotFoundException {
    final PeassFolders folders = new PeassFolders(projectFolder);
    final Map<ChangedEntity, ClazzChangeData> changes = getChanges(folders);
    final List<String> traceCurrent = Sequitur.getExpandedTrace(traceFileCurrent);
    final List<String> traceOld = Sequitur.getExpandedTrace(traceFileOld);
    determineTraceSizeChanges(property, traceCurrent, traceOld);
    final Set<String> merged = getMergedCalls(traceCurrent, traceOld);
    readMethodSources(property, folders, merged);
    identifyAffectedClasses(property, merged);
    LOG.info("Calls: " + merged);
    getTestSourceAffection(property, merged, folders, changes);
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) PeassFolders(de.dagere.peass.folders.PeassFolders)

Example 18 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class ChangeManager method compareClazz.

private void compareClazz(final Map<ChangedEntity, ClazzChangeData> changedClassesMethods, final Iterator<ChangedEntity> clazzIterator) {
    final ChangedEntity clazz = clazzIterator.next();
    final ClazzChangeData changeData = new ClazzChangeData(clazz);
    try {
        ClazzFileFinder finder = new ClazzFileFinder(config);
        final File newFile = finder.getSourceFile(folders.getProjectFolder(), clazz);
        final File oldFile = finder.getSourceFile(folders.getOldSources(), clazz);
        LOG.info("Vergleiche {}", newFile, oldFile);
        if (newFile != null && newFile.exists() && oldFile != null) {
            compareFiles(changedClassesMethods, clazzIterator, clazz, changeData, newFile, oldFile);
        } else {
            LOG.info("Class did not exist before: {}", clazz);
            changeData.addClazzChange(clazz);
            changedClassesMethods.put(clazz, changeData);
        }
    } catch (final ParseException | NoSuchElementException pe) {
        LOG.info("Class is unparsable for java parser, so to be sure it is added to the changed classes: {}", clazz);
        changeData.addClazzChange(clazz);
        changedClassesMethods.put(clazz, changeData);
        pe.printStackTrace();
    } catch (final IOException e) {
        LOG.info("Class is unparsable for java parser, so to be sure it is added to the changed classes: {}", clazz);
        changeData.addClazzChange(clazz);
        changedClassesMethods.put(clazz, changeData);
        e.printStackTrace();
    }
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) ParseException(com.github.javaparser.ParseException) IOException(java.io.IOException) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException)

Example 19 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class DependencyDetectorIT method testTestChange.

@Test
public void testTestChange() throws Exception {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "changed_test");
    final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
    DependencyDetectorTestUtil.addChange(changes, "", "defaultpackage.TestMe", "testMe");
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    System.out.println(reader.getDependencies().getVersions().get(DependencyTestConstants.VERSION_1));
    DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.TestMe#testMe", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) TreeMap(java.util.TreeMap) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 20 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class DependencyDetectorIT method testNoChange.

@Test
public void testNoChange() throws Exception {
    final Map<ChangedEntity, ClazzChangeData> changes = new HashMap<>();
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(DependencyTestConstants.BASIC_STATE));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    StaticTestSelection dependencies = reader.getDependencies();
    System.out.println(dependencies.getVersions());
    Assert.assertTrue(dependencies.getVersions().get(dependencies.getNewestVersion()).isRunning());
// DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) HashMap(java.util.HashMap) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Aggregations

ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)42 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)41 Test (org.junit.jupiter.api.Test)26 File (java.io.File)25 ChangeManager (de.dagere.peass.dependency.ChangeManager)17 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)10 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)10 VersionIterator (de.dagere.peass.vcs.VersionIterator)9 TreeMap (java.util.TreeMap)9 HashMap (java.util.HashMap)7 PeassFolders (de.dagere.peass.folders.PeassFolders)5 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)4 KiekerConfig (de.dagere.peass.config.KiekerConfig)4 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)4 ChangeTestMapping (de.dagere.peass.dependency.analysis.data.ChangeTestMapping)3 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)3 Map (java.util.Map)3 Set (java.util.Set)3 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)2 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)2