  @Test
  public void testCountTimestampSamplesWritable() throws Exception {

    CountTimestampSamplesWritable orig =
      new CountTimestampSamplesWritable(7L, 123L, Arrays.asList(18L, 19L, 20L));

    assertEquals(orig.getCount(), 7L);
    assertEquals(orig.getEpochMilliseconds(), 123L);
    assertEquals(Arrays.asList(18L, 19L, 20L), orig.getSamples());

    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);

    orig.write(dataOut);
    CountTimestampSamplesWritable deSerialized = new CountTimestampSamplesWritable(0L, 0L, null);

    deSerialized.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray())));
    assertEquals(orig.getCount(), deSerialized.getCount());
    assertEquals(orig.getEpochMilliseconds(), deSerialized.getEpochMilliseconds());
    assertEquals(orig.getSamples(), deSerialized.getSamples());
  }