@Test
  public void convertRequestToJSONAllElementsIntact() {
    PutRecordRequest putRequest = new PutRecordRequest();

    putRequest
        .withStreamName(stream)
        .withPartitionKey(partitionKey)
        .withExplicitHashKey(explicitHashKey)
        .withData(data)
        .withSequenceNumberForOrdering(sequenceNumberForOrdering);

    JSONRecordAdapter adapter = new JSONRecordAdapter();
    JSONObject json = adapter.translateFromRecord(putRequest);

    try {
      assertTrue(json.getString(JSONRecordAdapter.STREAM_NAME_FIELD).equalsIgnoreCase(stream));
      assertTrue(
          json.getString(JSONRecordAdapter.DATA_FIELD_KEY)
              .equalsIgnoreCase(
                  Base64.encodeToString("TestData".getBytes(StringUtils.UTF8), Base64.DEFAULT)));
      assertTrue(
          json.getString(JSONRecordAdapter.PARTITION_KEY_FIELD).equalsIgnoreCase(partitionKey));
      assertTrue(
          json.getString(JSONRecordAdapter.SEQUENCE_NUMBER_FIELD)
              .equalsIgnoreCase(sequenceNumberForOrdering));
      assertTrue(
          json.getString(JSONRecordAdapter.EXPLICIT_HASH_FIELD).equalsIgnoreCase(explicitHashKey));

    } catch (JSONException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  @Test(expected = AmazonClientException.class)
  public void convertRequestWhenPartitionKeyNull() {
    PutRecordRequest putRequest = new PutRecordRequest();
    putRequest.withStreamName(stream).withData(data);

    JSONRecordAdapter adapter = new JSONRecordAdapter();
    adapter.translateFromRecord(putRequest);
  }
  @Test
  public void testStaticGetters() throws JSONException {

    PutRecordRequest putRequest = new PutRecordRequest();
    putRequest.withStreamName(stream).withPartitionKey(partitionKey).withData(data);

    JSONRecordAdapter adapter = new JSONRecordAdapter();
    JSONObject json = adapter.translateFromRecord(putRequest);

    assertArrayEquals(data.array(), JSONRecordAdapter.getData(json).array());
    assertTrue(partitionKey.equalsIgnoreCase(JSONRecordAdapter.getPartitionKey(json)));
    assertTrue(stream.equalsIgnoreCase(JSONRecordAdapter.getStreamName(json)));
  }