### Question:
DefaultPojoDao implements PojoDao<P> { @Override public ListenableFuture<Void> saveAsync(P pojo) { return completeAsync(group -> save(group, StatementOptionsBuilder.empty(), pojo, defaultTtl)); } DefaultPojoDao(Session session, PojoBinding<P> binding, String tableName, PojoStatementFactory statementFactory, PojoQueryContextFactory contextFactory, Executor executor); @Override void delete(P pojo); @Override void delete(StatementOptions options, P pojo); @Override void delete(UpdateGroup group, P pojo); @Override void delete(UpdateGroup group, StatementOptions options, P pojo); @Override ListenableFuture<Void> deleteAsync(P pojo); @Override ListenableFuture<Void> deleteAsync(StatementOptions options, P pojo); @Override void deleteByKey(Object... values); @Override void deleteByKey(StatementOptions options, Object... values); @Override void deleteByKey(UpdateGroup group, StatementOptions options, Object... values); @Override ListenableFuture<Void> deleteByKeyAsync(Object... values); @Override ListenableFuture<Void> deleteByKeyAsync(StatementOptions options, Object... values); @Override PojoQueryBuilder<P> find(); @Override PojoQuery<P> find(Consumer<Select.Where> builder); @Override P findByKey(Object... values); @Override P findByKey(StatementOptions options, Object... values); @Override PojoMultiQuery<P> findByKeys(); @Override PojoMultiQuery<P> findByKeys(StatementOptions options); @Override void save(P pojo); @Override void save(P pojo, int ttl); @Override void save(StatementOptions options, P pojo); @Override void save(UpdateGroup group, P pojo); @Override void save(StatementOptions options, P pojo, int ttl); @Override void save(UpdateGroup group, P pojo, int ttl); @Override void save(UpdateGroup group, StatementOptions options, P pojo); @Override void save(UpdateGroup group, StatementOptions options, P pojo, int ttl); @Override ListenableFuture<Void> saveAsync(P pojo); @Override ListenableFuture<Void> saveAsync(P pojo, int ttl); @Override ListenableFuture<Void> saveAsync(StatementOptions options, P pojo); @Override ListenableFuture<Void> saveAsync(StatementOptions options, P pojo, int ttl); static final int NO_TTL; }### Answer:
@Test public void testSaveWithTtlAnnotationAsync() throws Exception { TtlEntity entity = new TtlEntity(); createPojoDao(TtlEntity.class).saveAsync(entity).get(); assertTrue(ttlOf(entity) > 0); }
@Test public void testSaveWithTtlOverrideAsync() throws Exception { TtlEntity entity = new TtlEntity(); createPojoDao(TtlEntity.class).saveAsync(entity, 60000).get(5, TimeUnit.SECONDS); assertTrue(ttlOf(entity) > 30000); }
@Test public void testSaveWithStatementOptionsAsync() throws Exception { long now = System.currentTimeMillis() + 200000; TtlEntity entity = new TtlEntity(); createPojoDao(TtlEntity.class).saveAsync(StatementOptionsBuilder.defaultTimestamp(now).build(), entity).get(5, TimeUnit.SECONDS); assertEquals(now, writeTime(entity)); }
@Test public void testSaveWithStatementOptionsAndTtlAsync() throws Exception { long now = System.currentTimeMillis() + 200000; TtlEntity entity = new TtlEntity(); createPojoDao(TtlEntity.class).saveAsync(StatementOptionsBuilder.defaultTimestamp(now).build(), entity, 60000).get(5, TimeUnit.SECONDS); assertEquals(now, writeTime(entity)); assertTrue(ttlOf(entity) > 30000); }