use of com.buschmais.jqassistant.core.scanner.api.configuration.Scan in project jqa-core-framework by jQAssistant.
the class ConfigurationLoaderImplTest method loadFromFiles.
@Test
void loadFromFiles() {
Configuration configuration = configurationLoader.load(Configuration.class);
assertThat(configuration).isNotNull();
List<Plugin> plugins = configuration.plugins();
assertThat(plugins).isNotNull().hasSize(2);
Scan scan = configuration.scan();
assertThat(scan).isNotNull();
assertThat(scan.continueOnError()).isEqualTo(true);
}
use of com.buschmais.jqassistant.core.scanner.api.configuration.Scan in project jqa-core-framework by jQAssistant.
the class ScannerImplTest method pluginPipeline.
/**
* Verifies correct execution of the pipeline for dependent and nested scanner
* plugins:
*
* <ul>
* <li>A {@link TestItem} is scanned initially by
* {@link TestItemScannerPlugin}.</li>
* <li>The created {@link TestItemDescriptor} is then passed to the
* {@link DependentTestItemScannerPlugin}.</li>
* <li>The {@link DependentTestItemScannerPlugin} triggers a separate scan using
* the {@link TestScope} which activates the
* {@link NestedTestItemScannerPlugin}.</li>
* </ul>
*/
@Test
void pluginPipeline() {
Store store = mock(Store.class);
ScannerContext scannerContext = new ScannerContextImpl(store, OUTPUT_DIRECTORY);
when(store.create(any(Class.class))).thenAnswer((Answer<Descriptor>) invocation -> {
Class<? extends Descriptor> descriptorType = (Class<? extends Descriptor>) invocation.getArguments()[0];
return mock(descriptorType);
});
when(store.addDescriptorType(any(Descriptor.class), any(Class.class))).thenAnswer((Answer<Descriptor>) invocation -> {
Class<? extends Descriptor> descriptorType = (Class<? extends Descriptor>) invocation.getArguments()[1];
return mock(descriptorType);
});
Map<String, ScannerPlugin<?, ?>> scannerPlugins = new HashMap<>();
scannerPlugins.put("TestScanner", new TestItemScannerPlugin());
scannerPlugins.put("DependentTestScanner", new DependentTestItemScannerPlugin());
scannerPlugins.put("NestedTestScanner", new NestedTestItemScannerPlugin());
doReturn(scannerPlugins).when(scannerPluginRepository).getScannerPlugins(configuration, scannerContext);
Scanner scanner = new ScannerImpl(configuration, scannerContext, scannerPluginRepository);
Descriptor descriptor = scanner.scan(new TestItem(), "/", DefaultScope.NONE);
assertThat(descriptor, instanceOf(DependentTestItemDescriptor.class));
verify(store).create(eq(TestItemDescriptor.class));
verify(store).addDescriptorType(any(TestItemDescriptor.class), eq(NestedTestItemDescriptor.class));
verify(store).addDescriptorType(any(NestedTestItemDescriptor.class), eq(DependentTestItemDescriptor.class));
}
Aggregations