Search in sources :

Example 11 with CreateNewDraftRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest 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 12 with CreateNewDraftRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest in project webcert by sklintyg.

the class CreateNewDraftRequestBuilderImpl method buildCreateNewDraftRequest.

@Override
public CreateNewDraftRequest buildCreateNewDraftRequest(Intyg intyg, IntygUser user) {
    HoSPersonal hosPerson = createHoSPerson(intyg.getSkapadAv(), HoSPersonHelper.createVardenhetFromIntygUser(intyg.getSkapadAv().getEnhet().getEnhetsId().getExtension(), user));
    HoSPersonHelper.enrichHoSPerson(hosPerson, user);
    return new CreateNewDraftRequest(null, moduleRegistry.getModuleIdFromExternalId(intyg.getTypAvIntyg().getCode()), null, hosPerson, TransportConverterUtil.getPatient(intyg.getPatient(), true), intyg.getRef());
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)

Example 13 with CreateNewDraftRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest in project webcert by sklintyg.

the class UtkastServiceImplTest method testReferensGetsPersistedWhenSupplied.

@Test
public void testReferensGetsPersistedWhenSupplied() throws ModuleNotFoundException, IOException, ModuleException {
    CreateNewDraftRequest request = buildCreateNewDraftRequest();
    request.setReferens(REFERENS);
    setupReferensMocks();
    Utkast res = draftService.createNewDraft(request);
    assertNotNull(res.getSkapad());
    verify(referensService).saveReferens(INTYG_ID, REFERENS);
}
Also used : CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Test(org.junit.Test)

Example 14 with CreateNewDraftRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest in project webcert by sklintyg.

the class UtkastApiControllerTest method testCreateUtkastSetsPatientFullName.

@Test
public void testCreateUtkastSetsPatientFullName() {
    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());
    ArgumentCaptor<CreateNewDraftRequest> requestCaptor = ArgumentCaptor.forClass(CreateNewDraftRequest.class);
    verify(utkastService).createNewDraft(requestCaptor.capture());
    assertNotNull(requestCaptor.getValue().getPatient().getFullstandigtNamn());
    assertEquals(PATIENT_FORNAMN + " " + PATIENT_MELLANNAMN + " " + PATIENT_EFTERNAMN, requestCaptor.getValue().getPatient().getFullstandigtNamn());
}
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 15 with CreateNewDraftRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest in project webcert by sklintyg.

the class UtkastServiceImplTest method testEmptyReferensNotPersisted.

@Test
public void testEmptyReferensNotPersisted() throws ModuleNotFoundException, IOException, ModuleException {
    CreateNewDraftRequest request = buildCreateNewDraftRequest();
    request.setReferens("");
    setupReferensMocks();
    Utkast res = draftService.createNewDraft(request);
    assertNotNull(res.getSkapad());
    verify(referensService, times(0)).saveReferens(INTYG_ID, REFERENS);
}
Also used : CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Test(org.junit.Test)

Aggregations

CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)23 Test (org.junit.Test)14 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)10 BaseCreateDraftCertificateTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest)9 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)4 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)4 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)4 TakResult (se.inera.intyg.webcert.integration.tak.model.TakResult)4 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)4 ResultValidator (se.inera.intyg.webcert.web.integration.validators.ResultValidator)4 Utlatande (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande)3 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType)3 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType)3 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)3 TypAvUtlatande (se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande)3 TypAvIntyg (se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg)3 Response (javax.ws.rs.core.Response)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 QueryIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse)2