Search in sources :

Example 91 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class NotificationServiceImplTest method createUtkast.

private Utkast createUtkast() {
    Utkast utkast = new Utkast();
    utkast.setIntygsId(INTYG_ID);
    utkast.setIntygsTyp(INTYG_TYP_FK);
    utkast.setEnhetsId(ENHET_ID);
    utkast.setStatus(UtkastStatus.DRAFT_INCOMPLETE);
    utkast.setModel(INTYG_JSON);
    utkast.setPatientPersonnummer(PATIENT_ID);
    return utkast;
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast)

Example 92 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class UtkastApiControllerTest method testCreateUtkast.

@Test
public void testCreateUtkast() {
    String intygsTyp = "luse";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(new Utkast());
    Response response = utkastController.createUtkast(intygsTyp, buildRequest("luse"));
    assertEquals(OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) QueryIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 93 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class UtkastApiControllerTest method buildUtkast.

private Utkast buildUtkast(Personnummer personnr) {
    Utkast utkast = new Utkast();
    utkast.setIntygsTyp("luse");
    utkast.setVardgivarId("456");
    utkast.setStatus(UtkastStatus.DRAFT_COMPLETE);
    utkast.setSenastSparadAv(new VardpersonReferens());
    utkast.setSenastSparadDatum(LocalDateTime.now());
    utkast.setPatientPersonnummer(personnr);
    return utkast;
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)

Example 94 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class UtkastApiControllerTest method testCreateUtkastSetsPatientFullNameWithoutMiddlename.

@Test
public void testCreateUtkastSetsPatientFullNameWithoutMiddlename() {
    String intygsTyp = "luse";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(new Utkast());
    // Fake PU service being down
    when(patientDetailsResolver.resolvePatient(PATIENT_PERSONNUMMER, intygsTyp)).thenReturn(null);
    CreateUtkastRequest utkastRequest = buildRequest("luse");
    // no middlename
    utkastRequest.setPatientMellannamn(null);
    Response response = utkastController.createUtkast(intygsTyp, utkastRequest);
    assertEquals(OK.getStatusCode(), response.getStatus());
    ArgumentCaptor<CreateNewDraftRequest> requestCaptor = ArgumentCaptor.forClass(CreateNewDraftRequest.class);
    verify(utkastService).createNewDraft(requestCaptor.capture());
    assertNotNull(requestCaptor.getValue().getPatient().getFullstandigtNamn());
    assertEquals(PATIENT_FORNAMN + " " + PATIENT_EFTERNAMN, requestCaptor.getValue().getPatient().getFullstandigtNamn());
}
Also used : CreateUtkastRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest) Response(javax.ws.rs.core.Response) QueryIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 95 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class UtkastApiControllerTest method testCreateUtkastFornamnOk.

@Test
public void testCreateUtkastFornamnOk() {
    String intygsTyp = "luse";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(new Utkast());
    CreateUtkastRequest utkastRequest = buildRequest(intygsTyp);
    utkastRequest.setPatientFornamn(Strings.repeat("a", 255));
    Response response = utkastController.createUtkast(intygsTyp, utkastRequest);
    assertEquals(OK.getStatusCode(), response.getStatus());
}
Also used : CreateUtkastRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest) Response(javax.ws.rs.core.Response) QueryIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)171 Test (org.junit.Test)88 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)34 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 Personnummer (se.inera.intyg.schemas.contract.Personnummer)21 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)21 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)21 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)18 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)17 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)16 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)13 Patient (se.inera.intyg.common.support.model.common.internal.Patient)12 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)12 ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)12 Transactional (org.springframework.transaction.annotation.Transactional)11 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)11 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)11 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)10 ArrayList (java.util.ArrayList)9