コード例 #1
0
 @Test
 public void testHBColumnMultiVersion() {
   Double[] testNumbers = new Double[] {3.14159, 2.71828, 0.0};
   for (Double n : testNumbers) {
     // Written as unversioned, read as versioned
     Result result = hbMapper.writeValueAsResult(new CrawlNoVersion("key").setF1(n));
     Crawl versioned = hbMapper.readValue(result, Crawl.class);
     NavigableMap<Long, Double> columnHistory = versioned.getF1();
     assertEquals("Column history size mismatch", 1, columnHistory.size());
     assertEquals(
         String.format(
             "Inconsistency between %s and %s",
             HBColumn.class.getSimpleName(), HBColumnMultiVersion.class.getSimpleName()),
         n,
         columnHistory.lastEntry().getValue());
     // Written as versioned, read as unversioned
     Result result1 =
         hbMapper.writeValueAsResult(
             new Crawl("key")
                 .addF1(Double.MAX_VALUE)
                 .addF1(Double.MAX_VALUE)
                 .addF1(Double.MAX_VALUE)
                 .addF1(n));
     CrawlNoVersion unversioned = hbMapper.readValue(result1, CrawlNoVersion.class);
     Double f1 = unversioned.getF1();
     assertEquals(
         String.format(
             "Inconsistency between %s and %s",
             HBColumnMultiVersion.class.getSimpleName(), HBColumn.class.getSimpleName()),
         n,
         f1);
   }
 }