### Question:
PutRecordsRequestMarshaller implements
        Marshaller<Request<PutRecordsRequest>, PutRecordsRequest> { public Request<PutRecordsRequest> marshall(PutRecordsRequest putRecordsRequest) { if (putRecordsRequest == null) { throw new AmazonClientException( "Invalid argument passed to marshall(PutRecordsRequest)"); } Request<PutRecordsRequest> request = new DefaultRequest<PutRecordsRequest>( putRecordsRequest, "AmazonKinesis"); String target = "Kinesis_20131202.PutRecords"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); String uriResourcePath = "/"; request.setResourcePath(uriResourcePath); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(baos, 8192); Writer writer = new OutputStreamWriter(gos, StringUtils.UTF8); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(writer); jsonWriter.beginObject(); if (putRecordsRequest.getRecords() != null) { java.util.List<PutRecordsRequestEntry> records = putRecordsRequest.getRecords(); jsonWriter.name("Records"); jsonWriter.beginArray(); for (PutRecordsRequestEntry recordsItem : records) { if (recordsItem != null) { PutRecordsRequestEntryJsonMarshaller.getInstance().marshall(recordsItem, jsonWriter); } } jsonWriter.endArray(); } if (putRecordsRequest.getStreamName() != null) { String streamName = putRecordsRequest.getStreamName(); jsonWriter.name("StreamName"); jsonWriter.value(streamName); } jsonWriter.endObject(); jsonWriter.flush(); gos.finish(); writer.close(); byte[] content = baos.toByteArray(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Encoding", "gzip"); } catch (Throwable t) { throw new AmazonClientException( "Unable to marshall request to JSON: " + t.getMessage(), t); } if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/x-amz-json-1.1"); } return request; }  Request<PutRecordsRequest> marshall(PutRecordsRequest putRecordsRequest);  }### Answer:
@Test public void test() throws Exception { PutRecordsRequest putRecordsRequest = new PutRecordsRequest(); putRecordsRequest.setStreamName("stream name"); List<PutRecordsRequestEntry> records = new ArrayList<PutRecordsRequestEntry>(); for (int i = 0; i < 10; i++) { PutRecordsRequestEntry record = new PutRecordsRequestEntry(); String randomStr = RandomStringUtils.random(8 * 1024); record.setData(ByteBuffer.wrap(randomStr.getBytes(StringUtils.UTF8))); record.setPartitionKey("partition key"); records.add(record); } putRecordsRequest.setRecords(records); PutRecordsRequestMarshaller marshaller = new PutRecordsRequestMarshaller(); Request<PutRecordsRequest> request = marshaller.marshall(putRecordsRequest); assertEquals("content encoding", "gzip", request.getHeaders().get("Content-Encoding")); byte[] content = IOUtils.toByteArray(request.getContent()); assertEquals("content length", request.getHeaders().get("Content-Length"), String.valueOf(content.length)); GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(content)); String str = IOUtils.toString(gis); assertTrue("content is compressed", content.length < str.length()); Map<String, String> map = JsonUtils.jsonToMap(str); assertEquals("StreamName", "stream name", map.get("StreamName")); }