use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande 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());
}
use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class IntygServiceTest method setupIntygstjanstResponse.
@Before
public void setupIntygstjanstResponse() throws Exception {
vardpersonReferens = new VardpersonReferens();
vardpersonReferens.setHsaId(HSA_ID);
vardpersonReferens.setNamn(CREATED_BY_NAME);
json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
CertificateMetaData metaData = new CertificateMetaData();
metaData.setStatus(new ArrayList<>());
CertificateResponse certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(certificateResponse);
when(moduleFacade.getUtlatandeFromInternalModel(anyString(), anyString())).thenReturn(utlatande);
}
use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class IntygConverterUtilTest method testBuildSendTypeFromUtlatande.
@Test
public void testBuildSendTypeFromUtlatande() throws Exception {
Fk7263Utlatande utlatande = createUtlatandeFromJson();
SendType res = IntygConverterUtil.buildSendTypeFromUtlatande(utlatande);
assertNotNull(res);
assertNotNull(res.getAvsantTidpunkt());
assertTrue(res.getVardReferensId().contains("SEND-123-"));
assertEquals("123", res.getLakarutlatande().getLakarutlatandeId());
assertNull(res.getLakarutlatande().getPatient().getFullstandigtNamn());
assertEquals("19121212-1212", res.getLakarutlatande().getPatient().getPersonId().getExtension());
assertNotNull(res.getLakarutlatande().getSigneringsTidpunkt());
assertNull(res.getAdressVard().getHosPersonal().getForskrivarkod());
assertEquals("En Läkare", res.getAdressVard().getHosPersonal().getFullstandigtNamn());
assertEquals("Personal HSA-ID", res.getAdressVard().getHosPersonal().getPersonalId().getExtension());
assertEquals("Kir mott", res.getAdressVard().getHosPersonal().getEnhet().getEnhetsnamn());
assertEquals("VardenhetY", res.getAdressVard().getHosPersonal().getEnhet().getEnhetsId().getExtension());
assertEquals("123456789011", res.getAdressVard().getHosPersonal().getEnhet().getArbetsplatskod().getExtension());
assertEquals("Landstinget Norrland", res.getAdressVard().getHosPersonal().getEnhet().getVardgivare().getVardgivarnamn());
assertEquals("VardgivarId", res.getAdressVard().getHosPersonal().getEnhet().getVardgivare().getVardgivareId().getExtension());
}
Aggregations