• 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

95.45
/main/src/main/java/mockit/internal/expectations/invocation/InvocationConstraints.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.invocation;
7

8
import edu.umd.cs.findbugs.annotations.NonNull;
9
import edu.umd.cs.findbugs.annotations.Nullable;
10

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

14
import org.checkerframework.checker.index.qual.NonNegative;
15

16
public final class InvocationConstraints {
17
    public int minInvocations;
18
    private int maxInvocations;
19
    @NonNegative
20
    public int invocationCount;
21

22
    public InvocationConstraints(boolean nonStrictInvocation) {
1✔
23
        setLimits(nonStrictInvocation ? 0 : 1, -1);
1✔
24
    }
1✔
25

26
    public void setLimits(int minInvocations, int maxInvocations) {
27
        this.minInvocations = minInvocations;
1✔
28
        this.maxInvocations = maxInvocations;
1✔
29
    }
1✔
30

31
    void adjustMaxInvocations(@NonNegative int expectedInvocationCount) {
32
        if (maxInvocations > 0 && maxInvocations < expectedInvocationCount) {
1!
33
            maxInvocations = expectedInvocationCount;
×
34
        }
35
    }
1✔
36

37
    void setUnlimitedMaxInvocations() {
38
        maxInvocations = -1;
1✔
39
    }
1✔
40

41
    public void incrementInvocationCount() {
42
        invocationCount++;
1✔
43
    }
1✔
44

45
    public boolean isInvocationCountLessThanMinimumExpected() {
46
        return invocationCount < minInvocations;
1✔
47
    }
48

49
    public boolean isInvocationCountMoreThanMaximumExpected() {
50
        return maxInvocations >= 0 && invocationCount > maxInvocations;
1✔
51
    }
52

53
    @Nullable
54
    public Error verifyLowerLimit(@NonNull ExpectedInvocation invocation, int lowerLimit) {
55
        if (invocationCount < lowerLimit) {
1✔
56
            int missingInvocations = lowerLimit - invocationCount;
1✔
57
            return invocation.errorForMissingInvocations(missingInvocations,
1✔
58
                    Collections.<ExpectedInvocation> emptyList());
1✔
59
        }
60

61
        return null;
1✔
62
    }
63

64
    @Nullable
65
    public Error verifyUpperLimit(@NonNull ExpectedInvocation invocation, @NonNull Object[] replayArgs,
66
            int upperLimit) {
67
        if (upperLimit >= 0) {
1✔
68
            int unexpectedInvocations = invocationCount - upperLimit;
1✔
69

70
            if (unexpectedInvocations > 0) {
1✔
71
                return invocation.errorForUnexpectedInvocations(replayArgs, unexpectedInvocations);
1✔
72
            }
73
        }
74

75
        return null;
1✔
76
    }
77

78
    @NonNull
79
    public Error errorForMissingExpectations(@NonNull ExpectedInvocation invocation,
80
            @NonNull List<ExpectedInvocation> nonMatchingInvocations) {
81
        return invocation.errorForMissingInvocations(minInvocations - invocationCount, nonMatchingInvocations);
1✔
82
    }
83
}
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