example ``` val rights: MyApiClient = mock<M...
# announcements
b
example
Copy code
val rights: MyApiClient = mock<MyApiClient>{
        on {fetchByIds(any())} doReturn emptyList<Response>()
    }
n
billybong: What is the definition of
MyApiClient
and
fetchById
, and what is the stack trace?
b
MyApiClient is an open class (spring bean) and fetchId receives a list of id’s based on a domain class
n
it could be that the body of
fetchByIds
is still executed because it can't be mocked: is it declared
open
as well?
b
aah, you mean the function as well?
n
exactly
b
Is there anyway around that?
t
mockito 2 can mock final methods as well
can you show
fetchByIds()
function definition? It may happen that it returns list of
Response?
type
n
the only way around not adding
open
to the function is to use `mock-maker-inline`: https://github.com/mockito/mockito/wiki/What's-new-in-Mockito-2#unmockable
b
no it doesn’t. nhaarman was right that the method was not open and I was using Mockito 1.9. That lead me to the correct answer
Yup, the same as Hadi blogged about above. Big thanks for the help
👍 1