@Test public void testGetReportAsCharSource() throws IOException { ReportDownloader downloader = new ReportDownloader(reportService, 1); URL resourceUrl = ReportProvider.TEST_REPORT_RESOURCE; String report = Resources.toString(resourceUrl, Charset.forName("UTF-8")); when(reportService.getReportJobStatus(Matchers.anyLong())) .thenReturn(ReportJobStatus.COMPLETED); when(reportService.getReportDownloadUrlWithOptions( Matchers.anyLong(), Matchers.any(ReportDownloadOptions.class))) .thenReturn(resourceUrl.toString()); ReportDownloadOptions options = new ReportDownloadOptions(); options.setExportFormat(ExportFormat.CSV_DUMP); options.setUseGzipCompression(false); CharSource reportCharSource = downloader.getReportAsCharSource(options); assertEquals(report, reportCharSource.read()); }
public CharSource getReportAsCharSource(ReportDownloadOptions options) throws IOException { Preconditions.checkArgument( SUPPORTED_CHARSOURCE_EXPORT_FORMATS.contains(options.getExportFormat()), "ExportFormat " + options.getExportFormat() + " cannot be used with CharSource"); ByteSource byteSource = Resources.asByteSource(getDownloadUrl(options)); return (options.getUseGzipCompression() ? new GZippedByteSource(byteSource) : byteSource) .asCharSource(REPORT_CHARSET); }
ReportDownloader { public CharSource getReportAsCharSource(ReportDownloadOptions options) throws IOException { Preconditions.checkArgument( SUPPORTED_CHARSOURCE_EXPORT_FORMATS.contains(options.getExportFormat()), "ExportFormat " + options.getExportFormat() + " cannot be used with CharSource"); ByteSource byteSource = Resources.asByteSource(getDownloadUrl(options)); return (options.getUseGzipCompression() ? new GZippedByteSource(byteSource) : byteSource) .asCharSource(REPORT_CHARSET); } }
ReportDownloader { public CharSource getReportAsCharSource(ReportDownloadOptions options) throws IOException { Preconditions.checkArgument( SUPPORTED_CHARSOURCE_EXPORT_FORMATS.contains(options.getExportFormat()), "ExportFormat " + options.getExportFormat() + " cannot be used with CharSource"); ByteSource byteSource = Resources.asByteSource(getDownloadUrl(options)); return (options.getUseGzipCompression() ? new GZippedByteSource(byteSource) : byteSource) .asCharSource(REPORT_CHARSET); } ReportDownloader(ReportServiceInterface reportService, long reportJobId); @VisibleForTesting  ReportDownloader(ReportServiceInterface reportService, long reportJobId, Sleeper sleeper); }
ReportDownloader { public CharSource getReportAsCharSource(ReportDownloadOptions options) throws IOException { Preconditions.checkArgument( SUPPORTED_CHARSOURCE_EXPORT_FORMATS.contains(options.getExportFormat()), "ExportFormat " + options.getExportFormat() + " cannot be used with CharSource"); ByteSource byteSource = Resources.asByteSource(getDownloadUrl(options)); return (options.getUseGzipCompression() ? new GZippedByteSource(byteSource) : byteSource) .asCharSource(REPORT_CHARSET); } ReportDownloader(ReportServiceInterface reportService, long reportJobId); @VisibleForTesting  ReportDownloader(ReportServiceInterface reportService, long reportJobId, Sleeper sleeper); Thread whenReportReady(final ReportCallback callback); boolean waitForReportReady(); URL getDownloadUrl(ReportDownloadOptions options); CharSource getReportAsCharSource(ReportDownloadOptions options); }
ReportDownloader { public CharSource getReportAsCharSource(ReportDownloadOptions options) throws IOException { Preconditions.checkArgument( SUPPORTED_CHARSOURCE_EXPORT_FORMATS.contains(options.getExportFormat()), "ExportFormat " + options.getExportFormat() + " cannot be used with CharSource"); ByteSource byteSource = Resources.asByteSource(getDownloadUrl(options)); return (options.getUseGzipCompression() ? new GZippedByteSource(byteSource) : byteSource) .asCharSource(REPORT_CHARSET); } ReportDownloader(ReportServiceInterface reportService, long reportJobId); @VisibleForTesting  ReportDownloader(ReportServiceInterface reportService, long reportJobId, Sleeper sleeper); Thread whenReportReady(final ReportCallback callback); boolean waitForReportReady(); URL getDownloadUrl(ReportDownloadOptions options); CharSource getReportAsCharSource(ReportDownloadOptions options); static final Charset REPORT_CHARSET; static final int SLEEP_TIMER; }