Search in sources :

Example 1 with DependencyReader

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

the class ContinuousDependencyReader method doPartialRCS.

private void doPartialRCS(final StaticTestSelection dependencies, final VersionIterator newIterator) {
    DependencyReader reader = new DependencyReader(dependencyConfig, folders, resultsFolders, dependencies.getUrl(), newIterator, new VersionKeeper(new File(resultsFolders.getStaticTestSelectionFile().getParentFile(), "nochanges.json")), executionConfig, kiekerConfig, env);
    newIterator.goTo0thCommit();
    reader.readCompletedVersions(dependencies);
    try {
        ExecutionData executions = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
        reader.setExecutionData(executions);
        if (resultsFolders.getCoverageSelectionFile().exists()) {
            ExecutionData coverageExecutions = Constants.OBJECTMAPPER.readValue(resultsFolders.getCoverageSelectionFile(), ExecutionData.class);
            reader.setCoverageExecutions(coverageExecutions);
            if (resultsFolders.getCoverageInfoFile().exists()) {
                CoverageSelectionInfo coverageInfo = Constants.OBJECTMAPPER.readValue(resultsFolders.getCoverageInfoFile(), CoverageSelectionInfo.class);
                reader.setCoverageInfo(coverageInfo);
            }
        }
        reader.readDependencies();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) IOException(java.io.IOException) File(java.io.File) CoverageSelectionInfo(de.dagere.peass.dependency.traces.coverage.CoverageSelectionInfo) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 2 with DependencyReader

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

the class ContinuousDependencyReader method doFullyLoadDependencies.

private StaticTestSelection doFullyLoadDependencies(final String url, final VersionIterator iterator, final VersionKeeper nonChanges) throws IOException, InterruptedException, XmlPullParserException, JsonParseException, JsonMappingException, ParseException, ViewNotFoundException {
    final DependencyReader reader = new DependencyReader(dependencyConfig, folders, resultsFolders, url, iterator, nonChanges, executionConfig, kiekerConfig, env);
    iterator.goToPreviousCommit();
    if (!reader.readInitialVersion()) {
        LOG.error("Analyzing first version was not possible");
    } else {
        reader.readDependencies();
    }
    StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(resultsFolders.getStaticTestSelectionFile(), StaticTestSelection.class);
    return dependencies;
}
Also used : DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Example 3 with DependencyReader

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

the class TestGenerateDependencies method testGenerateDependencies.

@Test
public void testGenerateDependencies() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
    final FakeFileIterator iterator = new FakeFileIterator(TestConstants.CURRENT_FOLDER, Arrays.asList(TraceGettingIT.REPETITION));
    ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
    final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, VersionKeeper.INSTANCE, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
    final boolean success = reader.readInitialVersion();
    Assert.assertTrue(success);
    iterator.goToNextCommit();
    final ChangeManager manager = Mockito.mock(ChangeManager.class);
    final HashMap<ChangedEntity, ClazzChangeData> value = new HashMap<>();
    ChangedEntity testMeEntity = new ChangedEntity("viewtest.TestMe", "");
    value.put(testMeEntity, new ClazzChangeData(testMeEntity, false));
    Mockito.when(manager.getChanges(Mockito.any())).thenReturn(value);
    final int tests = reader.analyseVersion(manager);
    LOG.debug(Constants.OBJECTMAPPER.writeValueAsString(reader.getDependencies()));
    Assert.assertEquals(1, tests);
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) HashMap(java.util.HashMap) 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) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ResultsFolders(de.dagere.peass.folders.ResultsFolders) KiekerConfig(de.dagere.peass.config.KiekerConfig) Test(org.junit.jupiter.api.Test)

Example 4 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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 5 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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

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