use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInAMonth in project perun by CESNET.
the class ExpirationNotifSchedulerTest method testSponsorshipExpirationIsAuditedAMonthBefore.
@Test
public void testSponsorshipExpirationIsAuditedAMonthBefore() throws Exception {
System.out.println(CLASS_NAME + "testSponsorshipExpirationIsAuditedAMonthBefore");
LocalDate today = LocalDate.of(2020, 2, 2);
when(spyScheduler.getCurrentLocalDate()).thenReturn(today);
Member member = setUpMember();
User sponsor = perun.getUsersManagerBl().getUserByMember(session, setUpMember());
AuthzResolverBlImpl.setRole(session, sponsor, vo, Role.SPONSOR);
LocalDate nextDay = today.plusDays(28);
perun.getMembersManagerBl().setSponsorshipForMember(session, member, sponsor, nextDay);
ReflectionTestUtils.invokeMethod(spyScheduler, "auditSponsorshipExpirations");
EnrichedSponsorship es = new EnrichedSponsorship();
es.setSponsoredMember(perun.getMembersManagerBl().getMemberById(session, member.getId()));
es.setSponsor(perun.getUsersManagerBl().getUserById(session, sponsor.getId()));
AuditEvent expectedEvent = new SponsorshipExpirationInAMonth(es);
verify(auditerMock).log(any(), eq(expectedEvent));
}
use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInAMonth in project perun by CESNET.
the class ExpirationNotifScheduler method auditSponsorshipExpirations.
/**
* Logs information about incoming sponsorship expirations.
* 1,7,14 days in advance, logs the SponsorshipExpirationInDays event
* 28 days in advance, logs the SponsorshipExpirationInAMonth event
*/
private void auditSponsorshipExpirations() {
IntStream.of(1, 7, 14).forEach(this::auditSponsorshipExpirationsInDays);
// need to use 28 days instead of plusMonth(1), otherwise, some days might be skipped or
// processed multiple times
LocalDate nextMonth = getCurrentLocalDate().plusDays(28);
auditSponsorshipExpirationsForDate(nextMonth, sponsorship -> perun.getAuditer().log(sess, new SponsorshipExpirationInAMonth(sponsorship)));
}
Aggregations