AbstractDao implements CrudDao<T, ID> { private void updateAuditInfo(final Object value) { updateAuditInfo(value, principalName.get(), new Date(), mapper.getCreatedByColumnName(), mapper.getCreatedDateColumnName(), mapper.getUpdatedByColumnName(), mapper.getUpdatedDateColumnName()); } protected  AbstractDao(Mapper<T, ID> mapper, Supplier<Object, Object, Object, Object> supplier); R withCommitTransaction(TransFunc<R> transFunc); R withRollbackTransaction(TransFunc<R> transFunc); R withTransaction(TransFunc<R> transFunc, boolean commit); static R withTransaction(TransFunc<R> transFunc, boolean commit, Supplier<Object, Object, Object, Object> supplier); int count(); @Override int count(Object parentKey); void delete(ID id); @Override void delete(Object parentKey, ID id); void delete(Iterable<ID> ids); T get(ID id); @Override T get(Object parentKey, ID id); @Override ID put(Object parentKey, ID id, T entity); ID put(T entity); @Override ID insert(Object parentKey, ID id, T entity); CursorPage<T> queryPage(int requestedPageSize, String cursorString); @Override CursorPage<T> queryPage(Object ancestorKey, int requestedPageSize, String cursorString); Future<T> getAsync(Object parentKey, ID id); Future<ID> putAsync(T entity); ID getId(Object key); Object getKey(ID id); Object getKey(Object parentKey, ID id); String getKind(); void setParentKey(T entity, Object parentKey); static void setPrincipalName(String name);  }
@Test public void testAuditInfoCreated() { DUserMapper mapper = new DUserMapper(supplier); Object actual = supplier.createWriteValue(mapper, null, 1L, null); Date date = new Date(); userDao.updateAuditInfo(actual, "first", date, "createdBy", "birthDate", null, null); assertEquals("first", supplier.getString(actual, "createdBy")); assertEquals(date, supplier.getDate(actual, "birthDate")); userDao.updateAuditInfo(actual, "second", new Date(0L), "createdBy", "birthDate", null, null); assertEquals("first", supplier.getString(actual, "createdBy")); assertEquals(date, supplier.getDate(actual, "birthDate")); }
@Test public void testAuditInfoUpdated() { DUserMapper mapper = new DUserMapper(supplier); Object actual = supplier.createWriteValue(mapper, null, 1L, null); Date date = new Date(); userDao.updateAuditInfo(actual, "first", date, null, null, "createdBy", "birthDate"); assertEquals("first", supplier.getString(actual, "createdBy")); assertEquals(date, supplier.getDate(actual, "birthDate")); Date date1 = new Date(0L); userDao.updateAuditInfo(actual, "second", date1, null, null, "createdBy", "birthDate"); assertEquals("second", supplier.getString(actual, "createdBy")); assertEquals(date1, supplier.getDate(actual, "birthDate")); userDao.updateAuditInfo(actual, null, null, null, null, "createdBy", "birthDate"); assertEquals("second", supplier.getString(actual, "createdBy")); assertEquals(date1, supplier.getDate(actual, "birthDate")); }