jmockit1
jmockit1 copied to clipboard
Add support for with() with Predicate as argument
-
Version of JMockit that was used: 1.49
-
Description of the problem or enhancement request: I want to create a simple argument matcher with lambda as predicate in
Expectations. But it isn't possible because method with has as argument Delegate which is not a funcional interface. So my proposal is add a new method into Invocations class:
protected final <T> T with(@Nonnull Predicate<? super T> matcher)
then you will be able to create expectations as (String is used just for examle):
mock.mockMethod(with((String s) -> s.isEmpty()));
With a Delegate you have to write it as:
mock.mockMethod(with(new Delegate<String>() {
boolean test(String s) {
return s.isEmpty();
}
}));