Search in sources :

Example 1 with LocalizedMatcher

use of org.mockito.internal.matchers.LocalizedMatcher in project mockito by mockito.

the class MatchersBinder method bindMatchers.

public InvocationMatcher bindMatchers(ArgumentMatcherStorage argumentMatcherStorage, Invocation invocation) {
    List<LocalizedMatcher> lastMatchers = argumentMatcherStorage.pullLocalizedMatchers();
    validateMatchers(invocation, lastMatchers);
    List<ArgumentMatcher> matchers = new LinkedList<ArgumentMatcher>();
    for (LocalizedMatcher m : lastMatchers) {
        matchers.add(m.getMatcher());
    }
    return new InvocationMatcher(invocation, matchers);
}
Also used : LocalizedMatcher(org.mockito.internal.matchers.LocalizedMatcher) ArgumentMatcher(org.mockito.ArgumentMatcher) LinkedList(java.util.LinkedList)

Example 2 with LocalizedMatcher

use of org.mockito.internal.matchers.LocalizedMatcher in project powermock by powermock.

the class PowerMockMatchersBinder method bindMatchers.

public InvocationMatcher bindMatchers(ArgumentMatcherStorage argumentMatcherStorage, final Invocation invocation) {
    List<LocalizedMatcher> lastMatchers = argumentMatcherStorage.pullLocalizedMatchers();
    validateMatchers(invocation, lastMatchers);
    // In Mockito 2.0 LocalizedMatcher no more extend ArgumentMatcher, so new list should be created.
    final List<ArgumentMatcher> argumentMatchers = extractArgumentMatchers(lastMatchers);
    final InvocationMatcher invocationWithMatchers = new InvocationMatcher(invocation, argumentMatchers) {

        @Override
        public String toString() {
            return invocation.toString();
        }
    };
    return invocationWithMatchers;
}
Also used : LocalizedMatcher(org.mockito.internal.matchers.LocalizedMatcher) ArgumentMatcher(org.mockito.ArgumentMatcher) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher)

Aggregations

ArgumentMatcher (org.mockito.ArgumentMatcher)2 LocalizedMatcher (org.mockito.internal.matchers.LocalizedMatcher)2 LinkedList (java.util.LinkedList)1 InvocationMatcher (org.mockito.internal.invocation.InvocationMatcher)1