-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathRepeatedCollectManagerTest.java
More file actions
42 lines (37 loc) · 1.32 KB
/
RepeatedCollectManagerTest.java
File metadata and controls
42 lines (37 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package io.arex.inst.runtime.context;
import static org.junit.jupiter.api.Assertions.*;
import io.arex.inst.runtime.config.ConfigBuilder;
import io.arex.inst.runtime.log.LogManager;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
/**
* @since 2024/1/12
*/
class RepeatedCollectManagerTest {
private static MockedStatic<LogManager> logManagerMockedStatic;
@BeforeAll
static void setUp() {
Mockito.mockStatic(ContextManager.class);
logManagerMockedStatic = Mockito.mockStatic(LogManager.class);
}
@AfterAll
static void tearDown() {
Mockito.clearAllCaches();
}
@Test
void test() {
assertTrue(RepeatedCollectManager.validate());
assertTrue(RepeatedCollectManager.exitAndValidate("test"));
Mockito.when(ContextManager.needRecord()).thenReturn(true);
RepeatedCollectManager.enter();
RepeatedCollectManager.enter();
// enable debug
ConfigBuilder.create("test").enableDebug(true).build();
assertFalse(RepeatedCollectManager.exitAndValidate("test"));
logManagerMockedStatic.verify(() -> LogManager.info("repeat", "test"));
assertTrue(RepeatedCollectManager.exitAndValidate("test"));
}
}