Again, the library application has a field representing the E-mail server, which is then mocked by an MockEmailServerHolder. However, in this case, we don't have to fake the result of sendEmail (which does not exists because it is void method), we are interested if we are actually calling the sendEmail method. To this end, we use the method verify imported as "import static org.mockito.Mockito.verify;". Verfiy allows us to check that a message has been sent. For example, if aLibraryApp.sendReminder() is supposed to send the message "sendEmail("user@domain","Overdue book(s)","You have 1 overdue book(s)")", then
verify(mockEmailServer).sendEmail("user@domain", "Overdue book(s)", "You have 1 overdue book(s)");will raise an AssertionFailedException, when the message was not sent or not sent with the correct arguments. You find more information about the verify method at the Mockito tutorial.