what would be the Kotlin equivalent to this Java code?
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Design design = new Design();
GetDesign.Listener callback = (GetDesign.Listener) invocation.getArguments()[0];
callback.onSuccess(design);
return null;
}
}).when(someRepository).getDesign(any(GetDesign.Listener.class));
I've tried several options with lambdas but can't find an equivalent that works. For the moment I'm trying this one (it does not work)
doAnswer { invocation ->
val design = Design()
(invocation.arguments.elementAt(0) as GetDesign.Listener).onSuccess(design)
null
}.`when`(someRepository).execute(listener)
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire