@Test public void performQueryDataTest() throws ReportDataFactoryException { PerformanceLoggingStopWatch stopWatch = Mockito.mock(PerformanceLoggingStopWatch.class); Mockito.doNothing().when(stopWatch).stop(); Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { ((PerformanceLoggingStopWatch) invocation.getMock()).stop(); return null; } }).when(stopWatch).close(); Mockito.doNothing().when(stopWatch).start(); Mockito.when(performanceMonitorContext.createStopWatch(Mockito.eq(PerformanceTags.REPORT_QUERY), Mockito.any())).thenReturn(stopWatch); DataFactory dataFactory = Mockito.mock(DataFactory.class); String query = "query"; Mockito.when(dataFactory.queryData(Mockito.eq(query), Mockito.any())).thenReturn(new EmptyTableModel()); int queryLimit = 10; int queryTimeout = 10000; boolean designTime = true; List<SortConstraint> sortConstraints = new ArrayList<>(); try { controller.performQueryData(dataFactory, query, queryLimit, queryTimeout, parameters, designTime, sortConstraints); } catch (ReportDataFactoryException e) { e.printStackTrace(); } InOrder order = Mockito.inOrder(stopWatch); order.verify(stopWatch).start(); order.verify(stopWatch).stop(); }
protected TableModel performQueryData( final DataFactory dataFactory, final String query, final int queryLimit, final int queryTimeout, final DataRow parameters, final boolean designTime, final List<SortConstraint> sortConstraints ) throws ReportDataFactoryException { if ( dataFactory == null ) { throw new NullPointerException(); } if ( parameters == null ) { throw new NullPointerException(); } if ( query == null ) { return new EmptyTableModel(); } PerformanceLoggingStopWatch sw = performanceMonitorContext.createStopWatch( PerformanceTags.REPORT_QUERY, new FormattedMessage( "query={%s}", query ) ); try { sw.start(); int increasedQueryLimit = queryLimit > 0 ? queryLimit + 1 : queryLimit; DataRow params = new QueryDataRowWrapper( parameters, queryTimeout, increasedQueryLimit, sortConstraints ); TableModel reportData; if ( designTime && dataFactory instanceof DataFactoryDesignTimeSupport ) { DataFactoryDesignTimeSupport designTimeSupport = (DataFactoryDesignTimeSupport) dataFactory; reportData = designTimeSupport.queryDesignTimeStructure( query, params ); } else { reportData = dataFactory.queryData( query, params ); } if ( queryLimit > 0 && reportData.getRowCount() >= queryLimit + 1 ) { setQueryLimitReached( true ); return new LengthLimitingTableModel( reportData, queryLimit ); } return reportData; } finally { sw.close(); } }
DefaultFlowController { protected TableModel performQueryData( final DataFactory dataFactory, final String query, final int queryLimit, final int queryTimeout, final DataRow parameters, final boolean designTime, final List<SortConstraint> sortConstraints ) throws ReportDataFactoryException { if ( dataFactory == null ) { throw new NullPointerException(); } if ( parameters == null ) { throw new NullPointerException(); } if ( query == null ) { return new EmptyTableModel(); } PerformanceLoggingStopWatch sw = performanceMonitorContext.createStopWatch( PerformanceTags.REPORT_QUERY, new FormattedMessage( "query={%s}", query ) ); try { sw.start(); int increasedQueryLimit = queryLimit > 0 ? queryLimit + 1 : queryLimit; DataRow params = new QueryDataRowWrapper( parameters, queryTimeout, increasedQueryLimit, sortConstraints ); TableModel reportData; if ( designTime && dataFactory instanceof DataFactoryDesignTimeSupport ) { DataFactoryDesignTimeSupport designTimeSupport = (DataFactoryDesignTimeSupport) dataFactory; reportData = designTimeSupport.queryDesignTimeStructure( query, params ); } else { reportData = dataFactory.queryData( query, params ); } if ( queryLimit > 0 && reportData.getRowCount() >= queryLimit + 1 ) { setQueryLimitReached( true ); return new LengthLimitingTableModel( reportData, queryLimit ); } return reportData; } finally { sw.close(); } } }
DefaultFlowController { protected TableModel performQueryData( final DataFactory dataFactory, final String query, final int queryLimit, final int queryTimeout, final DataRow parameters, final boolean designTime, final List<SortConstraint> sortConstraints ) throws ReportDataFactoryException { if ( dataFactory == null ) { throw new NullPointerException(); } if ( parameters == null ) { throw new NullPointerException(); } if ( query == null ) { return new EmptyTableModel(); } PerformanceLoggingStopWatch sw = performanceMonitorContext.createStopWatch( PerformanceTags.REPORT_QUERY, new FormattedMessage( "query={%s}", query ) ); try { sw.start(); int increasedQueryLimit = queryLimit > 0 ? queryLimit + 1 : queryLimit; DataRow params = new QueryDataRowWrapper( parameters, queryTimeout, increasedQueryLimit, sortConstraints ); TableModel reportData; if ( designTime && dataFactory instanceof DataFactoryDesignTimeSupport ) { DataFactoryDesignTimeSupport designTimeSupport = (DataFactoryDesignTimeSupport) dataFactory; reportData = designTimeSupport.queryDesignTimeStructure( query, params ); } else { reportData = dataFactory.queryData( query, params ); } if ( queryLimit > 0 && reportData.getRowCount() >= queryLimit + 1 ) { setQueryLimitReached( true ); return new LengthLimitingTableModel( reportData, queryLimit ); } return reportData; } finally { sw.close(); } } DefaultFlowController( final ProcessingContext reportContext, final DataSchemaDefinition schemaDefinition,
      final ReportParameterValues parameters, final PerformanceMonitorContext performanceMonitorContext ); private  DefaultFlowController( final DefaultFlowController fc, final MasterDataRow dataRow ); }
