use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInDays in project perun by CESNET.
the class ExpirationNotifSchedulerTest method testSponsorshipExpirationIsAuditedInDays.
/**
* Performs test of sponsorship expiration being audited n days before its expiration.
*
* @param days number of days before the expiration
*/
private void testSponsorshipExpirationIsAuditedInDays(int days) throws Exception {
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(days);
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 SponsorshipExpirationInDays(es, days);
verify(auditerMock).log(any(), eq(expectedEvent));
}
use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInDays in project perun by CESNET.
the class ExpirationNotifScheduler method auditSponsorshipExpirationsInDays.
/**
* Audits incoming sponsorship expirations which have validity set to
* currentDate + days.
*
* @param days days used to calculate the validity for which the audit log should happen
*/
private void auditSponsorshipExpirationsInDays(int days) {
LocalDate today = getCurrentLocalDate();
auditSponsorshipExpirationsForDate(today.plusDays(days), sponsorship -> perun.getAuditer().log(sess, new SponsorshipExpirationInDays(sponsorship, days)));
}
Aggregations