1
+ /*
2
+ * Copyright 2023 VMware, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
package io .micrometer .core .instrument .step ;
2
17
3
18
import io .micrometer .core .instrument .MockClock ;
19
+ import org .junit .jupiter .api .BeforeEach ;
4
20
import org .junit .jupiter .api .Test ;
5
21
6
22
import java .time .Duration ;
7
23
8
24
import static org .assertj .core .api .Assertions .assertThat ;
9
25
10
26
class StepMaxTest {
27
+
11
28
private final Duration step = Duration .ofMillis (10 );
29
+
12
30
MockClock clock ;
31
+
32
+ @ BeforeEach
33
+ void init () {
34
+ clock = new MockClock ();
35
+ }
36
+
13
37
@ Test
14
38
void testMax () {
15
- clock = new MockClock ();
16
39
StepMax max = new StepMax (clock , step .toMillis ());
17
40
18
41
assertThat (max .poll ()).isZero ();
@@ -32,7 +55,6 @@ void testMax() {
32
55
33
56
@ Test
34
57
void shouldPreserveCurrentAfterManualRollover () {
35
- clock = new MockClock ();
36
58
StepMax max = new StepMax (clock , step .toMillis ());
37
59
38
60
max .record (11 );
@@ -45,4 +67,5 @@ void shouldPreserveCurrentAfterManualRollover() {
45
67
clock .add (step );
46
68
assertThat (max .poll ()).isEqualTo (11 );
47
69
}
70
+
48
71
}
0 commit comments