@Test
public void onAccessChangedQueuesExtendedMessageWhenNewEndAfterOldEnd() {

    // given
    var expectedTemplatePath = "/templates/mail/UserAccessExtended.vm";
    var expectedSubject = "Subject!";
    var expectedText = "Text!";
    var expectedEndTime = LocalDateTime.of(2019, 2, 3, 10, 0);
    var expectedOldEndTime = LocalDateTime.of(2019, 1, 1, 10, 0);
    var expectedContextMap = Map.of(
            "userData", userDataMock,
            "newDate", expectedEndTime.format(MailUserAccessEventHandler.DATE_TIME_FORMATTER),
            "projectBoardUrl", PROJECT_BOARD_URL
    );
    var expectedMessage = new TimeAwareMessage(userMock, userMock, expectedSubject, expectedText, expectedEndTime);
    var subjectTextPair = new Pair<>(expectedSubject, expectedText);
    given(accessIntervalMock.getEndTime()).willReturn(expectedEndTime);
    given(userServiceMock.getUserData(userMock)).willReturn(userDataMock);
    given(velocityMailTemplateServiceMock.getSubjectAndText(expectedTemplatePath, expectedContextMap))
            .willReturn(subjectTextPair);
    // when
    mailUserAccessEventHandler.onAccessChanged(userMock, accessIntervalMock, expectedOldEndTime);
    // then
    verify(mailSenderAdapterMock).queueMessage(expectedMessage);
}