@Test
  public void testEncodeDecodeMatch() {
    int samplesQuantity = 200;
    for (int i = 0; i < samplesQuantity; i++) {
      BigDecimal randomData = BigDecimal
        .valueOf(ThreadLocalRandom.current().nextDouble() + ThreadLocalRandom.current().nextLong());
      PositionedByteRange tmp = new SimplePositionedMutableByteRange(100);
      Order ord = ThreadLocalRandom.current().nextBoolean() ? Order.DESCENDING : Order.ASCENDING;

      OrderedBytes.encodeNumeric(tmp, randomData, ord);
      tmp.setPosition(0);

      BigDecimal left = OrderedBytes.normalize(randomData);
      BigDecimal right = OrderedBytes.decodeNumericAsBigDecimal(tmp);
      assertEquals(0, left.compareTo(right));
    }
  }
Test if the data encoded by our encoding function can be decoded correctly.
hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestOrderedBytes.java