Search in sources :

Example 6 with JqassistantPlugin

use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class ScannerPluginRepositoryImpl method getScannerPlugins.

private void getScannerPlugins(List<JqassistantPlugin> plugins) {
    for (JqassistantPlugin plugin : plugins) {
        IdClassListType scannerTypes = plugin.getScanner();
        if (scannerTypes != null) {
            for (IdClassType classType : scannerTypes.getClazz()) {
                ScannerPlugin<?, ?> scannerPlugin = createInstance(classType.getValue());
                if (scannerPlugin != null) {
                    scannerPlugin.initialize();
                    String id = classType.getId();
                    if (id == null) {
                        id = scannerPlugin.getClass().getSimpleName();
                    }
                    scannerPlugins.put(id, scannerPlugin);
                }
            }
        }
    }
}
Also used : IdClassType(org.jqassistant.schema.plugin.v1.IdClassType) JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) IdClassListType(org.jqassistant.schema.plugin.v1.IdClassListType)

Example 7 with JqassistantPlugin

use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class PluginIdGeneratorTest method idGenerationWorksAsExpected.

// todo null
// todo ""
@ParameterizedTest
@MethodSource("parameterProvider")
void idGenerationWorksAsExpected(String name, String id, String expected) {
    JqassistantPlugin plugin = Mockito.mock(JqassistantPlugin.class);
    Mockito.when(plugin.getName()).thenReturn(name);
    Mockito.when(plugin.getId()).thenReturn(id);
    JqassistantPlugin apply = generator.apply(plugin);
    Mockito.verify(apply).setId(expected);
}
Also used : JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with JqassistantPlugin

use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class PluginIdGeneratorTest method pluginWithIdWithoutAnyWhitespaceWillNotBeModified.

@Test
void pluginWithIdWithoutAnyWhitespaceWillNotBeModified() {
    JqassistantPlugin plugin = Mockito.mock(JqassistantPlugin.class);
    Mockito.when(plugin.getName()).thenReturn("Time Maschine Plugin");
    Mockito.when(plugin.getId()).thenReturn("org.timed.plugin");
    JqassistantPlugin apply = generator.apply(plugin);
    Mockito.verify(apply, never()).setId(Mockito.anyString());
}
Also used : JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with JqassistantPlugin

use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class ReportPluginRepositoryImpl method getReportPlugins.

private Map<String, ReportPlugin> getReportPlugins(List<JqassistantPlugin> plugins) throws PluginRepositoryException {
    Map<String, ReportPlugin> reportPlugins = new HashMap<>();
    for (JqassistantPlugin plugin : plugins) {
        ReportType reportType = plugin.getReport();
        if (reportType != null) {
            for (IdClassType classType : reportType.getClazz()) {
                ReportPlugin reportPlugin = createInstance(classType.getValue());
                if (reportPlugin != null) {
                    try {
                        reportPlugin.initialize();
                    } catch (ReportException e) {
                        throw new PluginRepositoryException("Cannot initialize report plugin " + reportPlugin, e);
                    }
                    String id = classType.getId();
                    if (id == null) {
                        id = reportPlugin.getClass().getSimpleName();
                    }
                    reportPlugins.put(id, reportPlugin);
                }
            }
        }
    }
    return reportPlugins;
}
Also used : IdClassType(com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType) PluginRepositoryException(com.buschmais.jqassistant.core.plugin.api.PluginRepositoryException) ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) HashMap(java.util.HashMap) JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin) ReportException(com.buschmais.jqassistant.core.report.api.ReportException) ReportType(com.buschmais.jqassistant.core.plugin.schema.v1.ReportType)

Example 10 with JqassistantPlugin

use of org.jqassistant.schema.plugin.v1.JqassistantPlugin 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)

Aggregations

JqassistantPlugin (org.jqassistant.schema.plugin.v1.JqassistantPlugin)12 IdClassListType (org.jqassistant.schema.plugin.v1.IdClassListType)5 Test (org.junit.jupiter.api.Test)5 PluginRepositoryException (com.buschmais.jqassistant.core.plugin.api.PluginRepositoryException)3 JqassistantPlugin (com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3 IdClassType (org.jqassistant.schema.plugin.v1.IdClassType)3 AnalyzerPluginRepository (com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository)2 PluginConfigurationReader (com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader)2 PluginInfo (com.buschmais.jqassistant.core.plugin.api.PluginInfo)2 PluginRepository (com.buschmais.jqassistant.core.plugin.api.PluginRepository)2 Scope (com.buschmais.jqassistant.core.scanner.api.Scope)2 ScannerPluginRepository (com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 RuleInterpreterPlugin (com.buschmais.jqassistant.core.analysis.api.RuleInterpreterPlugin)1 IdClassType (com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType)1 ReportType (com.buschmais.jqassistant.core.plugin.schema.v1.ReportType)1 RulesType (com.buschmais.jqassistant.core.plugin.schema.v1.RulesType)1 ScopeType (com.buschmais.jqassistant.core.plugin.schema.v1.ScopeType)1