org.mockito.internal.junit.StubbingArgMismatches Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of securemock Show documentation
Show all versions of securemock Show documentation
Libraries for Elasticsearch
The newest version!
/*
* Copyright (c) 2016 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.junit;
import org.mockito.internal.util.MockitoLogger;
import org.mockito.invocation.Invocation;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
/**
* Contains stubbing arg mismatches, knows how to format them
*/
public class StubbingArgMismatches {
final Map> mismatches = new LinkedHashMap>();
public void add(Invocation invocation, Invocation stubbing) {
Set matchingInvocations = mismatches.get(stubbing);
if (matchingInvocations == null) {
matchingInvocations = new LinkedHashSet();
mismatches.put(stubbing, matchingInvocations);
}
matchingInvocations.add(invocation);
}
public void format(String testName, MockitoLogger logger) {
if (mismatches.isEmpty()) {
return;
}
StubbingHint hint = new StubbingHint(testName);
int x = 1;
for (Map.Entry> m : mismatches.entrySet()) {
hint.appendLine(x++, ". Unused... ", m.getKey().getLocation());
for (Invocation invocation : m.getValue()) {
hint.appendLine(" ...args ok? ", invocation.getLocation());
}
}
logger.log(hint.toString());
}
public int size() {
return mismatches.size();
}
public String toString() {
return "" + mismatches;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy