• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / jmockit1 / 496

15 Nov 2025 05:33PM UTC coverage: 72.192% (-0.008%) from 72.2%
496

push

github

web-flow
Merge pull request #412 from hazendaz/renovate/major-spring-core

Update spring core to v7 (major)

5677 of 8360 branches covered (67.91%)

Branch coverage included in aggregate %.

11922 of 16018 relevant lines covered (74.43%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.2
/main/src/main/java/mockit/internal/expectations/ActiveInvocations.java
1
/*
2
 * MIT License
3
 * Copyright (c) 2006-2025 JMockit developers
4
 * See LICENSE file for full license text.
5
 */
6
package mockit.internal.expectations;
7

8
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_BOOLEAN;
9
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_BYTE;
10
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_CHAR;
11
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_DOUBLE;
12
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_FLOAT;
13
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_INT;
14
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_LONG;
15
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_SHORT;
16
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_STRING;
17
import static mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher.ANY_VALUE;
18

19
import edu.umd.cs.findbugs.annotations.NonNull;
20
import edu.umd.cs.findbugs.annotations.Nullable;
21

22
import mockit.internal.expectations.argumentMatching.ArgumentMatcher;
23
import mockit.internal.expectations.transformation.ArgumentCapturing;
24
import mockit.internal.state.TestRun;
25
import mockit.internal.util.ClassLoad;
26

27
import org.checkerframework.checker.index.qual.NonNegative;
28

29
@SuppressWarnings("unused")
1✔
30
public final class ActiveInvocations {
31
    private ActiveInvocations() {
32
    }
33

34
    public static void anyString() {
35
        addArgMatcher(ANY_STRING);
1✔
36
    }
1✔
37

38
    public static void anyBoolean() {
39
        addArgMatcher(ANY_BOOLEAN);
1✔
40
    }
1✔
41

42
    public static void anyChar() {
43
        addArgMatcher(ANY_CHAR);
1✔
44
    }
1✔
45

46
    public static void anyByte() {
47
        addArgMatcher(ANY_BYTE);
1✔
48
    }
1✔
49

50
    public static void anyShort() {
51
        addArgMatcher(ANY_SHORT);
1✔
52
    }
1✔
53

54
    public static void anyInt() {
55
        addArgMatcher(ANY_INT);
1✔
56
    }
1✔
57

58
    public static void anyFloat() {
59
        addArgMatcher(ANY_FLOAT);
1✔
60
    }
1✔
61

62
    public static void anyLong() {
63
        addArgMatcher(ANY_LONG);
1✔
64
    }
1✔
65

66
    public static void anyDouble() {
67
        addArgMatcher(ANY_DOUBLE);
1✔
68
    }
1✔
69

70
    public static void any() {
71
        addArgMatcher(ANY_VALUE);
1✔
72
    }
1✔
73

74
    private static void addArgMatcher(@NonNull ArgumentMatcher<?> argumentMatcher) {
75
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
76

77
        if (instance != null) {
1!
78
            TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
79

80
            if (currentPhase != null) {
1!
81
                currentPhase.addArgMatcher(argumentMatcher);
1✔
82
            }
83
        }
84
    }
1✔
85

86
    public static void moveArgMatcher(@NonNegative int originalMatcherIndex, @NonNegative int toIndex) {
87
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
88

89
        if (instance != null) {
1!
90
            TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
91

92
            if (currentPhase != null) {
1!
93
                currentPhase.moveArgMatcher(originalMatcherIndex, toIndex);
1✔
94
            }
95
        }
96
    }
1✔
97

98
    public static void setExpectedArgumentType(@NonNegative int parameterIndex, @NonNull String typeDesc) {
99
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
100

101
        if (instance != null) {
1!
102
            TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
103

104
            if (currentPhase != null) {
1!
105
                Class<?> argumentType = ClassLoad.loadByInternalName(typeDesc);
1✔
106
                currentPhase.setExpectedSingleArgumentType(parameterIndex, argumentType);
1✔
107
            }
108
        }
109
    }
1✔
110

111
    public static void setExpectedArgumentType(@NonNegative int parameterIndex, int varIndex) {
112
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
113

114
        if (instance != null) {
1!
115
            String typeDesc = ArgumentCapturing.extractArgumentType(varIndex);
1✔
116

117
            if (typeDesc != null) {
1!
118
                TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
119

120
                if (currentPhase != null) {
1!
121
                    Class<?> argumentType = ClassLoad.loadByInternalName(typeDesc);
1✔
122
                    currentPhase.setExpectedMultiArgumentType(parameterIndex, argumentType);
1✔
123
                }
124
            }
125
        }
126
    }
1✔
127

128
    @Nullable
129
    public static Object matchedArgument(@NonNegative int parameterIndex, @Nullable String argTypeDesc) {
130
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
131

132
        if (instance != null) {
1!
133
            BaseVerificationPhase verificationPhase = (BaseVerificationPhase) instance.getCurrentTestOnlyPhase();
1✔
134

135
            if (verificationPhase != null) {
1!
136
                return verificationPhase.getArgumentValueForCurrentVerification(parameterIndex);
1✔
137
            }
138
        }
139

140
        return null;
×
141
    }
142

143
    public static void addResult(@Nullable Object result) {
144
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
145

146
        if (instance != null) {
1!
147
            RecordPhase recordPhase = instance.getRecordPhase();
1✔
148

149
            if (recordPhase != null) {
1!
150
                recordPhase.addResult(result);
1✔
151
            }
152
        }
153
    }
1✔
154

155
    public static void times(int n) {
156
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
157

158
        if (instance != null) {
1!
159
            TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
160

161
            if (currentPhase != null) {
1!
162
                currentPhase.handleInvocationCountConstraint(n, n);
1✔
163
            }
164
        }
165
    }
1✔
166

167
    public static void minTimes(int n) {
168
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
169

170
        if (instance != null) {
1!
171
            TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
172

173
            if (currentPhase != null) {
1!
174
                currentPhase.handleInvocationCountConstraint(n, -1);
1✔
175
            }
176
        }
177
    }
1✔
178

179
    public static void maxTimes(int n) {
180
        RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
181

182
        if (instance != null) {
1!
183
            TestOnlyPhase currentPhase = instance.getCurrentTestOnlyPhase();
1✔
184

185
            if (currentPhase != null) {
1!
186
                currentPhase.setMaxInvocationCount(n);
1✔
187
            }
188
        }
189
    }
1✔
190

191
    public static void endInvocations() {
192
        TestRun.enterNoMockingZone();
1✔
193

194
        try {
195
            RecordAndReplayExecution instance = TestRun.getRecordAndReplayForRunningTest();
1✔
196
            assert instance != null;
1!
197
            instance.endInvocations();
1✔
198
        } finally {
199
            TestRun.exitNoMockingZone();
1✔
200
        }
201
    }
1✔
202
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc