AuditableWrapper implements Auditable { @Override public Object getId() { return wrapper.getPropertyValue(repositoryMetadata.getIdentifierProperty()); } AuditableWrapper(Object entity, RepositoryMetadata repositoryMetadata); @Override @Nonnull Optional<Object> getCreatedBy(); @Override void setCreatedBy(@Nonnull Object createdBy); @Override @Nonnull Optional<Instant> getCreatedDate(); @Override void setCreatedDate(@Nonnull TemporalAccessor creationDate); @Override @Nonnull Optional<Object> getLastModifiedBy(); @Override void setLastModifiedBy(@Nonnull Object lastModifiedBy); @Override @Nonnull Optional<Instant> getLastModifiedDate(); @Override void setLastModifiedDate(@Nonnull TemporalAccessor lastModifiedDate); @Override Object getId(); @Override boolean isNew();  }
@Test public void testGettingIdentifier() { final RepositoryMetadata repositoryMetadata = new ImmutableRepositoryMetadata(String.class, EntityWithCreatedBy.class, null, "id"); final EntityWithCreatedBy entity = new EntityWithCreatedBy(); final AuditableWrapper wrapper = new AuditableWrapper(entity, repositoryMetadata); assertThat(wrapper.getId(), is(nullValue())); entity.setId("some identifier"); assertThat(wrapper.getId(), is(notNullValue())); assertThat(wrapper.getId(), is(entity.getId())); }