Thanks @assylias for you answer. I think I found a better way to implement the first mock, which combines the ideas from your first and second (after edit) answers. It goes like this:
new MockUp<A> () {
private int n;
@Mock
public void $init(Invocation inv, int n) {
this.n = n;
inv.proceed();
}
@Mock
public boolean isCorrect(Invocation inv) {
if (n == 3) {
return true;
}
return inv.proceed();
}
};
Update
For the second mock (the brute false return), this will do:
new MockUp<A> () {
@Mock
public boolean isCorrect() {
return false;
}
};
And again, thanks to @assylias for helping me with this :)