• 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.83
/main/src/main/java/mockit/internal/expectations/invocation/InvocationResults.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.lang.reflect.Array;
12
import java.util.Iterator;
13

14
import mockit.Delegate;
15
import mockit.internal.expectations.invocation.InvocationResult.DeferredResults;
16
import mockit.internal.expectations.invocation.InvocationResult.ReturnValueResult;
17
import mockit.internal.expectations.invocation.InvocationResult.ThrowableResult;
18

19
import org.checkerframework.checker.index.qual.NonNegative;
20

21
public final class InvocationResults {
1✔
22
    @NonNull
23
    private final ExpectedInvocation invocation;
24
    @NonNull
25
    private final InvocationConstraints constraints;
26
    @Nullable
27
    private InvocationResult currentResult;
28
    @Nullable
29
    private InvocationResult lastResult;
30
    @NonNegative
31
    private int resultCount;
32

33
    public InvocationResults(@NonNull ExpectedInvocation invocation, @NonNull InvocationConstraints constraints) {
1✔
34
        this.invocation = invocation;
1✔
35
        this.constraints = constraints;
1✔
36
    }
1✔
37

38
    public void addReturnValue(@Nullable Object value) {
39
        if (value instanceof Delegate) {
1✔
40
            addDelegatedResult((Delegate<?>) value);
1✔
41
        } else {
42
            addNewReturnValueResult(value);
1✔
43
        }
44
    }
1✔
45

46
    public void addDelegatedResult(@NonNull Delegate<?> delegate) {
47
        InvocationResult result = new DelegatedResult(invocation, delegate);
1✔
48
        addResult(result);
1✔
49
    }
1✔
50

51
    private void addNewReturnValueResult(@Nullable Object value) {
52
        InvocationResult result = new ReturnValueResult(value);
1✔
53
        addResult(result);
1✔
54
    }
1✔
55

56
    public void addReturnValueResult(@Nullable Object value) {
57
        addNewReturnValueResult(value);
1✔
58
    }
1✔
59

60
    public void addReturnValues(@NonNull Object... values) {
61
        for (Object value : values) {
1✔
62
            addReturnValue(value);
1✔
63
        }
64
    }
1✔
65

66
    void addResults(@NonNull Object array) {
67
        int n = Array.getLength(array);
1✔
68

69
        for (int i = 0; i < n; i++) {
1✔
70
            Object value = Array.get(array, i);
1✔
71
            addConsecutiveResult(value);
1✔
72
        }
73
    }
1✔
74

75
    private void addConsecutiveResult(@Nullable Object result) {
76
        if (result instanceof Throwable) {
1✔
77
            addThrowable((Throwable) result);
1✔
78
        } else {
79
            addReturnValue(result);
1✔
80
        }
81
    }
1✔
82

83
    void addResults(@NonNull Iterable<?> values) {
84
        for (Object value : values) {
1✔
85
            addConsecutiveResult(value);
1✔
86
        }
1✔
87
    }
1✔
88

89
    void addDeferredResults(@NonNull Iterator<?> values) {
90
        InvocationResult result = new DeferredResults(values);
1✔
91
        addResult(result);
1✔
92
        constraints.setUnlimitedMaxInvocations();
1✔
93
    }
1✔
94

95
    public void addThrowable(@NonNull Throwable t) {
96
        addResult(new ThrowableResult(t));
1✔
97
    }
1✔
98

99
    private void addResult(@NonNull InvocationResult result) {
100
        resultCount++;
1✔
101
        constraints.adjustMaxInvocations(resultCount);
1✔
102

103
        if (currentResult == null) {
1✔
104
            currentResult = result;
1✔
105
        } else {
106
            assert lastResult != null;
1!
107
            lastResult.next = result;
1✔
108
        }
109

110
        lastResult = result;
1✔
111
    }
1✔
112

113
    @Nullable
114
    public Object produceResult(@Nullable Object invokedObject, @NonNull Object[] invocationArgs) throws Throwable {
115
        InvocationResult resultToBeProduced = currentResult;
1✔
116

117
        if (resultToBeProduced == null) {
1!
118
            return null;
×
119
        }
120

121
        InvocationResult nextResult = resultToBeProduced.next;
1✔
122

123
        if (nextResult != null) {
1✔
124
            currentResult = nextResult;
1✔
125
        }
126

127
        return resultToBeProduced.produceResult(invokedObject, invocation, constraints, invocationArgs);
1✔
128
    }
129
}
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