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;
}
}
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());
}
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();
}
}
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));
}
}
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);
}
Aggregations