Created
September 10, 2014 15:58
-
-
Save AndrienkoAleksandr/8001cbd018709d73bc8c to your computer and use it in GitHub Desktop.
ArgumentCaptor vs doAnswer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArgumentCaptor<UserChangedCallBack> userCapture = ArgumentCaptor.forClass(UserChangedCallBack.class); | |
doNothing().when(dialogBoxPresenter).showDialog(any(User.class), userCapture.capture()); | |
usersListPresenter.onAddButtonClicked(); | |
userCapture.getValue().onChanged(user); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doAnswer(new Answer() { | |
@Override | |
public Void answer(InvocationOnMock invocationOnMock) throws Throwable { | |
UserChangedCallBack callBack = (UserChangedCallBack) invocationOnMock.getArguments()[1]; | |
callBack.onChanged(userForDeleting); | |
return null; | |
} | |
}).when(dialogBoxPresenter).showDialog(any(User.class), any(UserChangedCallBack.class)); | |
usersListPresenter.onAddButtonClicked(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment