Search in sources :

Example 1 with ReportPlugin

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

the class CompositeReportPlugin method selectReportWriter.

/**
     * Select the report writers for the given rule.
     *
     * @param rule The rule.
     * @throws ReportException If no writer exists for a specified id.
     */
private void selectReportWriter(ExecutableRule rule) throws ReportException {
    Set<String> selection = rule.getReport().getSelectedTypes();
    if (selection == null) {
        // no writer explicitly selected, use all registered.
        selectedReportWriters = reportWriters.values();
    } else {
        List<ReportPlugin> reportPlugins = new ArrayList<>();
        for (String type : selection) {
            ReportPlugin reportPlugin = this.reportWriters.get(type);
            if (reportPlugin == null) {
                throw new ReportException("Unknown report selection '" + type + "' selected for '" + rule + "'");
            }
            reportPlugins.add(reportPlugin);
        }
        this.selectedReportWriters = reportPlugins;
    }
}
Also used : ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) ReportException(com.buschmais.jqassistant.core.report.api.ReportException)

Example 2 with ReportPlugin

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

the class PluginRepositoryTest method repositories.

@Test
public void repositories() throws PluginRepositoryException {
    PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(PluginRepositoryTest.class.getClassLoader());
    PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
    // Scanner plugins
    ScannerContext scannerContext = mock(ScannerContext.class);
    Map<String, ScannerPlugin<?, ?>> scannerPlugins = pluginRepository.getScannerPluginRepository().getScannerPlugins(scannerContext, Collections.<String, Object>emptyMap());
    assertThat(scannerPlugins.size(), equalTo(2));
    assertThat(scannerPlugins.get(TestScannerPlugin.class.getSimpleName()), notNullValue());
    assertThat(scannerPlugins.get("testScanner"), notNullValue());
    // Report plugins
    Map<String, ReportPlugin> reportPlugins = pluginRepository.getReportPluginRepository().getReportPlugins(Collections.<String, Object>emptyMap());
    assertThat(reportPlugins.size(), equalTo(2));
    assertThat(reportPlugins.get(TestReportPlugin.class.getSimpleName()), notNullValue());
    assertThat(reportPlugins.get("testReport"), notNullValue());
}
Also used : ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) TestReportPlugin(com.buschmais.jqassistant.plugin.impl.plugin.TestReportPlugin) ScannerPlugin(com.buschmais.jqassistant.core.scanner.api.ScannerPlugin) TestScannerPlugin(com.buschmais.jqassistant.plugin.impl.plugin.TestScannerPlugin) PluginConfigurationReaderImpl(com.buschmais.jqassistant.core.plugin.impl.PluginConfigurationReaderImpl) ScannerContext(com.buschmais.jqassistant.core.scanner.api.ScannerContext) PluginRepositoryImpl(com.buschmais.jqassistant.core.plugin.impl.PluginRepositoryImpl) Test(org.junit.Test)

Example 3 with ReportPlugin

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

the class CompositeReportPluginTest method verifyGroup.

private void verifyGroup() throws ReportException {
    for (ReportPlugin reportWriter : Arrays.asList(reportWriter1, reportWriter2)) {
        verify(reportWriter).begin();
        verify(reportWriter).end();
        verify(reportWriter).beginGroup(group);
        verify(reportWriter).endGroup();
    }
}
Also used : ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) CompositeReportPlugin(com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin)

Example 4 with ReportPlugin

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

the class AnalyzerVisitorTest method ruleSourceInErrorMessage.

@Test
public void ruleSourceInErrorMessage() throws RuleException {
    String statement = "match (n) return n";
    Concept concept = createConcept(statement);
    when(store.executeQuery(Mockito.eq(statement), anyMap())).thenThrow(new IllegalStateException("An error"));
    ReportPlugin reportWriter = mock(ReportPlugin.class);
    try {
        AnalyzerVisitor analyzerVisitor = new AnalyzerVisitor(configuration, ruleParameters, store, reportWriter, console);
        analyzerVisitor.visitConcept(concept, Severity.MINOR);
        fail("Expecting an " + RuleExecutorException.class.getName());
    } catch (RuleExecutorException e) {
        String message = e.getMessage();
        assertThat(message, containsString(RULESOURCE));
    }
}
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)

Example 5 with ReportPlugin

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

the class CompositeReportPluginTest method createReportWriter.

@Before
public void createReportWriter() {
    Map<String, ReportPlugin> reportWriters = new HashMap<>();
    reportWriters.put("writer1", reportWriter1);
    reportWriters.put("writer2", reportWriter2);
    compositeReportPlugin = new CompositeReportPlugin(reportWriters);
}
Also used : ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) CompositeReportPlugin(com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin) CompositeReportPlugin(com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin) Before(org.junit.Before)

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