@Test public void throwsIfTryingToPutUnlessExistsInvalidTimestamp() { assertThatThrownBy(() -> preStartHandlingService.putUnlessExists(NEGATIVE_TIMESTAMP, COMMIT_TIMESTAMP)) .isInstanceOf(SafeIllegalStateException.class) .hasMessageContaining("Attempted to putUnlessExists") .hasMessageContaining("is disallowed"); }
@Override public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { if (!isTimestampValid(startTimestamp)) { throw new SafeIllegalStateException("Attempted to putUnlessExists({}, {}) which is disallowed.", SafeArg.of("startTimestamp", startTimestamp), SafeArg.of("commitTimestamp", commitTimestamp)); } delegate.putUnlessExists(startTimestamp, commitTimestamp); }
PreStartHandlingTransactionService implements TransactionService { @Override public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { if (!isTimestampValid(startTimestamp)) { throw new SafeIllegalStateException("Attempted to putUnlessExists({}, {}) which is disallowed.", SafeArg.of("startTimestamp", startTimestamp), SafeArg.of("commitTimestamp", commitTimestamp)); } delegate.putUnlessExists(startTimestamp, commitTimestamp); } }
PreStartHandlingTransactionService implements TransactionService { @Override public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { if (!isTimestampValid(startTimestamp)) { throw new SafeIllegalStateException("Attempted to putUnlessExists({}, {}) which is disallowed.", SafeArg.of("startTimestamp", startTimestamp), SafeArg.of("commitTimestamp", commitTimestamp)); } delegate.putUnlessExists(startTimestamp, commitTimestamp); } PreStartHandlingTransactionService(TransactionService delegate); }
PreStartHandlingTransactionService implements TransactionService { @Override public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { if (!isTimestampValid(startTimestamp)) { throw new SafeIllegalStateException("Attempted to putUnlessExists({}, {}) which is disallowed.", SafeArg.of("startTimestamp", startTimestamp), SafeArg.of("commitTimestamp", commitTimestamp)); } delegate.putUnlessExists(startTimestamp, commitTimestamp); } PreStartHandlingTransactionService(TransactionService delegate); @CheckForNull @Override Long get(long startTimestamp); @Override Map<Long, Long> get(Iterable<Long> startTimestamps); @Override ListenableFuture<Long> getAsync(long startTimestamp); @Override ListenableFuture<Map<Long, Long>> getAsync(Iterable<Long> startTimestamps); @Override void putUnlessExists(long startTimestamp, long commitTimestamp); @Override void close(); }
PreStartHandlingTransactionService implements TransactionService { @Override public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { if (!isTimestampValid(startTimestamp)) { throw new SafeIllegalStateException("Attempted to putUnlessExists({}, {}) which is disallowed.", SafeArg.of("startTimestamp", startTimestamp), SafeArg.of("commitTimestamp", commitTimestamp)); } delegate.putUnlessExists(startTimestamp, commitTimestamp); } PreStartHandlingTransactionService(TransactionService delegate); @CheckForNull @Override Long get(long startTimestamp); @Override Map<Long, Long> get(Iterable<Long> startTimestamps); @Override ListenableFuture<Long> getAsync(long startTimestamp); @Override ListenableFuture<Map<Long, Long>> getAsync(Iterable<Long> startTimestamps); @Override void putUnlessExists(long startTimestamp, long commitTimestamp); @Override void close();  }