Search in sources :

Example 1 with VersionIterator

use of de.dagere.peass.vcs.VersionIterator in project peass by DaGeRe.

the class TestVersionSplitting method readDummyDependencies.

private void readDummyDependencies(final List<StaticTestSelection> dependencies, final int i, final List<GitCommit> currentCommits, final List<GitCommit> reserveCommits, final GitCommit minimumCommit) throws IOException {
    File dummyFolder = new File(TestConstants.CURRENT_FOLDER, "part_" + i);
    dummyFolder.mkdir();
    File pom = new File(dummyFolder, "pom.xml");
    try (BufferedWriter newBufferedWriter = Files.newBufferedWriter(pom.toPath())) {
        newBufferedWriter.write("<project></project>");
    }
    final VersionIterator fakeIterator = new FakeVersionIterator(dummyFolder, currentCommits);
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(null);
    FirstRunningVersionFinder finder = new FirstRunningVersionFinder(null, null, null, null, null) {

        @Override
        public boolean searchFirstRunningCommit() {
            return true;
        }
    };
    DummyReader dummy = new DummyReader(dummyFolder, fakeIterator, changeManager);
    System.out.println(minimumCommit.getTag());
    final VersionIterator reserveIterator = new FakeVersionIterator(dummyFolder, reserveCommits);
    OneReader reader = new OneReader(minimumCommit, reserveIterator, dummy, finder);
    reader.run();
    dependencies.add(dummy.getDependencies());
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FirstRunningVersionFinder(de.dagere.peass.dependency.reader.FirstRunningVersionFinder) OneReader(de.dagere.peass.dependency.parallel.OneReader) FakeVersionIterator(de.dagere.peass.dependencytests.helper.FakeVersionIterator) VersionIterator(de.dagere.peass.vcs.VersionIterator) FakeVersionIterator(de.dagere.peass.dependencytests.helper.FakeVersionIterator) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 2 with VersionIterator

use of de.dagere.peass.vcs.VersionIterator in project peass by DaGeRe.

the class DependencyDetectorIT method testClassRemoval.

@Test
public void testClassRemoval() throws Exception {
    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);
    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 3 with VersionIterator

use of de.dagere.peass.vcs.VersionIterator in project peass by DaGeRe.

the class DependencyDetectorIT method testClassChange.

@Test
public void testClassChange() throws Exception {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "changed_class");
    final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
    changes.put(new ChangedEntity("defaultpackage.NormalDependency", ""), new ClazzChangeData("defaultpackage.NormalDependency", 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());
    final boolean success = reader.readInitialVersion();
    Assert.assertTrue(success);
    final StaticTestSelection dependencies = reader.getDependencies();
    System.out.println(dependencies);
    fakeIterator.goToNextCommit();
    reader.analyseVersion(changeManager);
    final TestSet testMe = DependencyDetectorTestUtil.findDependency(dependencies, "defaultpackage.NormalDependency", DependencyTestConstants.VERSION_1);
    System.out.println(testMe);
    final ChangedEntity change = dependencies.getVersions().get(DependencyTestConstants.VERSION_1).getChangedClazzes().keySet().iterator().next();
    Assert.assertEquals("defaultpackage.NormalDependency", change.toString());
    Assert.assertEquals("defaultpackage.TestMe#testMe", testMe.getTests().iterator().next().getExecutable());
}
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) TreeMap(java.util.TreeMap) 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) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 4 with VersionIterator

use of de.dagere.peass.vcs.VersionIterator in project peass by DaGeRe.

the class DependencyDetectorIT method testAddedClass.

@Test
public void testAddedClass() throws Exception {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "added_class");
    final ChangeManager changeManager = DependencyDetectorTestUtil.mockAddedChangeManager();
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    System.out.println(reader.getDependencies());
    DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.TestMeAlso", "defaultpackage.TestMeAlso", DependencyTestConstants.VERSION_1);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with VersionIterator

use of de.dagere.peass.vcs.VersionIterator in project peass by DaGeRe.

the class DependencyDetectorITGradle method testNormalChange.

// @org.junit.After
// public void cleanAfterwards() throws IOException {
// FileUtils.deleteDirectory(CURRENT);
// // be aware: maven does not compile if a .class-file is still in the resources, since it gets identified as test
// }
@Test
public void testNormalChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    init(BASIC_STATE);
    final ChangeManager changeManager = DependencyDetectorTestUtil.defaultChangeManager();
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(CHANGE));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) Test(org.junit.jupiter.api.Test)

Aggregations

VersionIterator (de.dagere.peass.vcs.VersionIterator)27 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)24 ChangeManager (de.dagere.peass.dependency.ChangeManager)23 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)23 Test (org.junit.jupiter.api.Test)22 File (java.io.File)15 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)10 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)9 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)7 TreeMap (java.util.TreeMap)7 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)5 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)5 PeassFolders (de.dagere.peass.folders.PeassFolders)5 KiekerConfig (de.dagere.peass.config.KiekerConfig)4 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)4 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)4 OneReader (de.dagere.peass.dependency.parallel.OneReader)2 VersionIteratorGit (de.dagere.peass.vcs.VersionIteratorGit)2 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)1 FirstRunningVersionFinder (de.dagere.peass.dependency.reader.FirstRunningVersionFinder)1