@Test
  public void testKeys() {
    byte[] row = Bytes.toBytes("10");
    byte[] fam = Bytes.toBytes("balance");
    byte[] col = Bytes.toBytes("main");
    long ts1 = 11l;
    long ts2 = 10l;

    kvs.clear();
    KeyValue first = new KeyValue(row, fam, col, ts1, KeyValue.Type.Put);
    KeyValue second = new KeyValue(row, fam, col, ts2, KeyValue.Type.Put);
    kvs.add(first);
    kvs.add(second);
    Collections.sort(kvs, KeyValue.COMPARATOR);
    Iterable<KeyVersions<HKey>> versions = HRegionTransactionManager.transform(kvs);

    HKey expected = new HKey(row, fam, col);

    Iterator<KeyVersions<HKey>> it = versions.iterator();
    Assert.assertTrue(it.hasNext());
    Assert.assertEquals(expected, it.next().getKey());
    Assert.assertFalse(it.hasNext());

    it = versions.iterator();
    Assert.assertTrue(it.hasNext());
    KeyVersions<HKey> kv = it.next();
    Assert.assertEquals(expected, kv.getKey());
    Iterator<Long> vs = kv.getVersions().iterator();
    Assert.assertTrue(vs.hasNext());
    Assert.assertEquals((Long) ts1, vs.next());
    Assert.assertTrue(vs.hasNext());
    Assert.assertEquals((Long) ts2, vs.next());
    Assert.assertFalse(vs.hasNext());
  }
 @Test
 public void testVersionIterator() {
   Iterable<KeyVersions<HKey>> versions = HRegionTransactionManager.transform(kvs);
   for (KeyVersions<HKey> kv : versions) {
     for (Iterator<Long> it = kv.getVersions().iterator(); it.hasNext(); ) {
       it.next();
       while (it.hasNext()) {
         it.next();
         it.remove();
       }
     }
   }
   for (KeyVersions<HKey> vs : versions)
     for (Long version : vs.getVersions()) Assert.assertEquals(Long.valueOf(2L), version);
   Assert.assertEquals(4, kvs.size());
 }