ProfileHBaseMapper implements HBaseMapper { @Override public Optional<Long> getTTL(Tuple tuple) { Optional<Long> expiresMillis = Optional.empty(); ProfileMeasurement measurement = (ProfileMeasurement) tuple.getValueByField("measurement"); ProfileConfig profileConfig = measurement.getDefinition(); if(profileConfig.getExpires() != null) { long expiresDays = profileConfig.getExpires(); expiresMillis = Optional.of(TimeUnit.DAYS.toMillis(expiresDays)); } return expiresMillis; } ProfileHBaseMapper();  ProfileHBaseMapper(RowKeyBuilder rowKeyBuilder, ColumnBuilder columnBuilder); @Override byte[] rowKey(Tuple tuple); @Override ColumnList columns(Tuple tuple); @Override Optional<Long> getTTL(Tuple tuple); void setRowKeyBuilder(RowKeyBuilder rowKeyBuilder); void setColumnBuilder(ColumnBuilder columnBuilder);  }
@Test public void testExpires() { final Long expiresDays = 30L; profile.setExpires(expiresDays); Optional<Long> actual = mapper.getTTL(tuple); assertTrue(actual.isPresent()); assertEquals(expiresDays, (Long) TimeUnit.MILLISECONDS.toDays(actual.get())); }
@Test public void testExpiresUndefined() { Optional<Long> actual = mapper.getTTL(tuple); assertFalse(actual.isPresent()); }