• 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

93.85
/main/src/main/java/mockit/internal/expectations/UnorderedVerificationPhase.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 edu.umd.cs.findbugs.annotations.NonNull;
9
import edu.umd.cs.findbugs.annotations.Nullable;
10

11
import java.util.ArrayList;
12
import java.util.List;
13

14
import mockit.internal.expectations.invocation.ExpectedInvocation;
15

16
class UnorderedVerificationPhase extends BaseVerificationPhase {
17
    @NonNull
18
    private final List<VerifiedExpectation> verifiedExpectations;
19

20
    UnorderedVerificationPhase(@NonNull ReplayPhase replayPhase) {
21
        super(replayPhase);
1✔
22
        verifiedExpectations = new ArrayList<>();
1✔
23
    }
1✔
24

25
    @NonNull
26
    @Override
27
    final List<ExpectedInvocation> findExpectation(@Nullable Object mock, @NonNull String mockClassDesc,
28
            @NonNull String mockNameAndDesc, @NonNull Object[] args) {
29
        if (!matchInstance && executionState.isToBeMatchedOnInstance(mock, mockNameAndDesc)) {
1✔
30
            matchInstance = true;
1✔
31
        }
32

33
        replayIndex = -1;
1✔
34
        List<Expectation> expectationsInReplayOrder = replayPhase.invocations;
1✔
35
        Expectation verification = currentVerification;
1✔
36
        List<ExpectedInvocation> matchingInvocationsWithDifferentArgs = new ArrayList<>();
1✔
37

38
        for (int i = 0, n = expectationsInReplayOrder.size(); i < n; i++) {
1✔
39
            Expectation replayExpectation = expectationsInReplayOrder.get(i);
1✔
40
            Object replayInstance = replayPhase.invocationInstances.get(i);
1✔
41
            Object[] replayArgs = replayPhase.invocationArguments.get(i);
1✔
42

43
            if (matches(mock, mockClassDesc, mockNameAndDesc, args, replayExpectation, replayInstance, replayArgs)) {
1✔
44
                replayIndex = i;
1✔
45

46
                if (verification != null) {
1!
47
                    verification.constraints.invocationCount++;
1✔
48
                }
49

50
                currentExpectation = replayExpectation;
1✔
51
            } else if (matchingInvocationWithDifferentArgs != null) {
1✔
52
                matchingInvocationsWithDifferentArgs.add(matchingInvocationWithDifferentArgs);
1✔
53
            }
54
        }
55

56
        if (verification != null && replayIndex >= 0) {
1!
57
            pendingError = verifyConstraints(verification);
1✔
58
        }
59

60
        return matchingInvocationsWithDifferentArgs;
1✔
61
    }
62

63
    @Nullable
64
    private Error verifyConstraints(@NonNull Expectation verification) {
65
        ExpectedInvocation lastInvocation = replayPhase.invocations.get(replayIndex).invocation;
1✔
66
        Object[] lastArgs = replayPhase.invocationArguments.get(replayIndex);
1✔
67
        return verification.verifyConstraints(lastInvocation, lastArgs, 1, -1);
1✔
68
    }
69

70
    @Override
71
    final void addVerifiedExpectation(@NonNull Expectation expectation, @NonNull Object[] args) {
72
        VerifiedExpectation verifiedExpectation = new VerifiedExpectation(expectation, args, argMatchers, -1);
1✔
73
        addVerifiedExpectation(verifiedExpectation);
1✔
74
        verifiedExpectations.add(verifiedExpectation);
1✔
75
    }
1✔
76

77
    @Override
78
    final void handleInvocationCountConstraint(int minInvocations, int maxInvocations) {
79
        pendingError = null;
1✔
80

81
        Expectation verifying = currentVerification;
1✔
82

83
        if (verifying == null) {
1!
84
            return;
×
85
        }
86

87
        Error errorThrown;
88

89
        if (replayIndex >= 0) {
1✔
90
            ExpectedInvocation replayInvocation = replayPhase.invocations.get(replayIndex).invocation;
1✔
91
            Object[] replayArgs = replayPhase.invocationArguments.get(replayIndex);
1✔
92
            errorThrown = verifying.verifyConstraints(replayInvocation, replayArgs, minInvocations, maxInvocations);
1✔
93
        } else {
1✔
94
            errorThrown = verifying.verifyConstraints(minInvocations);
1✔
95
        }
96

97
        if (errorThrown != null) {
1✔
98
            throw errorThrown;
1✔
99
        }
100
    }
1✔
101
}
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