use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testThatIncompletePatientAddressIsNotUsedWhenIntygtjanstIsUnavailable.
@Test
public void testThatIncompletePatientAddressIsNotUsedWhenIntygtjanstIsUnavailable() 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 = "";
String 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());
assertNotEquals(postadress, argumentCaptor.getValue().getPostadress());
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntygDataUtkastNotFound.
@Test
public void testFetchIntygDataUtkastNotFound() throws Exception {
IntygContentHolder res = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertNull(res.getCreated());
verify(moduleFacade).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(utkastRepository).findOneByIntygsIdAndIntygsTyp(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(logservice).logReadIntyg(any(LogRequest.class));
verify(mockMonitoringService).logIntygRead(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(intygRelationHelper).getRelationsForIntyg(CERTIFICATE_ID);
verifyNoMoreInteractions(moduleFacade, utkastRepository, logservice, mockMonitoringService, intygRelationHelper);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class CopyCompletionUtkastBuilderTest method testPopulateCompletionFromSignedIntyg.
@Test
public void testPopulateCompletionFromSignedIntyg() throws Exception {
IntygContentHolder ich = createIntygContentHolder();
when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, false)).thenReturn(ich);
CreateCompletionCopyRequest copyRequest = buildCompletionRequest();
copyRequest.setMeddelandeId("meddelandeId");
Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
ValidateDraftResponse vdr = new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>());
when(mockModuleApi.validateDraft(isNull())).thenReturn(vdr);
CopyUtkastBuilderResponse builderResponse = copyCompletionBuilder.populateCopyUtkastFromSignedIntyg(copyRequest, patientDetails, true, false, false);
assertNotNull(builderResponse.getUtkastCopy());
assertNotNull(builderResponse.getUtkastCopy().getModel());
assertEquals(INTYG_TYPE, builderResponse.getUtkastCopy().getIntygsTyp());
assertEquals(PATIENT_SSN, builderResponse.getUtkastCopy().getPatientPersonnummer());
assertEquals(PATIENT_FNAME, builderResponse.getUtkastCopy().getPatientFornamn());
assertEquals(PATIENT_MNAME, builderResponse.getUtkastCopy().getPatientMellannamn());
assertEquals(PATIENT_LNAME, builderResponse.getUtkastCopy().getPatientEfternamn());
assertEquals(INTYG_ID, builderResponse.getUtkastCopy().getRelationIntygsId());
ArgumentCaptor<CreateDraftCopyHolder> requestCaptor = ArgumentCaptor.forClass(CreateDraftCopyHolder.class);
verify(mockModuleApi).createCompletionFromTemplate(requestCaptor.capture(), any(), eq(KOMMENTAR));
// verify full name is set
assertNotNull(requestCaptor.getValue().getPatient().getFullstandigtNamn());
assertEquals(PATIENT_FNAME + " " + PATIENT_MNAME + " " + PATIENT_LNAME, requestCaptor.getValue().getPatient().getFullstandigtNamn());
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromSignedIntygEnforceVardenhet.
@Test(expected = WebCertServiceException.class)
public void testPopulateRenewalUtkastFromSignedIntygEnforceVardenhet() throws Exception {
IntygContentHolder ich = createIntygContentHolder();
when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, true)).thenReturn(ich);
CreateRenewalCopyRequest renewalRequest = buildRenewalRequest();
Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
renewalBuilder.populateCopyUtkastFromSignedIntyg(renewalRequest, patientDetails, false, true, true);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromSignedIntygWithNoPatientDetails.
@Test
public void testPopulateRenewalUtkastFromSignedIntygWithNoPatientDetails() throws Exception {
IntygContentHolder ich = createIntygContentHolder();
when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, false)).thenReturn(ich);
CreateRenewalCopyRequest renewalRequest = buildRenewalRequest();
when(mockModuleApi.createRenewalFromTemplate(any(CreateDraftCopyHolder.class), any())).thenReturn(INTYG_JSON);
ValidateDraftResponse vdr = new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>());
when(mockModuleApi.validateDraft(anyString())).thenReturn(vdr);
CopyUtkastBuilderResponse builderResponse = renewalBuilder.populateCopyUtkastFromSignedIntyg(renewalRequest, null, false, false, false);
assertNotNull(builderResponse.getUtkastCopy());
assertNotNull(builderResponse.getUtkastCopy().getModel());
assertEquals(INTYG_TYPE, builderResponse.getUtkastCopy().getIntygsTyp());
assertEquals(PATIENT_SSN, builderResponse.getUtkastCopy().getPatientPersonnummer());
assertEquals("Test", builderResponse.getUtkastCopy().getPatientFornamn());
assertNull(builderResponse.getUtkastCopy().getPatientMellannamn());
assertEquals("Testorsson", builderResponse.getUtkastCopy().getPatientEfternamn());
}
Aggregations