DefaultFlowController { protected TableModel performQueryData( final DataFactory dataFactory, final String query, final int queryLimit, final int queryTimeout, final DataRow parameters, final boolean designTime, final List<SortConstraint> sortConstraints ) throws ReportDataFactoryException { if ( dataFactory == null ) { throw new NullPointerException(); } if ( parameters == null ) { throw new NullPointerException(); } if ( query == null ) { return new EmptyTableModel(); } PerformanceLoggingStopWatch sw = performanceMonitorContext.createStopWatch( PerformanceTags.REPORT_QUERY, new FormattedMessage( "query={%s}", query ) ); try { sw.start(); int increasedQueryLimit = queryLimit > 0 ? queryLimit + 1 : queryLimit; DataRow params = new QueryDataRowWrapper( parameters, queryTimeout, increasedQueryLimit, sortConstraints ); TableModel reportData; if ( designTime && dataFactory instanceof DataFactoryDesignTimeSupport ) { DataFactoryDesignTimeSupport designTimeSupport = (DataFactoryDesignTimeSupport) dataFactory; reportData = designTimeSupport.queryDesignTimeStructure( query, params ); } else { reportData = dataFactory.queryData( query, params ); } if ( queryLimit > 0 && reportData.getRowCount() >= queryLimit + 1 ) { setQueryLimitReached( true ); return new LengthLimitingTableModel( reportData, queryLimit ); } return reportData; } finally { sw.close(); } } DefaultFlowController( final ProcessingContext reportContext, final DataSchemaDefinition schemaDefinition,
      final ReportParameterValues parameters, final PerformanceMonitorContext performanceMonitorContext ); private  DefaultFlowController( final DefaultFlowController fc, final MasterDataRow dataRow ); void requireStructuralProcessing(); DefaultFlowController derive(); DefaultFlowController performAdvance(); DefaultFlowController performCommit(); MasterDataRow getMasterRow(); boolean isAdvanceRequested(); @Deprecated DefaultFlowController performQuery( final DataFactory dataFactory, final String query, final int queryLimit,
      final int queryTimeout, final ResourceBundleFactory resourceBundleFactory ); DefaultFlowController performQuery( final DataFactory dataFactory, final String query, final int queryLimit,
      final int queryTimeout, final ResourceBundleFactory resourceBundleFactory, final List<SortConstraint> sortOrder ); DefaultFlowController performDesignTimeQuery( final DataFactory dataFactory, final String query,
      final int queryLimit, final int queryTimeout, final ResourceBundleFactory resourceBundleFactory ); DefaultFlowController performInitSubreport( final DataFactory dataFactory,
      final ParameterMapping[] inputParameters, final ResourceBundleFactory resourceBundleFactory ); @Deprecated DefaultFlowController performSubReportQuery( final String query, final int queryLimit, final int queryTimeout,
      final ParameterMapping[] outputParameters ); DefaultFlowController performSubReportQuery( final String query, final int queryLimit, final int queryTimeout,
      final ParameterMapping[] outputParameters, final List<SortConstraint> sortConstraints ); DefaultFlowController activateExpressions( final Expression[] expressions, final boolean preserveState ); DefaultFlowController deactivateExpressions(); DefaultFlowController performReturnFromQuery(); DefaultFlowController performReturnFromSubreport(); DefaultFlowController performClearExportedParameters(); String getExportDescriptor(); ProcessingContext getReportContext(); DefaultFlowController fireReportEvent( final ReportEvent event ); DataSchema getDataSchema(); DataFactory getDataFactory(); DefaultFlowController startCrosstabMode( final CrosstabSpecification crosstabSpecification ); DefaultFlowController endCrosstabMode(); DefaultFlowController resetRowCursor(); DefaultFlowController restart(); DefaultFlowController updateDataSchema( final DataSchemaDefinition dataSchemaDefinition ); DefaultFlowController refreshDataRow(); boolean isCrosstabActive(); DefaultFlowController recordCrosstabRowState(); DefaultFlowController clearRecordedCrosstabRowState(); DefaultFlowController replayStoredCrosstabRowState(); boolean isQueryLimitReached(); void setQueryLimitReached( boolean queryLimitReached ); }
