use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpired in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method testLocalDate.
@Test
public void testLocalDate() throws Exception {
System.out.println(CLASS_NAME + "testLocalDate");
AuditMessagesManagerImpl auditMessagesManagerImpl = (AuditMessagesManagerImpl) ReflectionTestUtils.getField(perun.getAuditMessagesManagerBl(), "auditMessagesManagerImpl");
assertThat(auditMessagesManagerImpl).isNotNull();
ObjectMapper mapper = (ObjectMapper) ReflectionTestUtils.getField(auditMessagesManagerImpl, "mapper");
assertThat(mapper).isNotNull();
AuditEvent event = new SponsorshipEstablished(null, null, LocalDate.MIN);
testAuditEventMapper(mapper, event);
EnrichedSponsorship enrichedSponsorship = new EnrichedSponsorship();
enrichedSponsorship.setValidityTo(LocalDate.MAX);
AuditEvent event2 = new SponsorshipExpired();
testAuditEventMapper(mapper, event2);
}
use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpired in project perun by CESNET.
the class ExpirationNotifScheduler method expireSponsorship.
/**
* Cancel given sponsorship and log the SponsorshipExpired audit event.
*
* @param sponsorship sponsorship to be cancelled
*/
private void expireSponsorship(Sponsorship sponsorship) {
try {
Member member = perun.getMembersManagerBl().getMemberById(sess, sponsorship.getSponsoredId());
User sponsor = perun.getUsersManagerBl().getUserById(sess, sponsorship.getSponsorId());
perun.getMembersManagerBl().removeSponsor(sess, member, sponsor);
perun.getAuditer().log(sess, new SponsorshipExpired(convertSponsorshipToEnriched(sponsorship)));
} catch (MemberNotExistsException | UserNotExistsException e) {
log.error("Failed to expire sponsorship. Sponsorship: {}", sponsorship, e);
}
}
Aggregations