use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class TestGenerateDependencies method testGenerateDependencies.
@Test
public void testGenerateDependencies() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
final FakeFileIterator iterator = new FakeFileIterator(TestConstants.CURRENT_FOLDER, Arrays.asList(TraceGettingIT.REPETITION));
ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, VersionKeeper.INSTANCE, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
final boolean success = reader.readInitialVersion();
Assert.assertTrue(success);
iterator.goToNextCommit();
final ChangeManager manager = Mockito.mock(ChangeManager.class);
final HashMap<ChangedEntity, ClazzChangeData> value = new HashMap<>();
ChangedEntity testMeEntity = new ChangedEntity("viewtest.TestMe", "");
value.put(testMeEntity, new ClazzChangeData(testMeEntity, false));
Mockito.when(manager.getChanges(Mockito.any())).thenReturn(value);
final int tests = reader.analyseVersion(manager);
LOG.debug(Constants.OBJECTMAPPER.writeValueAsString(reader.getDependencies()));
Assert.assertEquals(1, tests);
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class JUnitTestShortener method getParentEntity.
public ChangedEntity getParentEntity(final ChangedEntity callee, final CompilationUnit calleeUnit, final ClassOrInterfaceDeclaration clazz) {
ChangedEntity parentEntity = null;
for (final ClassOrInterfaceType parent : clazz.getExtendedTypes()) {
LOG.debug("Must also shorten {} Package: {}", parent, callee.getPackage());
final String parentName = parent.getName().toString();
String fqn = findFQN(calleeUnit, parentName);
if (fqn == parentName) {
if (callee.getPackage().equals("")) {
fqn = parentName;
} else {
fqn = callee.getPackage() + "." + parentName;
}
}
parentEntity = new ChangedEntity(fqn, callee.getModule());
}
return parentEntity;
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class DependencyDetectorIT method testClassRemoval.
@Test
public void testClassRemoval() throws Exception {
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);
checkClassRemoved(reader);
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class DependencyDetectorIT method testClassChange.
@Test
public void testClassChange() throws Exception {
final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "changed_class");
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
changes.put(new ChangedEntity("defaultpackage.NormalDependency", ""), new ClazzChangeData("defaultpackage.NormalDependency", 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());
final boolean success = reader.readInitialVersion();
Assert.assertTrue(success);
final StaticTestSelection dependencies = reader.getDependencies();
System.out.println(dependencies);
fakeIterator.goToNextCommit();
reader.analyseVersion(changeManager);
final TestSet testMe = DependencyDetectorTestUtil.findDependency(dependencies, "defaultpackage.NormalDependency", DependencyTestConstants.VERSION_1);
System.out.println(testMe);
final ChangedEntity change = dependencies.getVersions().get(DependencyTestConstants.VERSION_1).getChangedClazzes().keySet().iterator().next();
Assert.assertEquals("defaultpackage.NormalDependency", change.toString());
Assert.assertEquals("defaultpackage.TestMe#testMe", testMe.getTests().iterator().next().getExecutable());
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class DependencyDetectorMultimoduleIT method mockChangeManager.
private ChangeManager mockChangeManager() {
final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("base-module", "de.dagere.base.BaseChangeable", "doSomething");
DependencyDetectorTestUtil.addChange(changes, "base-module", "de.dagere.base.NextBaseChangeable", "doSomething");
ChangeManager changeManager = Mockito.mock(ChangeManager.class);
Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
return changeManager;
}
Aggregations