DefaultFlowController { protected TableModel performQueryData( final DataFactory dataFactory, final String query, final int queryLimit, final int queryTimeout, final DataRow parameters, final boolean designTime, final List<SortConstraint> sortConstraints ) throws ReportDataFactoryException { if ( dataFactory == null ) { throw new NullPointerException(); } if ( parameters == null ) { throw new NullPointerException(); } if ( query == null ) { return new EmptyTableModel(); } PerformanceLoggingStopWatch sw = performanceMonitorContext.createStopWatch( PerformanceTags.REPORT_QUERY, new FormattedMessage( "query={%s}", query ) ); try { sw.start(); int increasedQueryLimit = queryLimit > 0 ? queryLimit + 1 : queryLimit; DataRow params = new QueryDataRowWrapper( parameters, queryTimeout, increasedQueryLimit, sortConstraints ); TableModel reportData; if ( designTime && dataFactory instanceof DataFactoryDesignTimeSupport ) { DataFactoryDesignTimeSupport designTimeSupport = (DataFactoryDesignTimeSupport) dataFactory; reportData = designTimeSupport.queryDesignTimeStructure( query, params ); } else { reportData = dataFactory.queryData( query, params ); } if ( queryLimit > 0 && reportData.getRowCount() >= queryLimit + 1 ) { setQueryLimitReached( true ); return new LengthLimitingTableModel( reportData, queryLimit ); } return reportData; } finally { sw.close(); } } DefaultFlowController( final ProcessingContext reportContext, final DataSchemaDefinition schemaDefinition,
      final ReportParameterValues parameters, final PerformanceMonitorContext performanceMonitorContext ); private  DefaultFlowController( final DefaultFlowController fc, final MasterDataRow dataRow ); void requireStructuralProcessing(); DefaultFlowController derive(); DefaultFlowController performAdvance(); DefaultFlowController performCommit(); MasterDataRow getMasterRow(); boolean isAdvanceRequested(); @Deprecated DefaultFlowController performQuery( final DataFactory dataFactory, final String query, final int queryLimit,
      final int queryTimeout, final ResourceBundleFactory resourceBundleFactory ); DefaultFlowController performQuery( final DataFactory dataFactory, final String query, final int queryLimit,
      final int queryTimeout, final ResourceBundleFactory resourceBundleFactory, final List<SortConstraint> sortOrder ); DefaultFlowController performDesignTimeQuery( final DataFactory dataFactory, final String query,
      final int queryLimit, final int queryTimeout, final ResourceBundleFactory resourceBundleFactory ); DefaultFlowController performInitSubreport( final DataFactory dataFactory,
      final ParameterMapping[] inputParameters, final ResourceBundleFactory resourceBundleFactory ); @Deprecated DefaultFlowController performSubReportQuery( final String query, final int queryLimit, final int queryTimeout,
      final ParameterMapping[] outputParameters ); DefaultFlowController performSubReportQuery( final String query, final int queryLimit, final int queryTimeout,
      final ParameterMapping[] outputParameters, final List<SortConstraint> sortConstraints ); DefaultFlowController activateExpressions( final Expression[] expressions, final boolean preserveState ); DefaultFlowController deactivateExpressions(); DefaultFlowController performReturnFromQuery(); DefaultFlowController performReturnFromSubreport(); DefaultFlowController performClearExportedParameters(); String getExportDescriptor(); ProcessingContext getReportContext(); DefaultFlowController fireReportEvent( final ReportEvent event ); DataSchema getDataSchema(); DataFactory getDataFactory(); DefaultFlowController startCrosstabMode( final CrosstabSpecification crosstabSpecification ); DefaultFlowController endCrosstabMode(); DefaultFlowController resetRowCursor(); DefaultFlowController restart(); DefaultFlowController updateDataSchema( final DataSchemaDefinition dataSchemaDefinition ); DefaultFlowController refreshDataRow(); boolean isCrosstabActive(); DefaultFlowController recordCrosstabRowState(); DefaultFlowController clearRecordedCrosstabRowState(); DefaultFlowController replayStoredCrosstabRowState(); boolean isQueryLimitReached(); void setQueryLimitReached( boolean queryLimitReached );  }