TestTimeUtil: Allow to get current timestamp
This allows tests to know what the next timestamp is going to be and use
this timestamp for test assertions.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I63f63d877bce406967d5bc6ab00d26c3aaae2908
diff --git a/java/com/google/gerrit/testing/TestTimeUtil.java b/java/com/google/gerrit/testing/TestTimeUtil.java
index 9228123..2020e5d 100644
--- a/java/com/google/gerrit/testing/TestTimeUtil.java
+++ b/java/com/google/gerrit/testing/TestTimeUtil.java
@@ -118,6 +118,15 @@
clockMs.addAndGet(clockStepUnit.toMillis(clockStep));
}
+ /**
+ * Returns the current timestamp.
+ *
+ * @return current timestamp
+ */
+ public static synchronized Timestamp getCurrentTimestamp() {
+ return new Timestamp(clockMs.get());
+ }
+
/** Reset the clock to use the actual system clock. */
public static synchronized void useSystemTime() {
clockMs = null;