'mockito a List<Predicate<String>> to always return true
I have a list<Predicate> which is a private field of a class, and this field will be used to filter lines of data.
I would like to test my class with mocking the list<Predicate> by making it always true/false.
public class T {
private final List<Predicate<String>> filters;
public void run(){
...
while ((line = input.readLine()) != null) {
if (filters.stream().allMatch(filter -> filter.test(line))) {
....
}}}
I am wondering how to mock this field filters in tests. Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
