use of com.buschmais.jqassistant.core.scanner.api.ScannerContext in project jqa-core-framework by buschmais.
the class PluginRepositoryTest method repositories.
@Test
public void repositories() throws PluginRepositoryException {
PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(PluginRepositoryTest.class.getClassLoader());
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
// Scanner plugins
ScannerContext scannerContext = mock(ScannerContext.class);
Map<String, ScannerPlugin<?, ?>> scannerPlugins = pluginRepository.getScannerPluginRepository().getScannerPlugins(scannerContext, Collections.<String, Object>emptyMap());
assertThat(scannerPlugins.size(), equalTo(2));
assertThat(scannerPlugins.get(TestScannerPlugin.class.getSimpleName()), notNullValue());
assertThat(scannerPlugins.get("testScanner"), notNullValue());
// Report plugins
Map<String, ReportPlugin> reportPlugins = pluginRepository.getReportPluginRepository().getReportPlugins(Collections.<String, Object>emptyMap());
assertThat(reportPlugins.size(), equalTo(2));
assertThat(reportPlugins.get(TestReportPlugin.class.getSimpleName()), notNullValue());
assertThat(reportPlugins.get("testReport"), notNullValue());
}
use of com.buschmais.jqassistant.core.scanner.api.ScannerContext in project jqa-java-plugin by buschmais.
the class AbstractJavaPluginIT method execute.
protected List<? extends FileDescriptor> execute(JavaArtifactFileDescriptor artifact, ScanClassPathOperation operation, Scanner scanner) {
ScannerContext context = scanner.getContext();
context.push(JavaArtifactFileDescriptor.class, artifact);
context.push(TypeResolver.class, new ArtifactScopedTypeResolver(artifact));
List<? extends FileDescriptor> descriptors = operation.scan(artifact, scanner);
context.pop(TypeResolver.class);
context.pop(JavaArtifactFileDescriptor.class);
return descriptors;
}
use of com.buschmais.jqassistant.core.scanner.api.ScannerContext in project jqa-java-plugin by buschmais.
the class AbstractJavaPluginIT method execute.
/**
* Executes the given scan operation.
*
* @param artifactId
* The artifact id of the artifact to push on the context.
* @param operation
* The operation.
*/
protected List<? extends FileDescriptor> execute(String artifactId, ScanClassPathOperation operation) {
Scanner scanner = getScanner();
ScannerContext context = scanner.getContext();
store.beginTransaction();
JavaArtifactFileDescriptor artifact = getArtifactDescriptor(artifactId);
artifact.setFullQualifiedName(artifactId);
context.push(JavaArtifactFileDescriptor.class, artifact);
ContainerFileResolver fileResolverStrategy = new ContainerFileResolver(artifact);
context.push(FileResolver.class, fileResolverStrategy);
List<? extends FileDescriptor> descriptors = execute(artifact, operation, scanner);
for (FileDescriptor descriptor : descriptors) {
fileResolverStrategy.put(descriptor.getFileName(), descriptor);
}
context.pop(JavaArtifactFileDescriptor.class);
context.pop(FileResolver.class);
fileResolverStrategy.flush();
store.commitTransaction();
return descriptors;
}
use of com.buschmais.jqassistant.core.scanner.api.ScannerContext in project jqa-core-framework by buschmais.
the class PluginRepositoryTest method getScannerPluginProperties.
private Map<String, Object> getScannerPluginProperties(PluginRepository pluginRepository, Map<String, Object> properties) throws PluginRepositoryException {
ScannerPluginRepository scannerPluginRepository = pluginRepository.getScannerPluginRepository();
ScannerContext scannerContext = mock(ScannerContext.class);
Map<String, ScannerPlugin<?, ?>> scannerPlugins = scannerPluginRepository.getScannerPlugins(scannerContext, properties);
assertThat(scannerPlugins.size(), greaterThan(0));
for (ScannerPlugin<?, ?> scannerPlugin : scannerPlugins.values()) {
if (scannerPlugin instanceof TestScannerPlugin) {
return ((TestScannerPlugin) scannerPlugin).getProperties();
}
}
return null;
}
use of com.buschmais.jqassistant.core.scanner.api.ScannerContext in project jqa-java-plugin by buschmais.
the class PackageDirectoryScannerPlugin method scan.
@Override
public PackageDescriptor scan(DirectoryResource item, String path, Scope scope, Scanner scanner) throws IOException {
ScannerContext context = scanner.getContext();
DirectoryDescriptor directoryDescriptor = context.getCurrentDescriptor();
PackageDescriptor descriptor = context.getStore().addDescriptorType(directoryDescriptor, PackageDescriptor.class);
String packageName = path.substring(1).replaceAll("/", ".");
String name;
int separatorIndex = packageName.lastIndexOf('.');
if (separatorIndex != -1) {
name = packageName.substring(separatorIndex + 1);
} else {
name = packageName;
}
descriptor.setName(name);
descriptor.setFullQualifiedName(packageName);
return descriptor;
}
Aggregations