use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntygDataWithRelation.
@Test
public void testFetchIntygDataWithRelation() throws Exception {
IntygContentHolder res = intygService.fetchIntygDataWithRelations(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertNotNull(res);
assertNotNull(res.getRelations());
verify(moduleFacade).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(logservice).logReadIntyg(any(LogRequest.class));
verify(mockMonitoringService).logIntygRead(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(intygRelationHelper).getRelationsForIntyg(CERTIFICATE_ID);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntyg.
@Test
public void testFetchIntyg() throws Exception {
IntygContentHolder intygData = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
// ensure that correctcall is made to intygstjanst
verify(moduleFacade).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(patientDetailsResolver).isAvliden(any(Personnummer.class));
verify(mockMonitoringService).logIntygRead(CERTIFICATE_ID, CERTIFICATE_TYPE);
// TODO: INTYG-4086, fix this assert. The contents have been updated with the just-in-time fetched patient...
// assertEquals(json, intygData.getContents());
assertEquals(CERTIFICATE_ID, intygData.getUtlatande().getId());
assertEquals(PERSON_ID, intygData.getUtlatande().getGrundData().getPatient().getPersonId().getPersonnummerWithDash());
assertFalse(intygData.isDeceased());
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testThatCompletePatientAddressIsUsedWhenIntygtjanstIsUnavailable.
@Test
public void testThatCompletePatientAddressIsUsedWhenIntygtjanstIsUnavailable() throws Exception {
// Given
when(moduleFacade.getCertificate(anyString(), anyString())).thenThrow(new WebServiceException());
when(utkastRepository.findOneByIntygsIdAndIntygsTyp(anyString(), anyString())).thenReturn(getIntyg(CERTIFICATE_ID, LocalDateTime.now(), null));
String postadress = "ttipafpinuwiiu-postadress";
String postort = "ttipafpinuwiiu-postort";
String postnummer = "ttipafpinuwiiu-postnummer";
Patient patientWithIncompleteAddress = buildPatient(false, false);
patientWithIncompleteAddress.setPostadress(postadress);
patientWithIncompleteAddress.setPostort(postort);
patientWithIncompleteAddress.setPostnummer(postnummer);
when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
// When
IntygContentHolder intygData = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
// Then
ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
assertEquals(postadress, argumentCaptor.getValue().getPostadress());
assertEquals(postort, argumentCaptor.getValue().getPostort());
assertEquals(postnummer, argumentCaptor.getValue().getPostnummer());
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntygDataWhenIntygstjanstIsUnavailable.
@SuppressWarnings("unchecked")
@Test
public void testFetchIntygDataWhenIntygstjanstIsUnavailable() throws Exception {
final LocalDateTime timestamp = LocalDateTime.of(2010, 11, 12, 13, 14, 15);
Utkast utkast = getIntyg(CERTIFICATE_ID, null, null);
utkast.setIntygsTyp(CERTIFICATE_TYPE);
utkast.setSkapad(timestamp);
when(moduleFacade.getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE)).thenThrow(WebServiceException.class);
when(utkastRepository.findOneByIntygsIdAndIntygsTyp(CERTIFICATE_ID, CERTIFICATE_TYPE)).thenReturn(utkast);
IntygContentHolder intygContentHolder = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertEquals(intygContentHolder.getStatuses().size(), 1);
assertNotNull(intygContentHolder.getUtlatande());
assertEquals(timestamp, intygContentHolder.getCreated());
verify(moduleFacade).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(moduleFacade, times(2)).getUtlatandeFromInternalModel(eq(CERTIFICATE_TYPE), anyString());
verify(logservice).logReadIntyg(any(LogRequest.class));
verify(utkastRepository).findOneByIntygsIdAndIntygsTyp(CERTIFICATE_ID, CERTIFICATE_TYPE);
verifyNoMoreInteractions(moduleFacade, logservice, utkastRepository);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testDeceasedIsSetForDeadPatientNormal.
@Test
public void testDeceasedIsSetForDeadPatientNormal() {
when(patientDetailsResolver.isAvliden(any(Personnummer.class))).thenReturn(true);
IntygContentHolder intygData = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertTrue(intygData.isDeceased());
}
Aggregations