@Test
  public void testFindRevision() {
    AuditReader vr = getAuditReader();

    long rev1Timestamp =
        vr.findRevision(CustomPropertyAccessRevEntity.class, 1).getCustomTimestamp();
    assert rev1Timestamp > timestamp1;
    assert rev1Timestamp <= timestamp2;

    long rev2Timestamp =
        vr.findRevision(CustomPropertyAccessRevEntity.class, 2).getCustomTimestamp();
    assert rev2Timestamp > timestamp2;
    assert rev2Timestamp <= timestamp3;
  }
  /**
   * Returns an entity in the given revision for the given entity-id.
   *
   * @param revisionNumber
   * @param id
   * @param reader
   * @return
   */
  @SuppressWarnings("unchecked")
  private Revision<N, T> getEntityForRevision(N revisionNumber, ID id, AuditReader reader) {

    Class<?> type = revisionEntityInformation.getRevisionEntityClass();

    T revision = (T) reader.findRevision(type, revisionNumber);
    Object entity = reader.find(entityInformation.getJavaType(), id, revisionNumber);

    return new Revision<N, T>((RevisionMetadata<N>) getRevisionMetadata(revision), (T) entity);
  }
  /*
   * (non-Javadoc)
   * @see org.springframework.data.repository.history.RevisionRepository#findLastChangeRevision(java.io.Serializable)
   */
  @SuppressWarnings("unchecked")
  public Revision<N, T> findLastChangeRevision(ID id) {

    Class<T> type = entityInformation.getJavaType();
    AuditReader reader = AuditReaderFactory.get(entityManager);

    List<Number> revisions = reader.getRevisions(type, id);

    if (revisions.isEmpty()) {
      return null;
    }

    N latestRevision = (N) revisions.get(revisions.size() - 1);

    Class<?> revisionEntityClass = revisionEntityInformation.getRevisionEntityClass();

    Object revisionEntity = reader.findRevision(revisionEntityClass, latestRevision);
    RevisionMetadata<N> metadata = (RevisionMetadata<N>) getRevisionMetadata(revisionEntity);
    return new Revision<N, T>(metadata, reader.find(type, id, latestRevision));
  }