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