public void testResultWithRow(HBRecord p) {
   long start, end;
   Result result = hbMapper.writeValueAsResult(Arrays.asList(p)).get(0);
   ImmutableBytesWritable rowKey = Util.strToIbw(p.composeRowKey());
   start = System.currentTimeMillis();
   Citizen pFromResult = hbMapper.readValue(rowKey, result, Citizen.class);
   end = System.currentTimeMillis();
   assertEquals("Data mismatch after deserialization from Result+Row", p, pFromResult);
   System.out.printf("Time taken for Result+Row->POJO = %dms%n%n", end - start);
 }
 public void testPutWithRow(HBRecord p) {
   long start, end;
   Put put = hbMapper.writeValueAsPut(p);
   ImmutableBytesWritable rowKey = Util.strToIbw(p.composeRowKey());
   start = System.currentTimeMillis();
   Citizen pFromPut = hbMapper.readValue(rowKey, put, Citizen.class);
   end = System.currentTimeMillis();
   assertEquals("Data mismatch after deserialization from Put", p, pFromPut);
   System.out.printf("Time taken for Put->POJO = %dms%n%n", end - start);
 }
 @Test
 public void testInvalidClasses() {
   Set<String> exceptionMessages = new HashSet<String>();
   for (Triplet<HBRecord, String, Class<? extends IllegalArgumentException>> p :
       invalidRecordsAndErrorMessages) {
     HBRecord record = p.getValue0();
     Class recordClass = record.getClass();
     assertFalse(
         "Object mapper couldn't detect invalidity of class " + recordClass.getName(),
         hbMapper.isValid(recordClass));
     String errorMessage =
         p.getValue1()
             + " ("
             + recordClass.getName()
             + ") should have thrown an "
             + IllegalArgumentException.class.getName();
     String exMsgObjToResult = null,
         exMsgObjToPut = null,
         exMsgResultToObj = null,
         exMsgPutToObj = null;
     try {
       hbMapper.writeValueAsResult(record);
       fail(errorMessage + " while converting bean to Result");
     } catch (IllegalArgumentException ex) {
       assertEquals(
           "Mismatch in type of exception thrown for " + recordClass.getSimpleName(),
           p.getValue2(),
           ex.getClass());
       exMsgObjToResult = ex.getMessage();
     }
     try {
       hbMapper.writeValueAsPut(record);
       fail(errorMessage + " while converting bean to Put");
     } catch (IllegalArgumentException ex) {
       assertEquals(
           "Mismatch in type of exception thrown for " + recordClass.getSimpleName(),
           p.getValue2(),
           ex.getClass());
       exMsgObjToPut = ex.getMessage();
     }
     try {
       hbMapper.readValue(someResult, recordClass);
       fail(errorMessage + " while converting Result to bean");
     } catch (IllegalArgumentException ex) {
       assertEquals(
           "Mismatch in type of exception thrown for " + recordClass.getSimpleName(),
           p.getValue2(),
           ex.getClass());
       exMsgResultToObj = ex.getMessage();
     }
     try {
       hbMapper.readValue(
           new ImmutableBytesWritable(someResult.getRow()), someResult, recordClass);
       fail(errorMessage + " while converting Result to bean");
     } catch (IllegalArgumentException ex) {
       assertEquals(
           "Mismatch in type of exception thrown for " + recordClass.getSimpleName(),
           p.getValue2(),
           ex.getClass());
     }
     try {
       hbMapper.readValue(somePut, recordClass);
       fail(errorMessage + " while converting Put to bean");
     } catch (IllegalArgumentException ex) {
       assertEquals(
           "Mismatch in type of exception thrown for " + recordClass.getSimpleName(),
           p.getValue2(),
           ex.getClass());
       exMsgPutToObj = ex.getMessage();
     }
     try {
       hbMapper.readValue(new ImmutableBytesWritable(somePut.getRow()), somePut, recordClass);
       fail(errorMessage + " while converting row key and Put combo to bean");
     } catch (IllegalArgumentException ex) {
       assertEquals("Mismatch in type of exception thrown", p.getValue2(), ex.getClass());
     }
     assertEquals(
         "Validation for 'conversion to Result' and 'conversion to Put' differ in code path",
         exMsgObjToResult,
         exMsgObjToPut);
     assertEquals(
         "Validation for 'conversion from Result' and 'conversion from Put' differ in code path",
         exMsgResultToObj,
         exMsgPutToObj);
     assertEquals(
         "Validation for 'conversion from bean' and 'conversion to bean' differ in code path",
         exMsgObjToResult,
         exMsgResultToObj);
     System.out.printf(
         "%s threw below Exception as expected:\n%s\n%n", p.getValue1(), exMsgObjToResult);
     if (!exceptionMessages.add(exMsgObjToPut)) {
       fail("Same error message for different invalid inputs");
     }
   }
 }