Search in sources :

Example 26 with ClazzChangeData

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

the class DependencyDetectorTestUtil method defaultChangeManager.

public static ChangeManager defaultChangeManager() {
    final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("", "defaultpackage.NormalDependency", "executeThing");
    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 27 with ClazzChangeData

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

the class SuperclassDetectorIT method testSuperclassChange.

@Test
public void testSuperclassChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    final File secondVersion = new File(VERSIONS_FOLDER, "superclass_changed");
    final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
    changes.put(new ChangedEntity("defaultpackage.NormalSuperclass", ""), new ClazzChangeData("defaultpackage.NormalSuperclass", 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());
    reader.readInitialVersion();
    checkInitialDependencies(reader);
    fakeIterator.goToNextCommit();
    reader.analyseVersion(changeManager);
    checkFirstVersionDependencies(reader);
}
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) Test(org.junit.jupiter.api.Test)

Example 28 with ClazzChangeData

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

the class TestClassComparison method test6.

@Test
public void test6() throws ParseException, IOException {
    final File file1 = new File(FOLDER, "Test1_1_Equal.java");
    final File file2 = new File(FOLDER, "Test6_MethodChanged.java");
    final ClazzChangeData changedMethods = new ClazzChangeData(new ChangedEntity("Test1_1_Equal", ""));
    FileComparisonUtil.getChangedMethods(file1, file2, changedMethods);
    Assert.assertTrue(changedMethods.isChange());
    Assert.assertTrue(changedMethods.isOnlyMethodChange());
    System.out.println(changedMethods.getChangedMethods());
    MatcherAssert.assertThat(changedMethods.getChangedMethods().values().iterator().next(), Matchers.hasItem("doNonStaticThing"));
    MatcherAssert.assertThat(changedMethods.getChangedMethods().values().iterator().next(), Matchers.hasItem("<init>"));
}
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 29 with ClazzChangeData

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

the class TestClassComparison method test4.

@Test
public void test4() throws ParseException, IOException {
    final File file1 = new File(FOLDER, "Test1_1_Equal.java");
    final File file2 = new File(FOLDER, "Test4_2_Formatting.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 30 with ClazzChangeData

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

the class TestClassComparison method test3.

@Test
public void test3() throws ParseException, IOException {
    final File file1 = new File(FOLDER, "Test1_1_Equal.java");
    final File file2 = new File(FOLDER, "Test3_2_MethodComments.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

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