Because it usris a layout, calling the inline method usr.getUserName()is the part that drops you. You cannot call the bullying method in the middle of the start of another method for reasons specific to the implementation of Mockito and the ability to syntax.
when(myObject.getEntity(
eq(1l),
or(eq(usr.getUserName()),eq(Constants.ADMIN))
)
).thenReturn(null);
Mockito, eq or, , 0 , - Matcher ArgumentMatcherStorage. Mockito , , , (.. ) (.. , ). .
Java, eq(1l) , usr.getUserName() - or. , getUserName , 0 1 .
:
String userName = usr.getUserName(); // or whatever you stubbed, directly
when(myObject.getEntity(
eq(1l),
or(eq(userName),eq(Constants.ADMIN))
)
).thenReturn(null);
, Mockito , . SO .