Search in sources :

Example 1 with SponsorshipExpirationInDays

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));
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) EnrichedSponsorship(cz.metacentrum.perun.core.api.EnrichedSponsorship) SponsorshipExpirationInDays(cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInDays) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) LocalDate(java.time.LocalDate) Member(cz.metacentrum.perun.core.api.Member)

Example 2 with SponsorshipExpirationInDays

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)));
}
Also used : SponsorshipExpirationInDays(cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInDays) LocalDate(java.time.LocalDate)

Aggregations

SponsorshipExpirationInDays (cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpirationInDays)2 LocalDate (java.time.LocalDate)2 AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)1 EnrichedSponsorship (cz.metacentrum.perun.core.api.EnrichedSponsorship)1 Member (cz.metacentrum.perun.core.api.Member)1 RichUser (cz.metacentrum.perun.core.api.RichUser)1 User (cz.metacentrum.perun.core.api.User)1