@Test public void testFailure_cannotReadStream() throws Exception { InputStream stream = Mockito.mock(InputStream.class); when(stream.read(isA(byte[].class))).thenThrow(new IOException()); RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(400, stream, AdHocReportDownloadHelper.REPORT_CHARSET, DownloadFormat.CSV.name()); try { downloadReport(DownloadFormat.CSV, rawResponse, null); fail("Should have thrown an exception"); } catch (ReportDownloadResponseException e) { assertEquals(400, e.getHttpStatus()); } }
@Override public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition) throws ReportException, ReportDownloadResponseException { return adHocReportDownloadHelper.downloadReport( new XmlReportDefinitionRequest(reportDefinition), new DetailedReportDownloadResponseException.Builder()); }
ReportDownloader implements ReportDownloaderInterface { @Override public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition) throws ReportException, ReportDownloadResponseException { return adHocReportDownloadHelper.downloadReport( new XmlReportDefinitionRequest(reportDefinition), new DetailedReportDownloadResponseException.Builder()); } }
ReportDownloader implements ReportDownloaderInterface { @Override public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition) throws ReportException, ReportDownloadResponseException { return adHocReportDownloadHelper.downloadReport( new XmlReportDefinitionRequest(reportDefinition), new DetailedReportDownloadResponseException.Builder()); } ReportDownloader(AdWordsSession session); @Inject  ReportDownloader(AdHocReportDownloadHelper adHocReportDownloadHelper); }
ReportDownloader implements ReportDownloaderInterface { @Override public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition) throws ReportException, ReportDownloadResponseException { return adHocReportDownloadHelper.downloadReport( new XmlReportDefinitionRequest(reportDefinition), new DetailedReportDownloadResponseException.Builder()); } ReportDownloader(AdWordsSession session); @Inject  ReportDownloader(AdHocReportDownloadHelper adHocReportDownloadHelper); @Override ReportDownloadResponse downloadReport(ReportDefinition reportDefinition); @Override ReportDownloadResponse downloadReport(String reportQuery, DownloadFormat format); @Override int getReportDownloadTimeout(); @Override void setReportDownloadTimeout(int reportDownloadTimeout); }
ReportDownloader implements ReportDownloaderInterface { @Override public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition) throws ReportException, ReportDownloadResponseException { return adHocReportDownloadHelper.downloadReport( new XmlReportDefinitionRequest(reportDefinition), new DetailedReportDownloadResponseException.Builder()); } ReportDownloader(AdWordsSession session); @Inject  ReportDownloader(AdHocReportDownloadHelper adHocReportDownloadHelper); @Override ReportDownloadResponse downloadReport(ReportDefinition reportDefinition); @Override ReportDownloadResponse downloadReport(String reportQuery, DownloadFormat format); @Override int getReportDownloadTimeout(); @Override void setReportDownloadTimeout(int reportDownloadTimeout);  }