use of de.dagere.peass.dependency.changesreading.ClazzChangeData 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());
}
use of de.dagere.peass.dependency.changesreading.ClazzChangeData 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);
}
use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.
the class DependencyDetectorNoUpdateIT method testClassRemoval.
@Test
public void testClassRemoval() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "removed_class");
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
final ChangedEntity changedEntity = new ChangedEntity("defaultpackage.TestMe", "");
changes.put(changedEntity, new ClazzChangeData(changedEntity, 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 = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
DependencyDetectorIT.checkClassRemoved(reader);
}
use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.
the class DependencyDetectorParameterizedIT method changeManagerWithParameter.
public static ChangeManager changeManagerWithParameter() {
final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("", "defaultpackage.NormalDependency", "onlyCalledWithOne()");
final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
return changeManager;
}
use of de.dagere.peass.dependency.changesreading.ClazzChangeData in project peass by DaGeRe.
the class DependencyDetectorTestUtil method mockAddedChangeManager.
public static ChangeManager mockAddedChangeManager() {
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
changes.put(new ChangedEntity("defaultpackage.NormalDependency", ""), new ClazzChangeData("defaultpackage.NormalDependency", false));
changes.put(new ChangedEntity("defaultpackage.TestMeAlso", ""), new ClazzChangeData("defaultpackage.TestMeAlso", false));
final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
return changeManager;
}
Aggregations