Package no.mnemonic.commons.testtools
Class MockitoTools
java.lang.Object
no.mnemonic.commons.testtools.MockitoTools
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Simplify testing with mockito and argThat by doingstatic <T,
U extends T>
TSame asmatch(Predicate)
, but with a specific expected argument class, to use if the verified method takes a superclass of expected argument verify(mock).method(match(c->c.getValue()==expectedValue, ExpectedClass.class))
-
Constructor Details
-
MockitoTools
public MockitoTools()
-
-
Method Details
-
match
Simplify testing with mockito and argThat by doingverify(mock).method(match(arg->arg.isSomething()));
- Type Parameters:
T
- the argument type- Parameters:
predicate
- predicate to match the expected argument- Returns:
- a mock reporter which matches the argument using this predicate
-
match
Same asmatch(Predicate)
, but with a specific expected argument class, to use if the verified method takes a superclass of expected argument verify(mock).method(match(c->c.getValue()==expectedValue, ExpectedClass.class))- Type Parameters:
T
- mocked method argument typeU
- expected argument type, subclass of T- Parameters:
expectedClass
- Expected argument classpredicate
- predicate to test on the argument- Returns:
- true if argument is instanceof U and passes the predicate test
-