Search in sources :

Example 6 with IntygContentHolder

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());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) WebServiceException(javax.xml.ws.WebServiceException) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Patient(se.inera.intyg.common.support.model.common.internal.Patient) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 7 with IntygContentHolder

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);
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Test(org.junit.Test)

Example 8 with IntygContentHolder

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());
}
Also used : CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest) CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) ValidateDraftResponse(se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 9 with IntygContentHolder

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);
}
Also used : CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 10 with IntygContentHolder

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());
}
Also used : CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) ValidateDraftResponse(se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse) Test(org.junit.Test)

Aggregations

IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)30 Test (org.junit.Test)23 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)9 Personnummer (se.inera.intyg.schemas.contract.Personnummer)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 Patient (se.inera.intyg.common.support.model.common.internal.Patient)5 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)5 CreateDraftCopyHolder (se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder)4 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)4 Person (se.inera.intyg.infra.integration.pu.model.Person)4 LocalDateTime (java.time.LocalDateTime)3 WebServiceException (javax.xml.ws.WebServiceException)3 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)3 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)3 IntygModuleFacadeException (se.inera.intyg.webcert.web.service.intyg.converter.IntygModuleFacadeException)3 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)3 Response (javax.ws.rs.core.Response)2 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)2 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)2 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)2