Search in sources :

Example 6 with ChangedEntity

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

the class TestShortening method testShorteningJUnit5Parameterized.

@Test
public void testShorteningJUnit5Parameterized() throws Exception {
    final File test = new File(folder, "src/test/java/de");
    test.mkdirs();
    final File testClazz = new File(test, "ExampleTestJUnit5Parameterized.java");
    try (JUnitTestShortener shortener = new JUnitTestShortener(transformer, folder, new ChangedEntity("de.ExampleTestJUnit5Parameterized", ""), "checkSomething")) {
        Assert.assertFalse(FileUtils.contentEquals(exampleTestFile5Parameterized, testClazz));
        try (FileInputStream inputStream = new FileInputStream(testClazz)) {
            String fileContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
            System.out.println(fileContent);
            int matches = StringUtils.countMatches(fileContent, "@Test");
            Assert.assertEquals(1, matches);
            int matchesParameterized = StringUtils.countMatches(fileContent, "@ParameterizedTest");
            Assert.assertEquals(0, matchesParameterized);
        }
    }
    Assert.assertTrue(FileUtils.contentEquals(exampleTestFile5Parameterized, testClazz));
}
Also used : ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File) FileInputStream(java.io.FileInputStream) JUnitTestShortener(de.dagere.peass.testtransformation.JUnitTestShortener) Test(org.junit.jupiter.api.Test)

Example 7 with ChangedEntity

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

the class TestClassComparison method testImport.

@Test
public void testImport() throws ParseException, IOException, URISyntaxException {
    final File file1 = new File(FOLDER, "TestImport_New.java");
    final File file2 = new File(FOLDER, "TestImport_Old.java");
    final ClazzChangeData changedMethods = new ClazzChangeData(new ChangedEntity("de.TestImport_new", ""));
    FileComparisonUtil.getChangedMethods(file1, file2, changedMethods);
    Assert.assertTrue(changedMethods.isChange());
    MatcherAssert.assertThat(changedMethods.getChanges(), Matchers.hasItem(new ChangedEntity("de.Test", "")));
    MatcherAssert.assertThat(changedMethods.getChanges(), Matchers.hasItem(new ChangedEntity("de.Test$InnerTest", "")));
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 8 with ChangedEntity

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

the class TestClassComparison method testChangeAndAddition2.

@Test
public void testChangeAndAddition2() throws ParseException, IOException {
    final File file1 = new File(FOLDER, "Test1_1_Equal.java");
    final File file2 = new File(FOLDER, "Test12_ChangeAndAddition2.java");
    final ClazzChangeData changedMethods = new ClazzChangeData(new ChangedEntity("Test1_1_Equal", ""));
    FileComparisonUtil.getChangedMethods(file1, file2, changedMethods);
    Assert.assertTrue(changedMethods.isChange());
    Assert.assertFalse(changedMethods.isOnlyMethodChange());
    System.out.println(changedMethods.getChangedMethods());
    MatcherAssert.assertThat(changedMethods.getChangedMethods().values().iterator().next(), Matchers.containsInAnyOrder("<init>", "doNonStaticThing"));
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 9 with ChangedEntity

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

the class TestClassComparison method test2.

@Test
public void test2() throws ParseException, IOException {
    final File file1 = new File(FOLDER, "Test1_1_Equal.java");
    final File file2 = new File(FOLDER, "Test2_2_Comments.java");
    final ClazzChangeData changedMethods = new ClazzChangeData(new ChangedEntity("Test1_1_Equal", ""));
    FileComparisonUtil.getChangedMethods(file1, file2, changedMethods);
    Assert.assertFalse(changedMethods.isChange());
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 10 with ChangedEntity

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

the class TestClassComparison method test1.

@Test
public void test1() throws ParseException, IOException, URISyntaxException {
    final File file1 = new File(FOLDER, "Test1_1_Equal.java");
    final File file2 = new File(FOLDER, "Test1_2_Equal.java");
    final ClazzChangeData changedMethods = new ClazzChangeData(new ChangedEntity("Test1_1_Equal", ""));
    FileComparisonUtil.getChangedMethods(file1, file2, changedMethods);
    Assert.assertFalse(changedMethods.isChange());
}
Also used : ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)136 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)23 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)20 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)12 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 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)6 Node (com.github.javaparser.ast.Node)5 Change (de.dagere.peass.analysis.changes.Change)5