Search in sources :

Example 6 with ReportPlugin

use of com.buschmais.jqassistant.core.report.api.ReportPlugin 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 7 with ReportPlugin

use of com.buschmais.jqassistant.core.report.api.ReportPlugin in project jqa-core-framework by buschmais.

the class PluginRepositoryTest method getReportPluginProperties.

private Map<String, Object> getReportPluginProperties(PluginRepository pluginRepository, Map<String, Object> properties) throws PluginRepositoryException {
    ReportPluginRepository reportPluginRepository = pluginRepository.getReportPluginRepository();
    Map<String, ReportPlugin> reportPlugins = reportPluginRepository.getReportPlugins(properties);
    assertThat(reportPlugins.size(), greaterThan(0));
    for (ReportPlugin reportPlugin : reportPlugins.values()) {
        if (reportPlugin instanceof TestReportPlugin) {
            return ((TestReportPlugin) reportPlugin).getProperties();
        }
    }
    return null;
}
Also used : ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) TestReportPlugin(com.buschmais.jqassistant.plugin.impl.plugin.TestReportPlugin) TestReportPlugin(com.buschmais.jqassistant.plugin.impl.plugin.TestReportPlugin)

Example 8 with ReportPlugin

use of com.buschmais.jqassistant.core.report.api.ReportPlugin in project jqa-core-framework by buschmais.

the class AnalyzerVisitorTest method missingParameter.

@Test
public void missingParameter() throws RuleException {
    String statement = "match (n) return n";
    Concept concept = createConcept(statement);
    ReportPlugin reportWriter = mock(ReportPlugin.class);
    try {
        AnalyzerVisitor analyzerVisitor = new AnalyzerVisitor(configuration, Collections.<String, String>emptyMap(), store, reportWriter, console);
        analyzerVisitor.visitConcept(concept, Severity.MINOR);
        fail("Expecting an " + RuleExecutorException.class.getName());
    } catch (RuleExecutorException e) {
        String message = e.getMessage();
        assertThat(message, containsString(concept.getId()));
        assertThat(message, containsString(PARAMETER_WITHOUT_DEFAULT));
    }
}
Also used : ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) RuleExecutorException(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

ReportPlugin (com.buschmais.jqassistant.core.report.api.ReportPlugin)8 Test (org.junit.Test)3 ReportException (com.buschmais.jqassistant.core.report.api.ReportException)2 CompositeReportPlugin (com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin)2 RuleExecutorException (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException)2 TestReportPlugin (com.buschmais.jqassistant.plugin.impl.plugin.TestReportPlugin)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 PluginRepositoryException (com.buschmais.jqassistant.core.plugin.api.PluginRepositoryException)1 PluginConfigurationReaderImpl (com.buschmais.jqassistant.core.plugin.impl.PluginConfigurationReaderImpl)1 PluginRepositoryImpl (com.buschmais.jqassistant.core.plugin.impl.PluginRepositoryImpl)1 IdClassType (com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType)1 JqassistantPlugin (com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin)1 ReportType (com.buschmais.jqassistant.core.plugin.schema.v1.ReportType)1 ScannerContext (com.buschmais.jqassistant.core.scanner.api.ScannerContext)1 ScannerPlugin (com.buschmais.jqassistant.core.scanner.api.ScannerPlugin)1 TestScannerPlugin (com.buschmais.jqassistant.plugin.impl.plugin.TestScannerPlugin)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1