use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorMultimoduleIT method testNormalChange.
// This test is disabled since it takes too long and nearly tests the same as testTwoChanges; however, since it enables easier debugging, it is left in the code
@Disabled
@Test
public void testNormalChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
final File secondVersion = new File(VERSIONS_FOLDER, "normal_change");
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("base-module", "de.dagere.base.BaseChangeable", "doSomething");
ChangeManager changeManager = Mockito.mock(ChangeManager.class);
Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(DependencyTestConstants.CURRENT), DependencyTestConstants.NULL_RESULTS_FOLDERS, null, fakeIterator, changeManager, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
final boolean success = reader.readInitialVersion();
Assert.assertTrue(success);
StaticTestSelection dependencies = reader.getDependencies();
checkInitialVersion(dependencies);
fakeIterator.goToNextCommit();
reader.analyseVersion(changeManager);
testFirstChange(dependencies);
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorNoUpdateIT method testClassRemoval.
@Test
public void testClassRemoval() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "removed_class");
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
final ChangedEntity changedEntity = new ChangedEntity("defaultpackage.TestMe", "");
changes.put(changedEntity, new ClazzChangeData(changedEntity, false));
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);
DependencyDetectorIT.checkClassRemoved(reader);
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyViewGeneratorTest method testTwoVersions.
@Test
public void testTwoVersions() throws Exception {
try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
FakeGitUtil.prepareGitUtils(gitUtilsMock);
DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
FakeFileIterator iteratorspied = mockIterator();
DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iteratorspied, new VersionKeeper(new File("/dev/null")), new ExecutionConfig(), new KiekerConfig(true), new EnvironmentVariables());
reader.readInitialVersion();
try {
reader.readDependencies();
} catch (Throwable t) {
System.out.println();
for (StackTraceElement te : t.getStackTrace()) {
System.out.println(te);
}
System.out.println();
throw t;
}
File expectedDiff = new File(resultsFolders.getVersionDiffFolder("000002"), "TestMe#test.txt");
System.out.println(expectedDiff.getAbsolutePath());
Assert.assertTrue(expectedDiff.exists());
// TODO Test, that instrumentation sources are not added to the view
final ExecutionData tests = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
//
Assert.assertEquals(2, tests.getVersions().size());
Assert.assertEquals(1, tests.getVersions().get("000002").getTests().size());
}
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyViewGeneratorTest method mockIterator.
private FakeFileIterator mockIterator() {
List<File> versionList = Arrays.asList(TraceGettingIT.BASIC, TraceGettingIT.REPETITION);
FakeFileIterator fakeIterator = new FakeFileIterator(TestConstants.CURRENT_FOLDER, versionList);
fakeIterator.goToFirstCommit();
FakeFileIterator iteratorspied = Mockito.spy(fakeIterator);
VersionDiff fakedDiff = new VersionDiff(Arrays.asList(TestConstants.CURRENT_FOLDER), TestConstants.CURRENT_FOLDER);
ExecutionConfig defaultConfig = new ExecutionConfig();
fakedDiff.addChange("src/test/java/viewtest/TestMe.java", defaultConfig);
Mockito.doReturn(fakedDiff).when(iteratorspied).getChangedClasses(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
return iteratorspied;
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class SuperclassDetectorIT method testSuperclassChange.
@Test
public void testSuperclassChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
final File secondVersion = new File(VERSIONS_FOLDER, "superclass_changed");
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
changes.put(new ChangedEntity("defaultpackage.NormalSuperclass", ""), new ClazzChangeData("defaultpackage.NormalSuperclass", false));
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 = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(DependencyTestConstants.CURRENT), DependencyTestConstants.NULL_RESULTS_FOLDERS, null, fakeIterator, changeManager, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
reader.readInitialVersion();
checkInitialDependencies(reader);
fakeIterator.goToNextCommit();
reader.analyseVersion(changeManager);
checkFirstVersionDependencies(reader);
}
Aggregations