use of de.dagere.peass.dependency.ClazzFileFinder in project peass by DaGeRe.
the class TestExecutor method loadClasses.
public void loadClasses() {
existingClasses = new LinkedList<>();
for (final File module : getModules().getModules()) {
ExecutionConfig executionConfig = testTransformer.getConfig().getExecutionConfig();
ClazzFileFinder finder = new ClazzFileFinder(executionConfig);
final List<String> currentClasses = finder.getClasses(module);
existingClasses.addAll(currentClasses);
}
}
use of de.dagere.peass.dependency.ClazzFileFinder in project peass by DaGeRe.
the class JmhTestTransformer method getTestMethodNames.
@Override
public List<TestCase> getTestMethodNames(final File module, final TestCase clazzname) {
final List<TestCase> methods = new LinkedList<>();
ClazzFileFinder finder = new ClazzFileFinder(measurementConfig.getExecutionConfig());
final File clazzFile = finder.getClazzFile(module, clazzname);
try {
// File might be removed or moved
if (clazzFile != null) {
LOG.debug("Parsing {} - {}", clazzFile, clazzname);
final CompilationUnit unit = JavaParserProvider.parse(clazzFile);
List<ClassOrInterfaceDeclaration> clazzDeclarations = ClazzFinder.getClazzDeclarations(unit);
for (ClassOrInterfaceDeclaration clazz : clazzDeclarations) {
String parsedClassName = getFullName(clazz);
LOG.trace("Clazz: {} - {}", parsedClassName, clazzname.getShortClazz());
if (parsedClassName.equals(clazzname.getShortClazz())) {
List<String> benchmarkMethods = JUnitParseUtil.getAnnotatedMethods(clazz, "org.openjdk.jmh.annotations.Benchmark", "Benchmark");
for (String benchmarkMethod : benchmarkMethods) {
TestCase foundBenchmark = new TestCase(clazzname.getClazz(), benchmarkMethod, clazzname.getModule());
methods.add(foundBenchmark);
}
}
}
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
return methods;
}
use of de.dagere.peass.dependency.ClazzFileFinder in project peass by DaGeRe.
the class JmhTestTransformer method findModuleTests.
public TestSet findModuleTests(final ModuleClassMapping mapping, final List<String> includedModules, final File module) throws FileNotFoundException {
TestSet moduleTests = new TestSet();
ClazzFileFinder finder = new ClazzFileFinder(measurementConfig.getExecutionConfig());
for (final String clazz : finder.getClasses(module)) {
String currentModule = ModuleClassMapping.getModuleName(projectFolder, module);
final List<TestCase> testMethodNames = getTestMethodNames(module, new TestCase(clazz, null, currentModule));
for (TestCase test : testMethodNames) {
if (includedModules == null || includedModules.contains(test.getModule())) {
addTestIfIncluded(moduleTests, test);
}
}
}
return moduleTests;
}
use of de.dagere.peass.dependency.ClazzFileFinder in project peass by DaGeRe.
the class FileComparisonUtil method getMethodSource.
public static String getMethodSource(final File projectFolder, final ChangedEntity entity, final String method, final ExecutionConfig config) throws FileNotFoundException {
ClazzFileFinder finder = new ClazzFileFinder(config);
final File file = finder.getSourceFile(projectFolder, entity);
if (file != null) {
LOG.debug("Found: {} {}", file, file.exists());
final CompilationUnit cu = JavaParserProvider.parse(file);
return getMethodSource(entity, method, cu);
} else {
return "";
}
}
use of de.dagere.peass.dependency.ClazzFileFinder in project peass by DaGeRe.
the class JUnitTestShortener method shortenTest.
private void shortenTest() {
if (!lastShortenedMap.isEmpty()) {
throw new RuntimeException("Only use TestShortener once!");
}
ClazzFileFinder finder = new ClazzFileFinder(transformer.getConfig().getExecutionConfig());
final File calleeClazzFile = finder.getClazzFile(module, callee);
if (calleeClazzFile != null) {
try {
shortenTestClazz(callee, calleeClazzFile);
for (final File superclass : superclasses) {
if (!lastShortenedMap.containsValue(superclass)) {
// A rather dirty hack..
final ChangedEntity callee = new ChangedEntity(superclass.getName().replaceAll(".java", ""), this.callee.getModule());
LOG.debug("Shortening: " + callee);
shortenTestClazz(callee, superclass);
}
}
} catch (final IOException e1) {
e1.printStackTrace();
}
} else {
throw new RuntimeException("Could not find " + callee.getModule() + " " + callee.getClazz() + " java file in " + module + " - maybe package missing?");
}
}
Aggregations