@Test
public void testCellsAreDeduplicated() {

  Append append = new Append(Bytes.toBytes("Ignored"));
  append.add(Bytes.toBytes("fam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1.1"));
  append.add(Bytes.toBytes("fam1"), Bytes.toBytes("qual2"), Bytes.toBytes("val2.1"));
  append.add(Bytes.toBytes("fam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1.2"));
  // Different family, should not be in the results:
  append.add(Bytes.toBytes("fam2"), Bytes.toBytes("qual1"), Bytes.toBytes("val1.2"));
  List<Cell> deduplicatedCells =
      CellDeduplicationHelper.deduplicateFamily(append, Bytes.toBytes("fam1"));
  // Expect a single value for qual1 and qual2.
  Assert.assertEquals(2, deduplicatedCells.size());
  for (Cell cell : deduplicatedCells) {
    byte[] family = CellUtil.cloneFamily(cell);
    Assert.assertArrayEquals(Bytes.toBytes("fam1"), family);
    if (Arrays.equals(Bytes.toBytes("qual1"), CellUtil.cloneQualifier(cell))) {
      Assert.assertArrayEquals(Bytes.toBytes("val1.2"), CellUtil.cloneValue(cell));
    } else if (Arrays.equals(Bytes.toBytes("qual2"), CellUtil.cloneQualifier(cell))) {
      Assert.assertArrayEquals(Bytes.toBytes("val2.1"), CellUtil.cloneValue(cell));
    } else {
      Assert.fail(
          "Unexpected qualifier encountered: " + Bytes.toString(CellUtil.cloneQualifier(cell)));
    }
  }
}