Search in sources :

Example 1 with CreateUtkastRequest

use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest 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 2 with CreateUtkastRequest

use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest 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)

Example 3 with CreateUtkastRequest

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

the class UtkastApiControllerTest method buildRequest.

private CreateUtkastRequest buildRequest(String typ) {
    CreateUtkastRequest request = new CreateUtkastRequest();
    request.setIntygType(typ);
    request.setPatientEfternamn(PATIENT_EFTERNAMN);
    request.setPatientFornamn(PATIENT_FORNAMN);
    request.setPatientMellannamn(PATIENT_MELLANNAMN);
    request.setPatientPersonnummer(PATIENT_PERSONNUMMER);
    request.setPatientPostadress(PATIENT_POSTADRESS);
    request.setPatientPostnummer(PATIENT_POSTNUMMER);
    request.setPatientPostort(PATIENT_POSTORT);
    return request;
}
Also used : CreateUtkastRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest)

Example 4 with CreateUtkastRequest

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

the class UtkastApiControllerTest method testCreateUtkastEfternamnTooLong.

@Test
public void testCreateUtkastEfternamnTooLong() {
    String intygsTyp = "luse";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    CreateUtkastRequest utkastRequest = buildRequest(intygsTyp);
    utkastRequest.setPatientEfternamn(Strings.repeat("a", 256));
    Response response = utkastController.createUtkast(intygsTyp, utkastRequest);
    assertEquals(BAD_REQUEST.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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 5 with CreateUtkastRequest

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

the class UtkastApiControllerTest method testCreateUtkastEfternamnOk.

@Test
public void testCreateUtkastEfternamnOk() {
    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.setPatientEfternamn(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

CreateUtkastRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest)10 Test (org.junit.Test)6 QueryIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse)6 Response (javax.ws.rs.core.Response)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)3 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)3 JsonPath (com.jayway.restassured.path.json.JsonPath)2 Response (com.jayway.restassured.response.Response)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 BaseRestIntegrationTest (se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)1