
com.github.aro_tech.extended_mockito.ListMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of extended-mockito Show documentation
Show all versions of extended-mockito Show documentation
Jar with Mockito as a mixin interface, plus extra features
package com.github.aro_tech.extended_mockito;
import java.util.List;
import java.util.stream.Stream;
import org.mockito.ArgumentMatcher;
/**
* Mockito ArgumentMatcher for lists of objects
*
* Override this abstract class, implementing evaluateStream() to do custom list
* matching.
*
* @author aro_tech
*
* @param
*/
public abstract class ListMatcher implements ArgumentMatcher> {
/*
* (non-Javadoc)
*
* @see org.mockito.ArgumentMatcher#matches(java.lang.Object)
*/
@Override
public boolean matches(Object argument) {
if (null == argument) {
return false;
}
Stream stream = listToStream(argument);
return evaluateStream(stream);
}
protected abstract boolean evaluateStream(Stream stream);
private Stream listToStream(Object argument) {
return ((List) argument).stream();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy