-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
UnusedStubbings.java
42 lines (33 loc) · 1.04 KB
/
UnusedStubbings.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package org.mockito.internal.junit;
import org.mockito.internal.util.MockitoLogger;
import org.mockito.internal.invocation.Stubbing;
import java.util.Collection;
/**
* Contains unused stubbings, knows how to format them
*/
public class UnusedStubbings {
private final Collection<Stubbing> unused;
UnusedStubbings(Collection<Stubbing> unused) {
this.unused = unused;
}
void format(String testName, MockitoLogger logger) {
if (unused.isEmpty()) {
return;
}
//TODO 544 it would be nice to make the String look good if x goes multiple digits (padding)
StubbingHint hint = new StubbingHint(testName);
int x = 1;
for (Stubbing candidate : unused) {
if (!candidate.wasUsed()) {
hint.appendLine(x++, ". Unused ", candidate.getInvocation().getLocation());
}
}
logger.log(hint.toString());
}
public int size() {
return unused.size();
}
public String toString() {
return unused.toString();
}
}