@Test
public void sendPendingMessagesOnlySendsRelevantMessages() {

    // given
    var expectedFrom = "sender@test.com";
    var expectedTo = "email@test.com";
    var expectedSubject = "This is a subject!";
    var expectedText = "This is a long text!";
    var expectedSimpleMessage = new SimpleMailMessage();
    expectedSimpleMessage.setFrom(expectedFrom);
    expectedSimpleMessage.setTo(expectedTo);
    expectedSimpleMessage.setSubject(expectedSubject);
    expectedSimpleMessage.setText(expectedText);
    given(messageRepositoryMock.findAll()).willReturn(List.of(templateMessageMock, templateMessageMock));
    given(templateMessageMock.isStillRelevant(LocalDateTime.now(clock)))
            .willReturn(false, true);
    given(templateMessageMock.getSubject()).willReturn(expectedSubject);
    given(templateMessageMock.getText()).willReturn(expectedText);
    given(templateMessageMock.getAddressee()).willReturn(userMock);
    given(userServiceMock.getUserData(userMock)).willReturn(userDataMock);
    given(userDataMock.getEmail()).willReturn(expectedTo);
    given(mailPropertiesMock.getFromMail()).willReturn(expectedFrom);
    // when
    mailSenderAdapter.sendPendingMessages();
    // then
    verify(messageRepositoryMock, times(2)).delete(templateMessageMock);
    verify(javaMailSenderMock).send(expectedSimpleMessage);
}