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;
}
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);
}
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();
}
}
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);
}
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);
}
Aggregations