Search in sources :

Example 21 with IntygContentHolder

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);
}
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 22 with IntygContentHolder

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

Example 23 with IntygContentHolder

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());
}
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 24 with IntygContentHolder

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

Example 25 with IntygContentHolder

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());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) 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