
org.mockito.internal.invocation.MatchersBinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-all Show documentation
Show all versions of mockito-all Show documentation
Mock objects library for java, modified to allow cache disabling
The newest version!
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.invocation;
import java.io.Serializable;
import java.util.List;
import org.hamcrest.Matcher;
import org.mockito.exceptions.Reporter;
import org.mockito.internal.progress.ArgumentMatcherStorage;
@SuppressWarnings("unchecked")
public class MatchersBinder implements Serializable {
private static final long serialVersionUID = -311433939339443463L;
public InvocationMatcher bindMatchers(ArgumentMatcherStorage argumentMatcherStorage, Invocation invocation) {
List lastMatchers = argumentMatcherStorage.pullMatchers();
validateMatchers(invocation, lastMatchers);
InvocationMatcher invocationWithMatchers = new InvocationMatcher(invocation, lastMatchers);
return invocationWithMatchers;
}
private void validateMatchers(Invocation invocation, List matchers) {
if (!matchers.isEmpty()) {
int recordedMatchersSize = matchers.size();
int expectedMatchersSize = invocation.getArgumentsCount();
if (expectedMatchersSize != recordedMatchersSize) {
new Reporter().invalidUseOfMatchers(expectedMatchersSize, recordedMatchersSize);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy