use of se.inera.intyg.webcert.persistence.utkast.model.PagaendeSignering in project webcert by sklintyg.
the class SignaturServiceImplTest method setup.
@Before
public void setup() throws Exception {
hoSPerson = new HoSPersonal();
hoSPerson.setPersonId("AAA");
hoSPerson.setFullstandigtNamn("Dr Dengroth");
VardpersonReferens vardperson = new VardpersonReferens();
vardperson.setHsaId(hoSPerson.getPersonId());
vardperson.setNamn(hoSPerson.getFullstandigtNamn());
utkast = createUtkast(INTYG_ID, 1, INTYG_TYPE, UtkastStatus.DRAFT_INCOMPLETE, INTYG_JSON, vardperson, ENHET_ID, PERSON_ID);
completedUtkast = createUtkast(INTYG_ID, 2, INTYG_TYPE, UtkastStatus.DRAFT_COMPLETE, INTYG_JSON, vardperson, ENHET_ID, PERSON_ID);
signedUtkast = createUtkast(INTYG_ID, 3, INTYG_TYPE, UtkastStatus.SIGNED, INTYG_JSON, vardperson, ENHET_ID, PERSON_ID);
vardenhet = new Vardenhet(ENHET_ID, "testNamn");
vardgivare = new Vardgivare("123", "vardgivare");
vardgivare.setVardenheter(Collections.singletonList(vardenhet));
user = createWebCertUser(true);
when(webcertUserService.getUser()).thenReturn(user);
when(moduleRegistry.getModuleApi(any())).thenReturn(moduleApi);
when(moduleApi.updateBeforeSigning(any(), any(), any())).thenReturn(INTYG_JSON);
Utlatande utlatande = mock(Utlatande.class);
GrundData grunddata = new GrundData();
grunddata.setSkapadAv(new HoSPersonal());
when(utlatande.getGrundData()).thenReturn(grunddata);
when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
setTypedField(intygSignatureService, new SignaturTicketTracker());
pagaendeSignering = mock(PagaendeSignering.class);
when(pagaendeSignering.getInternReferens()).thenReturn(PAGAENDE_SIGN_ID);
when(pagaendeSignering.getIntygData()).thenReturn(INTYG_JSON);
when(pagaendeSignering.getIntygsId()).thenReturn(INTYG_ID);
when(pagaendeSignering.getSigneradAvHsaId()).thenReturn(hoSPerson.getPersonId());
when(pagaendeSignering.getSigneradAvNamn()).thenReturn(hoSPerson.getFullstandigtNamn());
when(pagaendeSigneringRepository.findOne(any())).thenReturn(pagaendeSignering);
when(pagaendeSigneringRepository.save(any(PagaendeSignering.class))).thenReturn(pagaendeSignering);
}
use of se.inera.intyg.webcert.persistence.utkast.model.PagaendeSignering in project webcert by sklintyg.
the class PagaendeSigneringCleanupServiceImpl method cleanup.
@Scheduled(cron = "${signature.cleanup.cron}")
public void cleanup() {
List<PagaendeSignering> all = pagaendeSigneringRepository.findAll();
if (all == null || all.isEmpty()) {
return;
}
LOG.info("Running stale signature cleanup. There are currently {} ongoing signatures.", all.size());
LocalDateTime evictIfOlderThan = LocalDateTime.now().minusMinutes(EVICT_OLDER_THAN_MINUTES);
Iterator<PagaendeSignering> iterator = all.stream().filter(ps -> ps.getSigneringsDatum().isBefore(evictIfOlderThan)).iterator();
while (iterator.hasNext()) {
PagaendeSignering pagaendeSignering = iterator.next();
Long id = pagaendeSignering.getInternReferens();
String intygsId = pagaendeSignering.getIntygsId();
pagaendeSigneringRepository.delete(pagaendeSignering.getInternReferens());
LOG.info("Removed stale PagaendeSignering with id '{}' for intygs-id '{}'. " + "This is perfectly normal if the signing user didn't complete the signing.", id, intygsId);
}
}
Aggregations