@Test
public void adaptResponse_oneRow() {

  String family1 = "family1";
  String family2 = "family2";
  byte[] qualifier1 = "qualifier1".getBytes();
  byte[] qualifier2 = "qualifier2".getBytes();
  byte[] value1 = "value1".getBytes();
  byte[] value2 = "value2".getBytes();
  byte[] value3 = "value3".getBytes();
  byte[] value4 = "value4".getBytes();
  byte[] value5 = "value5".getBytes();
  byte[] value6 = "value6".getBytes();
  FlatRow row =
      FlatRow.newBuilder()
          .withRowKey(ByteString.copyFromUtf8("key"))
          // First cell.
          .addCell(family1, ByteString.copyFrom(qualifier1), 54321L, ByteString.copyFrom(value1))
          // Same family, same column, but different timestamps.
          .addCell(family1, ByteString.copyFrom(qualifier1), 12345L, ByteString.copyFrom(value2))
          // With label
          .addCell(
              family1,
              ByteString.copyFrom(qualifier1),
              12345L,
              ByteString.copyFrom(value6),
              Collections.singletonList("label"))
          // Same family, same timestamp, but different column.
          .addCell(family1, ByteString.copyFrom(qualifier2), 54321L, ByteString.copyFrom(value3))
          // Same column, same timestamp, but different family.
          .addCell(family2, ByteString.copyFrom(qualifier1), 54321L, ByteString.copyFrom(value4))
          // Same timestamp, but different family qualifier2 column.
          .addCell(family2, ByteString.copyFrom(qualifier2), 54321L, ByteString.copyFrom(value5))
          .build();
  Result result = instance.adaptResponse(row);
  assertEquals(6, result.rawCells().length);
  List<org.apache.hadoop.hbase.Cell> cells1 =
      result.getColumnCells(family1.getBytes(), qualifier1);
  assertEquals(3, cells1.size());
  assertEquals(Bytes.toString(value1), Bytes.toString(CellUtil.cloneValue(cells1.get(0))));
  assertEquals(Bytes.toString(value2), Bytes.toString(CellUtil.cloneValue(cells1.get(1))));
  assertEquals(Bytes.toString(value6), Bytes.toString(CellUtil.cloneValue(cells1.get(2))));
  List<org.apache.hadoop.hbase.Cell> cells2 =
      result.getColumnCells(family1.getBytes(), qualifier2);
  assertEquals(1, cells2.size());
  assertEquals(Bytes.toString(value3), Bytes.toString(CellUtil.cloneValue(cells2.get(0))));
  List<org.apache.hadoop.hbase.Cell> cells3 =
      result.getColumnCells(family2.getBytes(), qualifier1);
  assertEquals(1, cells3.size());
  assertEquals(Bytes.toString(value4), Bytes.toString(CellUtil.cloneValue(cells3.get(0))));
  List<org.apache.hadoop.hbase.Cell> cells4 =
      result.getColumnCells(family2.getBytes(), qualifier2);
  assertEquals(1, cells4.size());
  assertEquals(Bytes.toString(value5), Bytes.toString(CellUtil.cloneValue(cells4.get(0))));
  // The duplicate row and label cells have been removed. The timestamp micros get converted to
  // millisecond accuracy.
  FlatRow expected =
      FlatRow.newBuilder()
          .withRowKey(ByteString.copyFromUtf8("key"))
          // First cell.
          .addCell(family1, ByteString.copyFrom(qualifier1), 54000L, ByteString.copyFrom(value1))
          // Same family, same column, but different timestamps.
          .addCell(family1, ByteString.copyFrom(qualifier1), 12000L, ByteString.copyFrom(value2))
          // With label
          .addCell(
              family1,
              ByteString.copyFrom(qualifier1),
              12000L,
              ByteString.copyFrom(value6),
              Collections.singletonList("label"))
          // Same family, same timestamp, but different column.
          .addCell(family1, ByteString.copyFrom(qualifier2), 54000L, ByteString.copyFrom(value3))
          // Same column, same timestamp, but different family.
          .addCell(family2, ByteString.copyFrom(qualifier1), 54000L, ByteString.copyFrom(value4))
          // Same timestamp, but different family and column.
          .addCell(family2, ByteString.copyFrom(qualifier2), 54000L, ByteString.copyFrom(value5))
          .build();
  assertEquals(expected, transformToFlatRow(result));
}