|
19 | 19 | import java.lang.annotation.Retention;
|
20 | 20 | import java.lang.annotation.RetentionPolicy;
|
21 | 21 | import java.lang.annotation.Target;
|
22 |
| -import java.util.Arrays; |
23 | 22 | import java.util.List;
|
24 | 23 |
|
25 | 24 | import org.eclipse.jgit.lib.StoredConfig;
|
26 | 25 | import org.eclipse.jgit.util.SystemReader;
|
27 |
| -import org.junit.jupiter.api.extension.AfterAllCallback; |
28 |
| -import org.junit.jupiter.api.extension.BeforeAllCallback; |
| 26 | +import org.junit.jupiter.api.extension.AfterEachCallback; |
| 27 | +import org.junit.jupiter.api.extension.BeforeEachCallback; |
29 | 28 | import org.junit.jupiter.api.extension.ExtendWith;
|
30 | 29 | import org.junit.jupiter.api.extension.ExtensionContext;
|
31 | 30 | import org.junit.jupiter.api.parallel.ResourceAccessMode;
|
|
37 | 36 | @ResourceLock(value = "GIT", mode = ResourceAccessMode.READ_WRITE)
|
38 | 37 | public @interface ClearGitConfig {
|
39 | 38 |
|
40 |
| - class GitConfigExtension implements BeforeAllCallback, AfterAllCallback { |
| 39 | + class GitConfigExtension implements BeforeEachCallback, AfterEachCallback { |
41 | 40 |
|
42 | 41 | @Override
|
43 |
| - public void beforeAll(ExtensionContext extensionContext) throws Exception { |
| 42 | + public void beforeEach(ExtensionContext extensionContext) throws Exception { |
44 | 43 | for (var config : getConfigs()) {
|
45 | 44 | config.clear();
|
46 | 45 | }
|
47 | 46 | }
|
48 | 47 |
|
49 | 48 | @Override
|
50 |
| - public void afterAll(ExtensionContext extensionContext) throws Exception { |
| 49 | + public void afterEach(ExtensionContext extensionContext) throws Exception { |
51 | 50 | for (var config : getConfigs()) {
|
52 | 51 | config.load();
|
53 | 52 | }
|
54 | 53 | }
|
55 | 54 |
|
56 |
| - private List<StoredConfig> getConfigs() throws Exception { |
| 55 | + private static List<StoredConfig> getConfigs() throws Exception { |
57 | 56 | var reader = SystemReader.getInstance();
|
58 |
| - return Arrays.asList(reader.getUserConfig(), reader.getSystemConfig()); |
| 57 | + return List.of(reader.getUserConfig(), reader.getSystemConfig()); |
59 | 58 | }
|
60 | 59 | }
|
61 | 60 | }
|
0 commit comments