blob: f5574b020a0cf992e43e2114b23e06167ba5a0cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;
import java.util.Random;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class MockUtils {
public static MonotonicNanoClock mockedClockReturning(Long ts, Long... additionalTimestamps) {
var clock = mock(MonotonicNanoClock.class);
when(clock.nanoTimeNow()).thenReturn(ts, additionalTimestamps);
return clock;
}
// Extremely high quality randomness :D
public static Random mockedRandomReturning(Double v, Double... additionalValues) {
var rng = mock(Random.class);
when(rng.nextDouble()).thenReturn(v, additionalValues);
return rng;
}
}
|