@Override public com.google.api.ads.adwords.lib.utils.DetailedReportDownloadResponseException build( int httpStatus, String errorText) { return new DetailedReportDownloadResponseException(httpStatus, errorText); } }
@Test public void testFailure_failedStatusCode() throws Exception { InputStream stream = new ByteArrayInputStream(ERROR_TEXT.getBytes(AdHocReportDownloadHelper.REPORT_CHARSET)); int statusCode = 400; RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(statusCode, stream, AdHocReportDownloadHelper.REPORT_CHARSET, DownloadFormat.XML.name()); try { downloadReport(DownloadFormat.XML, rawResponse, ERROR_TEXT); fail("Should have thrown an exception"); } catch (DetailedReportDownloadResponseException e) { assertEquals(statusCode, e.getHttpStatus()); assertEquals(ERROR_TEXT, e.getErrorText()); assertThat(e.toString(), org.hamcrest.Matchers.containsString(String.valueOf(statusCode))); assertThat(e.toString(), org.hamcrest.Matchers.containsString(ERROR_TEXT)); } }
@Override public com.google.api.ads.adwords.lib.utils.DetailedReportDownloadResponseException build( int httpStatus, String errorText) { return new DetailedReportDownloadResponseException(httpStatus, errorText); } }