Search in sources :

Example 1 with ReportContext

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");
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) FileWriter(java.io.FileWriter) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) Store(com.buschmais.jqassistant.core.store.api.Store) File(java.io.File) ReportContext(com.buschmais.jqassistant.core.report.api.ReportContext) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test)

Example 2 with ReportContext

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();
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) TestScannerPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestScannerPlugin) ScannerPlugin(com.buschmais.jqassistant.core.scanner.api.ScannerPlugin) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) TestScannerPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestScannerPlugin) TestReportPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestReportPlugin) ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) TestReportPlugin(com.buschmais.jqassistant.core.plugin.impl.plugin.TestReportPlugin) ScannerContext(com.buschmais.jqassistant.core.scanner.api.ScannerContext) ReportContext(com.buschmais.jqassistant.core.report.api.ReportContext) Test(org.junit.jupiter.api.Test)

Aggregations

ReportContext (com.buschmais.jqassistant.core.report.api.ReportContext)2 Test (org.junit.jupiter.api.Test)2 AnalyzerPluginRepository (com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository)1 PluginConfigurationReader (com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader)1 PluginRepository (com.buschmais.jqassistant.core.plugin.api.PluginRepository)1 TestReportPlugin (com.buschmais.jqassistant.core.plugin.impl.plugin.TestReportPlugin)1 TestScannerPlugin (com.buschmais.jqassistant.core.plugin.impl.plugin.TestScannerPlugin)1 ReportPlugin (com.buschmais.jqassistant.core.report.api.ReportPlugin)1 ScannerContext (com.buschmais.jqassistant.core.scanner.api.ScannerContext)1 ScannerPlugin (com.buschmais.jqassistant.core.scanner.api.ScannerPlugin)1 ScannerPluginRepository (com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository)1 Store (com.buschmais.jqassistant.core.store.api.Store)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1