report.setQueryLimit( dataDefinition.getQueryLimit() ); report.setQueryTimeout( dataDefinition.getQueryTimeout() );
@Test public void testIsLimitReachedForNumberOfRowsGreaterQueryLimit() throws Exception { //When data source enforce limit itself // report with 148 rows final URL url = getClass().getResource( "report1.prpt" ); assertNotNull( url ); final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final Resource directly = resourceManager.createDirectly( url, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); report.setQueryLimit( 147 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), true ); }
@Test public void testIsLimitNotReachedForNumberOfRowsEqualQueryLimit() throws Exception { //When data source enforce limit itself // report with 148 rows final URL url = getClass().getResource( "report1.prpt" ); assertNotNull( url ); final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final Resource directly = resourceManager.createDirectly( url, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); report.setQueryLimit( 148 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsLimitNotReachedForNumberOfRowsLessQueryLimit() throws Exception { //When data source enforce limit itself // report with 148 rows final URL url = getClass().getResource( "report1.prpt" ); assertNotNull( url ); final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final Resource directly = resourceManager.createDirectly( url, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); report.setQueryLimit( 149 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
public void testDerive() throws CloneNotSupportedException { final MasterReport report = new MasterReport(); report.setQueryLimit( 10 ); report.setQueryTimeout( 10 ); final MasterReport element = (MasterReport) report.derive(); assertEquals( 10, element.getQueryLimit() ); assertEquals( 10, element.getQueryTimeout() ); }
@Test public void testInitializeForSubreport() throws Exception { MasterReport masterReport = new MasterReport(); ProcessingContext processingContext = new DefaultProcessingContext(); OutputFunction outputFunction = new DefaultOutputFunction(); SubReport subReportSpy = spy( new SubReport() ); InstanceID instanceID = new InstanceID(); InlineSubreportMarker[] inlineSubreportMarkers = new InlineSubreportMarker[1]; inlineSubreportMarkers[0] = new InlineSubreportMarker( subReportSpy, instanceID, SubReportProcessType.INLINE ); ProcessState parentProcessStateSpy = spy( new ProcessState() ); ProcessState processState = new ProcessState(); masterReport.getRelationalGroup( 0 ).getHeader().addSubReport( subReportSpy ); masterReport.setQueryLimit( 3 ); subReportSpy.reconnectParent( masterReport ); when( subReportSpy.isQueryLimitInherited() ).thenReturn( false ).thenReturn( true ); when( parentProcessStateSpy.getReport() ).thenReturn( masterReport ); parentProcessStateSpy.initializeForMasterReport( masterReport, processingContext, outputFunction ); processState.initializeForSubreport( inlineSubreportMarkers, 0, parentProcessStateSpy ); assertEquals( Integer.valueOf( -1 ), processState.getQueryLimit() ); processState.initializeForSubreport( inlineSubreportMarkers, 0, parentProcessStateSpy ); assertEquals( Integer.valueOf( 3 ), processState.getQueryLimit() ); } }
@Test public void testIsQueryLimitNotReachedForNumberOfRowsEqualQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 500 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForUnlimitedQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( -1 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForZeroQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 0 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForNumberOfRowsLessQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 499, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 500 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitReachedForNumberOfRowsGreaterQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 501, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 500 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), true ); }