use of com.buschmais.jqassistant.core.plugin.api.PluginRepository in project jqa-core-framework by buschmais.
the class PluginRepositoryImplTest method repositories.
@Test
void repositories() {
PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(PluginRepositoryImplTest.class.getClassLoader());
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
pluginRepository.initialize();
// Scanner plugins
ScannerContext scannerContext = mock(ScannerContext.class);
Map<String, ScannerPlugin<?, ?>> scannerPlugins = pluginRepository.getScannerPluginRepository().getScannerPlugins(scannerContext, Collections.emptyMap());
assertThat(scannerPlugins).hasSize(2);
assertThat(scannerPlugins.get(TestScannerPlugin.class.getSimpleName()), notNullValue());
assertThat(scannerPlugins.get(TestScannerPlugin.class.getSimpleName())).isNotNull();
assertThat(scannerPlugins.get("testScanner"), notNullValue());
assertThat(scannerPlugins.get("testScanner")).isNotNull();
// Report plugins
ReportContext reportContext = mock(ReportContext.class);
Map<String, ReportPlugin> reportPlugins = pluginRepository.getAnalyzerPluginRepository().getReportPlugins(reportContext, Collections.emptyMap());
assertThat(reportPlugins.size(), equalTo(3));
assertThat(reportPlugins).hasSize(3);
assertThat(reportPlugins.get(TestReportPlugin.class.getSimpleName()), notNullValue());
assertThat(reportPlugins.get(TestReportPlugin.class.getSimpleName())).isNotNull();
assertThat(reportPlugins.get("testReport"), notNullValue());
assertThat(reportPlugins.get("testReport")).isNotNull();
pluginRepository.destroy();
}
use of com.buschmais.jqassistant.core.plugin.api.PluginRepository in project jqa-core-framework by buschmais.
the class PluginRepositoryImplTest method pluginProperties.
/**
* Verifies that properties are loaded and passed to plugins.
*/
@Test
void pluginProperties() {
PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(PluginRepositoryImplTest.class.getClassLoader());
Map<String, Object> properties = new HashMap<>();
properties.put("testKey", "testValue");
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
pluginRepository.initialize();
// scanner plugins
verifyProperties(getScannerPluginProperties(pluginRepository, properties));
// report plugins
verifyProperties(getReportPluginProperties(pluginRepository, properties));
pluginRepository.destroy();
}
use of com.buschmais.jqassistant.core.plugin.api.PluginRepository in project jqa-core-framework by buschmais.
the class PluginRepositoryImplTest method returnedCollectionForTheOverviewIsUnmodifiable.
@Test
void returnedCollectionForTheOverviewIsUnmodifiable() {
PluginConfigurationReader pluginConfigurationReader = Mockito.mock(PluginConfigurationReader.class);
JqassistantPlugin pluginA = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginB = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginC = Mockito.mock(JqassistantPlugin.class);
doReturn("jqa.a").when(pluginA).getId();
doReturn("A").when(pluginA).getName();
doReturn("jqa.b").when(pluginB).getId();
doReturn("B").when(pluginB).getName();
doReturn("jqa.c").when(pluginC).getId();
doReturn("C").when(pluginC).getName();
doReturn(Arrays.asList(pluginA, pluginB, pluginC)).when(pluginConfigurationReader).getPlugins();
doReturn(PluginRepositoryImplTest.class.getClassLoader()).when(pluginConfigurationReader).getClassLoader();
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
pluginRepository.initialize();
Collection<PluginInfo> overview = pluginRepository.getPluginOverview();
SoftAssertions.assertSoftly(overviewOfPlugins -> {
overviewOfPlugins.assertThatThrownBy(() -> overview.clear()).isInstanceOf(RuntimeException.class);
overviewOfPlugins.assertThatThrownBy(() -> overview.removeIf(i -> true)).isInstanceOf(RuntimeException.class);
});
}
use of com.buschmais.jqassistant.core.plugin.api.PluginRepository in project jqa-core-framework by buschmais.
the class PluginRepositoryImplTest method allPluginsKnownToThePluginReaderFormThePluginOverview.
@Test
void allPluginsKnownToThePluginReaderFormThePluginOverview() {
PluginConfigurationReader pluginConfigurationReader = Mockito.mock(PluginConfigurationReader.class);
JqassistantPlugin pluginA = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginB = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginC = Mockito.mock(JqassistantPlugin.class);
doReturn("jqa.a").when(pluginA).getId();
doReturn("A").when(pluginA).getName();
doReturn("jqa.b").when(pluginB).getId();
doReturn("B").when(pluginB).getName();
doReturn("jqa.c").when(pluginC).getId();
doReturn("C").when(pluginC).getName();
doReturn(Arrays.asList(pluginA, pluginB, pluginC)).when(pluginConfigurationReader).getPlugins();
doReturn(PluginRepositoryImplTest.class.getClassLoader()).when(pluginConfigurationReader).getClassLoader();
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
pluginRepository.initialize();
Collection<PluginInfo> overview = pluginRepository.getPluginOverview();
assertThat(overview).hasSize(3);
assertThat(overview).anyMatch(info -> info.getName().equals("A") && info.getId().equals("jqa.a"));
assertThat(overview).anyMatch(info -> info.getName().equals("B") && info.getId().equals("jqa.b"));
assertThat(overview).anyMatch(info -> info.getName().equals("C") && info.getId().equals("jqa.c"));
}
Aggregations