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));
}
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", "")));
}
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"));
}
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());
}
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());
}
Aggregations