### Question:
ReportDownloadResponse { public String getAsString() throws IOException { InputStream inputStream = isGzipped() ? new GZIPInputStream(getInputStream()) : getInputStream(); return Streams.readAll(inputStream, rawResponse.getCharset()); } ReportDownloadResponse(RawReportDownloadResponse rawResponse); int getHttpStatus(); String getHttpResponseMessage(); @Nullable InputStream getInputStream(); String getAsString(); void saveToFile(String outputFile);  }### Answer:
@Test public void testGetAsString() throws IOException { String expectedContents = "a,b,c\nd,e,f\n"; InputStream inputStream = new ByteArrayInputStream(expectedContents.getBytes(UTF_8)); RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(HttpURLConnection.HTTP_OK, inputStream, UTF_8, "CSV"); ReportDownloadResponse response = new ReportDownloadResponse(rawResponse); assertEquals("contents as string are incorrect", expectedContents, response.getAsString()); }
@Test public void testGetAsString_gzippedCSV() throws IOException { String expectedContents = "a,b,c\nd,e,f\n"; ByteArrayOutputStream zippedBytesOut = new ByteArrayOutputStream(); Streams.copy(new ByteArrayInputStream(expectedContents.getBytes(UTF_8)), new GZIPOutputStream(zippedBytesOut)); RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(HttpURLConnection.HTTP_OK, new ByteArrayInputStream(zippedBytesOut.toByteArray()), UTF_8, "GZIPPED_CSV"); ReportDownloadResponse response = new ReportDownloadResponse(rawResponse); assertEquals("contents as string are incorrect for gzipped format", expectedContents, response.getAsString()); }