Search in sources :

Example 16 with Relations

use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.

the class IntygRelationHelperImplTest method testGetRelationsForIntygOneInITAndTwoFromWebcert.

@Test
public void testGetRelationsForIntygOneInITAndTwoFromWebcert() {
    when(listRelationsForCertificateResponderInterface.listRelationsForCertificate(isNull(), any(ListRelationsForCertificateType.class))).thenReturn(buildResponse());
    when(certificateRelationService.getRelations(INTYG_ID)).thenReturn(buildWebcertRelations());
    Relations relationsForIntyg = testee.getRelationsForIntyg(INTYG_ID);
    assertNotNull(relationsForIntyg);
    assertFrontendRelationsIntygsIds(relationsForIntyg.getLatestChildRelations(), OTHER_INTYG_ID_3, null, OTHER_INTYG_ID, OTHER_INTYG_ID_2);
}
Also used : ListRelationsForCertificateType(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateType) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) IntygRelations(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations) Test(org.junit.Test)

Example 17 with Relations

use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method getDraftShouldNotPatchIfNewAddressIsIncomplete.

@Test
public void getDraftShouldNotPatchIfNewAddressIsIncomplete() throws Exception {
    // Given
    String intygsTyp = "gdsnpinaii-intygsTyp";
    String intygsId = "gdsnpinaii-intygsId";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.getDraft(CERTIFICATE_ID, intygsTyp)).thenReturn(buildUtkast(intygsTyp, intygsId));
    when(certificateRelationService.getRelations(eq(intygsId))).thenReturn(new Relations());
    String postadress = "gdsnpinaii-postadress";
    String postort = "";
    String postnummer = "gdsnpinaii-postnummer";
    Patient patientWithIncompleteAddress = buildPatient();
    patientWithIncompleteAddress.setPostadress(postadress);
    patientWithIncompleteAddress.setPostort(postort);
    patientWithIncompleteAddress.setPostnummer(postnummer);
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
    // When
    Response response = moduleApiController.getDraft(intygsTyp, CERTIFICATE_ID, request);
    // Then
    ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
    verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
    assertNotEquals(postadress, argumentCaptor.getValue().getPostadress());
    assertNotEquals(postnummer, argumentCaptor.getValue().getPostnummer());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Response(javax.ws.rs.core.Response) SaveDraftResponse(se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 18 with Relations

use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method getDraftShouldPatchIfNewAddressExist.

@Test
public void getDraftShouldPatchIfNewAddressExist() throws Exception {
    // Given
    String intygsTyp = "gdspinae-intygsTyp";
    String intygsId = "gdspinae-intygsId";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.getDraft(CERTIFICATE_ID, intygsTyp)).thenReturn(buildUtkast(intygsTyp, intygsId));
    when(certificateRelationService.getRelations(eq(intygsId))).thenReturn(new Relations());
    String postadress = "gdspinae-postadress";
    String postort = "gdspinae-postort";
    String postnummer = "gdspinae-postnummer";
    Patient patientWithIncompleteAddress = buildPatient();
    patientWithIncompleteAddress.setPostadress(postadress);
    patientWithIncompleteAddress.setPostort(postort);
    patientWithIncompleteAddress.setPostnummer(postnummer);
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
    // When
    Response response = moduleApiController.getDraft(intygsTyp, CERTIFICATE_ID, request);
    // 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) Response(javax.ws.rs.core.Response) SaveDraftResponse(se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 19 with Relations

use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.

the class CertificateRelationServiceImplTest method testGetWithParentRelation.

@Test
public void testGetWithParentRelation() {
    when(utkastRepositoryCustom.findParentRelation(anyString())).thenReturn(buildParentRelations());
    Relations relations = testee.getRelations(INTYG_ID);
    assertEquals(OTHER_INTYG_ID, relations.getParent().getIntygsId());
    assertFrontendRelations(relations.getLatestChildRelations(), null, null, null, null);
}
Also used : Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) Test(org.junit.Test)

Example 20 with Relations

use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.

the class CertificateRelationServiceImplTest method testGetWithNoRelations.

@Test
public void testGetWithNoRelations() {
    Relations relations = testee.getRelations(INTYG_ID);
    assertNull(relations.getParent());
    assertFrontendRelations(relations.getLatestChildRelations(), null, null, null, null);
}
Also used : Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) Test(org.junit.Test)

Aggregations

Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)27 Test (org.junit.Test)12 IntygRelations (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)11 ListRelationsForCertificateType (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateType)7 Patient (se.inera.intyg.common.support.model.common.internal.Patient)7 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Personnummer (se.inera.intyg.schemas.contract.Personnummer)5 ArrayList (java.util.ArrayList)4 ListRelationsForCertificateResponseType (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponseType)4 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)4 Status (se.inera.intyg.common.support.model.Status)4 Response (javax.ws.rs.core.Response)3 Before (org.junit.Before)3 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)3 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)3 CertificateResponse (se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse)3 ValidationStatus (se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus)3 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)3