Search in sources :

Example 71 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorIT method testTestChange.

@Test
public void testTestChange() throws Exception {
    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 72 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorIT method testNoChange.

@Test
public void testNoChange() throws Exception {
    final Map<ChangedEntity, ClazzChangeData> changes = new HashMap<>();
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(DependencyTestConstants.BASIC_STATE));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    StaticTestSelection dependencies = reader.getDependencies();
    System.out.println(dependencies.getVersions());
    Assert.assertTrue(dependencies.getVersions().get(dependencies.getNewestVersion()).isRunning());
// 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) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) HashMap(java.util.HashMap) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Example 73 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorIT method checkClassRemoved.

public static void checkClassRemoved(final DependencyReader reader) {
    final Map<ChangedEntity, TestSet> changedClazzes = reader.getDependencies().getVersions().get(DependencyTestConstants.VERSION_1).getChangedClazzes();
    System.out.println("Ergebnis: " + changedClazzes);
    final ChangedEntity key = new ChangedEntity("defaultpackage.TestMe", "");
    System.out.println("Hash: " + key.hashCode());
    final TestSet testSet = changedClazzes.get(key);
    System.out.println("Testset: " + testSet);
    MatcherAssert.assertThat(testSet.getTests(), Matchers.empty());
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 74 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorIT method testMethodRemoval.

/**
 * Tests removal of a method. In the first version, the method should not be called (but the other method of TestMe should be called, since the class interface changed). In the
 * second version, the changes should only influence TestMe.testMe, not TestMe.removeMe.
 *
 * @throws IOException
 * @throws InterruptedException
 * @throws XmlPullParserException
 * @throws ViewNotFoundException
 * @throws ParseException
 */
@Test
public void testMethodRemoval() throws Exception {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "removed_method");
    final File thirdVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "removed_method_change");
    final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
    changes.put(new ChangedEntity("defaultpackage.TestMe", ""), new ClazzChangeData("defaultpackage.TestMe", 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, thirdVersion));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    Assert.assertEquals(1, reader.getDependencies().getVersions().get("000001").getChangedClazzes().size());
    fakeIterator.goToNextCommit();
    reader.analyseVersion(changeManager);
    System.out.println(reader.getDependencies());
    final TestSet testMe = DependencyDetectorTestUtil.findDependency(reader.getDependencies(), "defaultpackage.TestMe", DependencyTestConstants.VERSION_2);
    final TestCase test = testMe.getTests().iterator().next();
    Assert.assertEquals(1, testMe.getTests().size());
    Assert.assertEquals("defaultpackage.TestMe", test.getClazz());
    Assert.assertEquals("testMe", test.getMethod());
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) 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) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 75 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity 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)

Aggregations

ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)138 Test (org.junit.jupiter.api.Test)58 File (java.io.File)57 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)41 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)25 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)21 ChangeManager (de.dagere.peass.dependency.ChangeManager)18 Set (java.util.Set)17 HashSet (java.util.HashSet)16 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)14 HashMap (java.util.HashMap)14 Map (java.util.Map)13 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)11 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)11 VersionIterator (de.dagere.peass.vcs.VersionIterator)10 TreeMap (java.util.TreeMap)9 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)8 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)6 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)6 LinkedList (java.util.LinkedList)6