use of com.buschmais.jqassistant.core.report.api.ReportContext in project jqa-core-framework by buschmais.
the class ReportContextImplTest method archiveReports.
@Test
void archiveReports() throws IOException, ReportException {
// given
File reportDirectory = new File("target/report");
ReportContext reportContext = new ReportContextImpl(mock(Store.class), reportDirectory, reportDirectory);
File file = new File(reportContext.getReportDirectory("test-plugin"), "test-report.txt");
try (FileWriter fileWriter = new FileWriter(file)) {
IOUtils.write("Test", fileWriter);
}
reportContext.addReport("test", Concept.builder().id("test:Concept").build(), ReportContext.ReportType.LINK, file.toURI().toURL());
// when
File reportArchive = reportContext.createReportArchive();
// then
assertThat(reportArchive).exists();
List<String> reportEntries = new ArrayList<>();
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(reportArchive))) {
ZipEntry nextEntry;
while ((nextEntry = zipInputStream.getNextEntry()) != null) {
reportEntries.add(nextEntry.getName());
}
}
assertThat(reportEntries).containsExactly("test-plugin/test-report.txt");
}
use of com.buschmais.jqassistant.core.report.api.ReportContext 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();
}
Aggregations