Search in sources :

Example 31 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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);
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) ChangeManager(de.dagere.peass.dependency.ChangeManager) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) VersionIterator(de.dagere.peass.vcs.VersionIterator) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 32 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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);
}
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 33 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader in project peass by DaGeRe.

the class DependencyDetectorOneCallWriterIT method readTwoVersions.

public static DependencyReader readTwoVersions(final ChangeManager changeManager, final VersionIterator fakeIterator, final ExecutionConfig config, final TestSelectionConfig dependencyConfig, final ResultsFolders resultsFolders) {
    try {
        KiekerConfig kiekerConfig = new KiekerConfig(true);
        kiekerConfig.setOnlyOneCallRecording(true);
        kiekerConfig.setUseSourceInstrumentation(false);
        final DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(DependencyTestConstants.CURRENT), resultsFolders, null, fakeIterator, changeManager, config, kiekerConfig, new EnvironmentVariables());
        boolean success = reader.readInitialVersion();
        Assert.assertTrue(success);
        fakeIterator.goToNextCommit();
        reader.analyseVersion(changeManager);
        return reader;
    } catch (IOException | InterruptedException | XmlPullParserException | ParseException | ViewNotFoundException e) {
        throw new RuntimeException(e);
    }
}
Also used : EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) ParseException(com.github.javaparser.ParseException) KiekerConfig(de.dagere.peass.config.KiekerConfig) ViewNotFoundException(de.dagere.peass.dependencyprocessors.ViewNotFoundException) PeassFolders(de.dagere.peass.folders.PeassFolders)

Example 34 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader in project peass by DaGeRe.

the class DependencyDetectorTestUtil method readTwoVersions.

public static DependencyReader readTwoVersions(final ChangeManager changeManager, final VersionIterator fakeIterator, final ExecutionConfig config, final TestSelectionConfig dependencyConfig, final ResultsFolders resultsFolders) {
    try {
        final DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(DependencyTestConstants.CURRENT), resultsFolders, null, fakeIterator, changeManager, config, new KiekerConfig(true), new EnvironmentVariables());
        boolean success = reader.readInitialVersion();
        Assert.assertTrue(success);
        fakeIterator.goToNextCommit();
        reader.analyseVersion(changeManager);
        return reader;
    } catch (IOException | InterruptedException | XmlPullParserException | ParseException | ViewNotFoundException e) {
        throw new RuntimeException(e);
    }
}
Also used : EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) ParseException(com.github.javaparser.ParseException) KiekerConfig(de.dagere.peass.config.KiekerConfig) ViewNotFoundException(de.dagere.peass.dependencyprocessors.ViewNotFoundException) PeassFolders(de.dagere.peass.folders.PeassFolders)

Example 35 with DependencyReader

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

Aggregations

DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)36 Test (org.junit.jupiter.api.Test)28 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)27 ChangeManager (de.dagere.peass.dependency.ChangeManager)26 VersionIterator (de.dagere.peass.vcs.VersionIterator)24 File (java.io.File)21 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)11 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)11 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)11 PeassFolders (de.dagere.peass.folders.PeassFolders)11 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)10 KiekerConfig (de.dagere.peass.config.KiekerConfig)9 TreeMap (java.util.TreeMap)7 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)6 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)5 VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)5 ResultsFolders (de.dagere.peass.folders.ResultsFolders)5 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)4 GitUtils (de.dagere.peass.vcs.GitUtils)4 TestSelectionConfig (de.dagere.peass.config.TestSelectionConfig)3