use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class JmhDependencyReaderMultiParamTest method mockIterator.
private FakeFileIterator mockIterator() {
List<File> versionList = Arrays.asList(JmhTestConstants.MULTIPARAM_VERSION, JmhTestConstants.MULTIPARAM_VERSION_CHANGE);
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/de/dagere/peass/ExampleBenchmark.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 JmhDependencyReaderMultiParamTest method testVersionReading.
@Test
public void testVersionReading() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
FakeGitUtil.prepareGitUtils(gitUtilsMock);
FakeFileIterator iterator = mockIterator();
ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
ExecutionConfig jmhConfig = new ExecutionConfig();
jmhConfig.setTestTransformer("de.dagere.peass.dependency.jmh.JmhTestTransformer");
jmhConfig.setTestExecutor("de.dagere.peass.dependency.jmh.JmhTestExecutor");
DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, new VersionKeeper(new File("/dev/null")), jmhConfig, new KiekerConfig(true), new EnvironmentVariables());
reader.readInitialVersion();
checkInitialVersion(resultsFolders);
reader.readDependencies();
checkChangedVersion(resultsFolders);
}
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class JmhDependencyReaderTest method mockIterator.
private FakeFileIterator mockIterator() {
List<File> versionList = Arrays.asList(JmhTestConstants.BASIC_VERSION, JmhTestConstants.SLOWER_VERSION);
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/de/dagere/peass/ExampleBenchmark.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 JmhDependencyReaderTest method testVersionReading.
@ParameterizedTest
@ArgumentsSource(KiekerConfigurationProvider.class)
public void testVersionReading(final KiekerConfig kiekerConfig) throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
FakeGitUtil.prepareGitUtils(gitUtilsMock);
FakeFileIterator iterator = mockIterator();
ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
ExecutionConfig jmhConfig = new ExecutionConfig();
jmhConfig.setTestTransformer("de.dagere.peass.dependency.jmh.JmhTestTransformer");
jmhConfig.setTestExecutor("de.dagere.peass.dependency.jmh.JmhTestExecutor");
DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, new VersionKeeper(new File("/dev/null")), jmhConfig, kiekerConfig, new EnvironmentVariables());
reader.readInitialVersion();
checkInitialVersion(resultsFolders);
reader.readDependencies();
checkChangedVersion(resultsFolders);
}
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator 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);
}
Aggregations