Skip to content

Commit cbe51d4

Browse files
s1ckknutwalker
andcommitted
Add unit test for n:1 token:user mapping
Co-Authored-By: Paul Horn <paul.horn@neotechnology.com>
1 parent c38c5fd commit cbe51d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core-utils/src/main/java/org/neo4j/gds/core/utils/ClockService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.time.Clock;
2323
import java.util.concurrent.atomic.AtomicReference;
24+
import java.util.function.Consumer;
2425

2526
public final class ClockService {
2627

@@ -37,4 +38,13 @@ public static Clock clock() {
3738
}
3839

3940
private ClockService() {}
41+
42+
public static <T extends Clock> void runWithClock(T clock, Consumer<T> runnable) {
43+
Clock previousClock = CLOCK.getAndSet(clock);
44+
try {
45+
runnable.accept(clock);
46+
} finally {
47+
CLOCK.set(previousClock);
48+
}
49+
}
4050
}

0 commit comments

Comments
 (0)