PDFOutput implements ReportOutputHandler { public int generate( final MasterReport report, final int acceptedPage, final OutputStream outputStream, final int yieldRate ) throws ReportProcessingException, IOException { final PageableReportProcessor proc = createProcessor( report, yieldRate, outputStream ); final IAsyncReportListener listener = ReportListenerThreadHolder.getListener(); doProcess( listener, proc ); return 0; } PDFOutput(); Object getReportLock(); int paginate( MasterReport report, int yieldRate ); int generate( final MasterReport report, final int acceptedPage, final OutputStream outputStream,
                       final int yieldRate ); boolean supportsPagination(); void close();  }
@Test public void testGenerateListener() throws Exception { ClassicEngineBoot.getInstance().start(); pdfOutput.generate( new MasterReport(), 1, new ByteArrayOutputStream(), 1 ); verify( listener, times( 1 ) ).reportProcessingStarted( any( ReportProgressEvent.class ) ); verify( listener, times( 1 ) ).reportProcessingFinished( any( ReportProgressEvent.class ) ); verify( listener, atLeastOnce() ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); }
@Test public void testGenerate() throws Exception { ClassicEngineBoot.getInstance().start(); ReportListenerThreadHolder.clear(); pdfOutput.generate( new MasterReport(), 1, new ByteArrayOutputStream(), 1 ); verify( listener, times( 0 ) ).reportProcessingStarted( any( ReportProgressEvent.class ) ); verify( listener, times( 0 ) ).reportProcessingFinished( any( ReportProgressEvent.class ) ); verify( listener, times( 0 ) ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); verify( yieldReportListener, atLeast( 1 ) ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); }
@Test public void testGenerateYield0() throws Exception { MicroPlatform microPlatform = MicroPlatformFactory.create(); microPlatform.start(); ClassicEngineBoot.getInstance().start(); ReportListenerThreadHolder.clear(); try { pdfOutput.generate( new MasterReport(), 1, new ByteArrayOutputStream(), 0 ); verify( listener, times( 0 ) ).reportProcessingStarted( any( ReportProgressEvent.class ) ); verify( listener, times( 0 ) ).reportProcessingFinished( any( ReportProgressEvent.class ) ); verify( listener, times( 0 ) ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); verifyZeroInteractions( yieldReportListener ); } finally { microPlatform.stop(); microPlatform = null; } }