Search in sources :

Example 11 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData 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 12 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class DependencyDetectorMultimoduleIT method mockChangeManager.

private ChangeManager mockChangeManager() {
    final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("base-module", "de.dagere.base.BaseChangeable", "doSomething");
    DependencyDetectorTestUtil.addChange(changes, "base-module", "de.dagere.base.NextBaseChangeable", "doSomething");
    ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    return changeManager;
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 13 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class DependencyDetectorNoUpdateIT method testTestChange.

@Test
public void testTestChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    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)

Example 14 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class DependencyDetectorParametersIT method changeManagerWithParameter.

public static ChangeManager changeManagerWithParameter() {
    final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("", "defaultpackage.NormalDependency", "innerMethod(java.lang.Integer)");
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    return changeManager;
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 15 with ClazzChangeData

use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.

the class TestTestDependencies method testParameterChange.

private void testParameterChange(final TestDependencies dependencies, final String parameterizedMethod) {
    HashMap<ChangedEntity, ClazzChangeData> changeTestMap = new HashMap<ChangedEntity, ClazzChangeData>();
    ClazzChangeData classChangeData = new ClazzChangeData(new ChangedEntity("package.ClazzB", "moduleA"), true);
    classChangeData.addChange("ClazzB", parameterizedMethod);
    changeTestMap.put(new ChangedEntity("package.ClazzB", "moduleA"), classChangeData);
    ChangeTestMapping changes = dependencies.getChangeTestMap(changeTestMap);
    Assert.assertEquals(1, changes.getChanges().size());
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) HashMap(java.util.HashMap) ChangeTestMapping(de.dagere.peass.dependency.analysis.data.ChangeTestMapping) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Aggregations

ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)42 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)41 Test (org.junit.jupiter.api.Test)26 File (java.io.File)25 ChangeManager (de.dagere.peass.dependency.ChangeManager)17 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)10 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)10 VersionIterator (de.dagere.peass.vcs.VersionIterator)9 TreeMap (java.util.TreeMap)9 HashMap (java.util.HashMap)7 PeassFolders (de.dagere.peass.folders.PeassFolders)5 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)4 KiekerConfig (de.dagere.peass.config.KiekerConfig)4 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)4 ChangeTestMapping (de.dagere.peass.dependency.analysis.data.ChangeTestMapping)3 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)3 Map (java.util.Map)3 Set (java.util.Set)3 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)2 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)2