SecretSeriesDAO { public int setCurrentVersion(long secretId, long secretContentId, String updater, long now) { long checkId; Record1<Long> r = dslContext.select(SECRETS_CONTENT.SECRETID) .from(SECRETS_CONTENT) .where(SECRETS_CONTENT.ID.eq(secretContentId)) .fetchOne(); if (r == null) { throw new BadRequestException( String.format("The requested version %d is not a known version of this secret", secretContentId)); } checkId = r.value1(); if (checkId != secretId) { throw new IllegalStateException(String.format( "tried to reset secret with id %d to version %d, but this version is not associated with this secret", secretId, secretContentId)); } return dslContext.update(SECRETS) .set(SECRETS.CURRENT, secretContentId) .set(SECRETS.UPDATEDBY, updater) .set(SECRETS.UPDATEDAT, now) .where(SECRETS.ID.eq(secretId)) .execute(); } private  SecretSeriesDAO(DSLContext dslContext, ObjectMapper mapper,
      SecretSeriesMapper secretSeriesMapper, RowHmacGenerator rowHmacGenerator); int setExpiration(long secretContentId, Instant expiration); int setHmac(long secretContentId, String hmac); int setCurrentVersion(long secretId, long secretContentId, String updater, long now); Optional<SecretSeries> getSecretSeriesById(long id); Optional<SecretSeries> getSecretSeriesByName(String name); List<SecretSeries> getMultipleSecretSeriesByName(List<String> names); ImmutableList<SecretSeries> getSecretSeries(@Nullable Long expireMaxTime,
      @Nullable Group group, @Nullable Long expireMinTime, @Nullable String minName,
      @Nullable Integer limit); ImmutableList<SecretSeries> getSecretSeriesBatched(int idx, int num, boolean newestFirst); void deleteSecretSeriesByName(String name); void deleteSecretSeriesById(long id); int countDeletedSecretSeries(); List<Long> getIdsForSecretSeriesDeletedBeforeDate(DateTime deleteBefore); long dangerPermanentlyRemoveRecordsForGivenIDs(List<Long> ids);  }
@Test public void setCurrentVersion() { long now = OffsetDateTime.now().toEpochSecond(); long id = secretSeriesDAO.createSecretSeries("toBeDeleted_deleteSecretSeriesByName", "creator", "", null, null, now); Optional<SecretSeries> secretSeriesById = secretSeriesDAO.getSecretSeriesById(id); assertThat(secretSeriesById).isEmpty(); long contentId = secretContentDAO.createSecretContent(id, "blah", "checksum", "creator", null, 0, now); secretSeriesDAO.setCurrentVersion(id, contentId, "updater", now + 3600); secretSeriesById = secretSeriesDAO.getSecretSeriesById(id); assertThat(secretSeriesById.get().currentVersion().get()).isEqualTo(contentId); assertThat(secretSeriesById.get().updatedBy()).isEqualTo("updater"); assertThat(secretSeriesById.get().updatedAt().toEpochSecond()).isEqualTo(now + 3600); }