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());
}
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());
}
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;
}
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());
}
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());
}
Aggregations