Search in sources :

Example 11 with StaticTestSelection

use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.

the class TestMerging method testAlphabetic.

@Test
public void testAlphabetic() {
    List<GitCommit> commits = new LinkedList<>();
    commits.add(new GitCommit("A", "", "", ""));
    commits.add(new GitCommit("C", "", "", ""));
    commits.add(new GitCommit("B", "", "", ""));
    commits.add(new GitCommit("G", "", "", ""));
    commits.add(new GitCommit("E", "", "", ""));
    commits.add(new GitCommit("F", "", "", ""));
    VersionComparator.setVersions(commits);
    StaticTestSelection deps1 = new StaticTestSelection(), deps2 = new StaticTestSelection();
    deps1.setInitialversion(new InitialVersion());
    deps1.getInitialversion().setVersion("A");
    deps1.getVersions().put("C", null);
    deps1.getVersions().put("B", null);
    deps1.getVersions().put("G", null);
    deps2.setInitialversion(new InitialVersion());
    deps2.getInitialversion().setVersion("G");
    deps2.getVersions().put("E", null);
    deps2.getVersions().put("F", null);
    StaticTestSelection merged = DependencyReaderUtil.mergeDependencies(deps1, deps2);
    System.out.println(merged.getVersions().keySet());
    Assert.assertEquals(5, merged.getVersions().size());
}
Also used : GitCommit(de.dagere.peass.vcs.GitCommit) InitialVersion(de.dagere.peass.dependency.persistence.InitialVersion) LinkedList(java.util.LinkedList) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Example 12 with StaticTestSelection

use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.

the class TestVersionSplitting method testSplitting.

@Test
public void testSplitting() throws IOException {
    List<GitCommit> commits = ParallelTestUtil.getCommits();
    int count = 3;
    int size = commits.size() > 2 * count ? commits.size() / count : 2;
    List<StaticTestSelection> dependencies = new LinkedList<>();
    for (int chunk = 0; chunk < count; chunk++) {
        // Assuming one in three commits should contain a source-change
        final int max = Math.min((chunk + 1) * size + 3, commits.size());
        readUntilMax(commits, dependencies, chunk, chunk * size, max);
    }
    StaticTestSelection merged = PartialDependenciesMerger.mergeDependencies(dependencies);
    System.out.println(merged.getVersions().keySet());
    Assert.assertEquals(7, merged.getVersions().size());
}
Also used : GitCommit(de.dagere.peass.vcs.GitCommit) LinkedList(java.util.LinkedList) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Example 13 with StaticTestSelection

use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.

the class TestVersionSplitting method testSplittingNonRunning.

@Test
public void testSplittingNonRunning() throws IOException {
    List<GitCommit> commits = ParallelTestUtil.getCommits();
    int count = 3;
    int size = commits.size() > 2 * count ? commits.size() / count : 2;
    for (int i = 1; i < 10; i++) {
        for (int j = i + 1; j < 10; j++) {
            DummyReader.nonRunning = new HashSet<>(Arrays.asList(String.valueOf(i), String.valueOf(j)));
            List<StaticTestSelection> dependencies = new LinkedList<>();
            for (int chunk = 0; chunk < count; chunk++) {
                // Assuming one in three commits should contain a source-change
                final int max = Math.min((chunk + 1) * size + 3, commits.size());
                readUntilMax(commits, dependencies, chunk, chunk * size, max);
            }
            StaticTestSelection merged = PartialDependenciesMerger.mergeDependencies(dependencies);
            System.out.println(merged.getVersions().keySet() + " " + merged.getVersions().size());
            Assert.assertEquals("Error in " + DummyReader.nonRunning, 7, merged.getVersions().size());
        }
    }
}
Also used : GitCommit(de.dagere.peass.vcs.GitCommit) LinkedList(java.util.LinkedList) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Example 14 with StaticTestSelection

use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.

the class CleaningStarter method getVersionOrder.

private void getVersionOrder() throws IOException, StreamReadException, DatabindException {
    StaticTestSelection dependencies = null;
    if (dependencyFile != null) {
        dependencies = Constants.OBJECTMAPPER.readValue(dependencyFile, StaticTestSelection.class);
        VersionComparator.setDependencies(dependencies);
    }
    if (executionfile != null) {
        ExecutionData executionData = Constants.OBJECTMAPPER.readValue(executionfile, ExecutionData.class);
        dependencies = new StaticTestSelection(executionData);
        VersionComparator.setDependencies(dependencies);
    }
    if (dependencies == null) {
        throw new RuntimeException("Dependencyfile and executionfile not readable - one needs to be defined!");
    }
}
Also used : StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 15 with StaticTestSelection

use of de.dagere.peass.dependency.persistence.StaticTestSelection 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)

Aggregations

StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)56 File (java.io.File)24 Test (org.junit.jupiter.api.Test)22 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)14 PeassFolders (de.dagere.peass.folders.PeassFolders)14 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)12 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)12 LinkedList (java.util.LinkedList)9 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)8 KiekerConfig (de.dagere.peass.config.KiekerConfig)7 InitialVersion (de.dagere.peass.dependency.persistence.InitialVersion)7 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)7 VersionIteratorGit (de.dagere.peass.vcs.VersionIteratorGit)7 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)6 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)6 GitCommit (de.dagere.peass.vcs.GitCommit)6 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)5 ResultsFolders (de.dagere.peass.folders.ResultsFolders)5 GitUtils (de.dagere.peass.vcs.GitUtils)5 ChangeManager (de.dagere.peass.dependency.ChangeManager)4