Search in sources :

Example 16 with FakeFileIterator

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;
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) VersionDiff(de.dagere.peass.dependency.analysis.data.VersionDiff) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) File(java.io.File)

Example 17 with FakeFileIterator

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);
    }
}
Also used : TestSelectionConfig(de.dagere.peass.config.TestSelectionConfig) VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.jupiter.api.Test)

Example 18 with FakeFileIterator

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;
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) VersionDiff(de.dagere.peass.dependency.analysis.data.VersionDiff) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) File(java.io.File)

Example 19 with FakeFileIterator

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);
    }
}
Also used : TestSelectionConfig(de.dagere.peass.config.TestSelectionConfig) VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) PeassFolders(de.dagere.peass.folders.PeassFolders) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 20 with FakeFileIterator

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

Aggregations

FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)30 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)27 Test (org.junit.jupiter.api.Test)25 ChangeManager (de.dagere.peass.dependency.ChangeManager)23 VersionIterator (de.dagere.peass.vcs.VersionIterator)23 File (java.io.File)19 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)13 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)11 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)10 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)8 PeassFolders (de.dagere.peass.folders.PeassFolders)8 KiekerConfig (de.dagere.peass.config.KiekerConfig)7 TreeMap (java.util.TreeMap)7 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)5 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)4 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)4 ResultsFolders (de.dagere.peass.folders.ResultsFolders)4 GitUtils (de.dagere.peass.vcs.GitUtils)4 TestSelectionConfig (de.dagere.peass.config.TestSelectionConfig)3 VersionDiff (de.dagere.peass.dependency.analysis.data.VersionDiff)3