use of se.inera.intyg.common.fk7263.support.Fk7263EntryPoint in project webcert by sklintyg.
the class IntygServiceTest method testHandleSignedWithSigneraSkickaDirekt.
@Test
public void testHandleSignedWithSigneraSkickaDirekt() throws Exception {
final String intygId = "intygId";
final String intygTyp = "intygTyp";
final String relationIntygId = "relationIntygId";
final String recipient = new Fk7263EntryPoint().getDefaultRecipient();
final Personnummer personnummer = PERSNR;
Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
utlatande.setId(intygId);
utlatande.setTyp(intygTyp);
utlatande.getGrundData().getPatient().setPersonId(personnummer);
Utkast utkast = new Utkast();
utkast.setIntygsId(intygId);
utkast.setIntygsTyp(intygTyp);
utkast.setModel(json);
when(utkastRepository.findOne(intygId)).thenReturn(utkast);
when(moduleFacade.getUtlatandeFromInternalModel(eq(intygTyp), anyString())).thenReturn(utlatande);
when(certificateRelationService.getNewestRelationOfType(eq(intygId), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.empty());
when(moduleRegistry.getModuleEntryPoint(intygTyp)).thenReturn(new Fk7263EntryPoint());
when(authoritiesHelper.isFeatureActive(AuthoritiesConstants.FEATURE_SIGNERA_SKICKA_DIREKT, intygTyp)).thenReturn(true);
intygService.handleAfterSigned(utkast);
verify(certificateSenderService).sendCertificate(eq(intygId), eq(personnummer), anyString(), eq(recipient), eq(true));
verify(mockMonitoringService).logIntygSent(intygId, recipient);
verify(logservice).logSendIntygToRecipient(any(LogRequest.class));
verify(arendeService, never()).closeCompletionsAsHandled(relationIntygId, intygTyp);
verify(notificationService).sendNotificationForIntygSent(intygId);
ArgumentCaptor<Utkast> utkastCaptor = ArgumentCaptor.forClass(Utkast.class);
verify(utkastRepository).save(utkastCaptor.capture());
assertNotNull(utkastCaptor.getValue().getSkickadTillMottagareDatum());
assertEquals(recipient, utkastCaptor.getValue().getSkickadTillMottagare());
}
use of se.inera.intyg.common.fk7263.support.Fk7263EntryPoint in project webcert by sklintyg.
the class IntygServiceTest method testHandleSignedCompletion.
@Test
public void testHandleSignedCompletion() throws Exception {
final String intygId = "intygId";
final String intygTyp = "intygTyp";
final String relationIntygId = "relationIntygId";
final String recipient = new Fk7263EntryPoint().getDefaultRecipient();
final Personnummer personnummer = PERSNR;
Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
utlatande.setId(intygId);
utlatande.setTyp(intygTyp);
utlatande.getGrundData().getPatient().setPersonId(personnummer);
Utkast utkast = new Utkast();
utkast.setIntygsId(intygId);
utkast.setIntygsTyp(intygTyp);
utkast.setRelationKod(RelationKod.KOMPLT);
utkast.setRelationIntygsId(relationIntygId);
utkast.setModel(json);
when(utkastRepository.findOne(intygId)).thenReturn(utkast);
when(moduleFacade.getUtlatandeFromInternalModel(eq(intygTyp), anyString())).thenReturn(utlatande);
when(certificateRelationService.getNewestRelationOfType(eq(intygId), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.empty());
when(moduleRegistry.getModuleEntryPoint(intygTyp)).thenReturn(new Fk7263EntryPoint());
intygService.handleAfterSigned(utkast);
verify(certificateSenderService).sendCertificate(eq(intygId), eq(personnummer), anyString(), eq(recipient), eq(true));
verify(mockMonitoringService).logIntygSent(intygId, recipient);
verify(logservice).logSendIntygToRecipient(any(LogRequest.class));
verify(arendeService).closeCompletionsAsHandled(relationIntygId, intygTyp);
verify(notificationService).sendNotificationForIntygSent(intygId);
ArgumentCaptor<Utkast> utkastCaptor = ArgumentCaptor.forClass(Utkast.class);
verify(utkastRepository).save(utkastCaptor.capture());
assertNotNull(utkastCaptor.getValue().getSkickadTillMottagareDatum());
assertEquals(recipient, utkastCaptor.getValue().getSkickadTillMottagare());
}
Aggregations