Search in sources :

Example 1 with PluginRepository

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();
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) TestScannerPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestScannerPlugin) ScannerPlugin(com.buschmais.jqassistant.core.scanner.api.ScannerPlugin) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) TestScannerPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestScannerPlugin) TestReportPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestReportPlugin) ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) TestReportPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestReportPlugin) ScannerContext(com.buschmais.jqassistant.core.scanner.api.ScannerContext) ReportContext(com.buschmais.jqassistant.core.report.api.ReportContext) Test(org.junit.jupiter.api.Test)

Example 2 with PluginRepository

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();
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) HashMap(java.util.HashMap) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) Test(org.junit.jupiter.api.Test)

Example 3 with PluginRepository

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);
    });
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) PluginInfo(com.buschmais.jqassistant.core.plugin.api.PluginInfo) Test(org.junit.jupiter.api.Test)

Example 4 with PluginRepository

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"));
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) PluginInfo(com.buschmais.jqassistant.core.plugin.api.PluginInfo) Test(org.junit.jupiter.api.Test)

Aggregations

AnalyzerPluginRepository (com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository)4 PluginConfigurationReader (com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader)4 PluginRepository (com.buschmais.jqassistant.core.plugin.api.PluginRepository)4 ScannerPluginRepository (com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository)4 Test (org.junit.jupiter.api.Test)4 PluginInfo (com.buschmais.jqassistant.core.plugin.api.PluginInfo)2 JqassistantPlugin (org.jqassistant.schema.plugin.v1.JqassistantPlugin)2 TestReportPlugin (com.buschmais.jqassistant.core.plugin.impl.plugin.TestReportPlugin)1 TestScannerPlugin (com.buschmais.jqassistant.core.plugin.impl.plugin.TestScannerPlugin)1 ReportContext (com.buschmais.jqassistant.core.report.api.ReportContext)1 ReportPlugin (com.buschmais.jqassistant.core.report.api.ReportPlugin)1 ScannerContext (com.buschmais.jqassistant.core.scanner.api.ScannerContext)1 ScannerPlugin (com.buschmais.jqassistant.core.scanner.api.ScannerPlugin)1 HashMap (java.util.HashMap)1