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
This commit is contained in:
Edwin Kempin
2019-03-19 14:27:30 +01:00
parent 1656bd9838
commit c8424c5566

View File

@@ -118,6 +118,15 @@ public class TestTimeUtil {
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;