use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateMultipleMIUs.
@Test
public void testCreateDraftCertificateMultipleMIUs() {
CreateNewDraftRequest draftRequest = createCreateNewDraftRequest(createVardenhet(createVardgivare()));
CreateDraftCertificateType certificateType = createCertificateType();
VardpersonReferens vardperson = createVardpersonReferens(certificateType.getIntyg().getSkapadAv().getPersonalId().getRoot(), certificateType.getIntyg().getSkapadAv().getFullstandigtNamn());
Utkast utkast = createUtkast(UTKAST_ID, Long.parseLong(UTKAST_VERSION), UTKAST_TYPE, UtkastStatus.DRAFT_INCOMPLETE, UTKAST_JSON, vardperson);
when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
when(mockRequestBuilder.buildCreateNewDraftRequest(any(Intyg.class), any(IntygUser.class))).thenReturn(draftRequest);
when(mockUtkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(utkast);
when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(true, Lists.emptyList()));
CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
verify(mockUtkastService).createNewDraft(any(CreateNewDraftRequest.class));
verify(mockIntegreradeEnheterService).putIntegreradEnhet(any(IntegreradEnhetEntry.class), eq(false), eq(true));
assertNotNull(response);
assertEquals(response.getResult().getResultCode(), ResultCodeType.OK);
assertEquals(response.getIntygsId().getExtension(), UTKAST_ID);
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeConverterTest method testDecorateArendeFromUtkastHsaNotResponding.
@Test
public void testDecorateArendeFromUtkastHsaNotResponding() {
Utkast utkast = new Utkast();
utkast.setIntygsTyp("intygstyp");
utkast.setEnhetsId("enhetsid");
utkast.setSignatur(mock(Signatur.class));
when(utkast.getSignatur().getSigneradAv()).thenReturn("signeratav");
when(hsaEmployeeService.getEmployee(anyString(), eq(null))).thenThrow(new WebServiceException());
try {
ArendeConverter.decorateArendeFromUtkast(new Arende(), utkast, LocalDateTime.now(), hsaEmployeeService);
fail("Should throw");
} catch (WebCertServiceException e) {
assertEquals(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getErrorCode());
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeConverterTest method testCreateArendeQuestionFromUtkast.
@Test
public void testCreateArendeQuestionFromUtkast() throws CertificateSenderException {
final ArendeAmne amne = ArendeAmne.OVRIGT;
final String enhetsId = "enhetsId";
final String intygsId = "intygsId";
final String intygsTyp = "luse";
final String meddelande = "meddelande";
final String patientPersonId = "191212121212";
final String rubrik = "rubrik";
final String signeratAv = "hsa123";
final String givenName = "givenname";
final String surname = "surname";
final String vardaktorName = "vardaktor namn";
final String enhetName = "enhet namn";
final String vardgivareName = "vardgivare namn";
final LocalDateTime now = LocalDateTime.now();
Utkast utkast = new Utkast();
utkast.setEnhetsId(enhetsId);
utkast.setEnhetsNamn(enhetName);
utkast.setVardgivarNamn(vardgivareName);
utkast.setIntygsId(intygsId);
utkast.setIntygsTyp(intygsTyp);
utkast.setPatientPersonnummer(Personnummer.createPersonnummer(patientPersonId).get());
utkast.setSignatur(mock(Signatur.class));
when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
when(hsaEmployeeService.getEmployee(signeratAv, null)).thenReturn(createHsaResponse(givenName, surname));
Arende res = ArendeConverter.createArendeFromUtkast(amne, rubrik, meddelande, utkast, now, vardaktorName, hsaEmployeeService);
assertNotNull(res);
assertEquals(amne, res.getAmne());
assertEquals(enhetsId, res.getEnhetId());
assertEquals(enhetName, res.getEnhetName());
assertEquals(vardgivareName, res.getVardgivareName());
assertEquals(intygsId, res.getIntygsId());
assertEquals(intygsTyp, res.getIntygTyp());
assertEquals(meddelande, res.getMeddelande());
assertNotNull(res.getMeddelandeId());
assertNull(res.getPaminnelseMeddelandeId());
assertEquals(patientPersonId, res.getPatientPersonId());
assertNull(res.getReferensId());
assertEquals(rubrik, res.getRubrik());
assertEquals(now, res.getSenasteHandelse());
assertEquals(now, res.getSkickatTidpunkt());
assertEquals(now, res.getTimestamp());
assertEquals(signeratAv, res.getSigneratAv());
assertEquals(givenName + " " + surname, res.getSigneratAvName());
assertNull(res.getSistaDatumForSvar());
assertEquals(FrageStallare.WEBCERT.getKod(), res.getSkickatAv());
assertEquals(Status.PENDING_EXTERNAL_ACTION, res.getStatus());
assertNull(res.getSvarPaId());
assertNull(res.getSvarPaReferens());
assertEquals(Boolean.FALSE, res.getVidarebefordrad());
assertEquals(vardaktorName, res.getVardaktorName());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeConverterTest method testDecorateArendeFromUtkast.
@Test
public void testDecorateArendeFromUtkast() throws WebCertServiceException {
final String intygTyp = "intygTyp";
final String signeratAv = "signeratAv";
final String enhetId = "enhetId";
final String enhetName = "enhetName";
final String vardgivareName = "vardgivareName";
final LocalDateTime now = LocalDateTime.now();
final String givenName = "Test";
final String surname = "Testorsson Svensson";
Utkast utkast = new Utkast();
utkast.setIntygsTyp(intygTyp);
utkast.setEnhetsId(enhetId);
utkast.setEnhetsNamn(enhetName);
utkast.setVardgivarNamn(vardgivareName);
utkast.setSignatur(mock(Signatur.class));
when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
when(hsaEmployeeService.getEmployee(eq(signeratAv), eq(null))).thenReturn(createHsaResponse(givenName, surname));
Arende res = new Arende();
ArendeConverter.decorateArendeFromUtkast(res, utkast, now, hsaEmployeeService);
assertNotNull(res);
assertEquals(now, res.getTimestamp());
assertEquals(now, res.getSenasteHandelse());
assertEquals(Boolean.FALSE, res.getVidarebefordrad());
assertEquals(Status.PENDING_INTERNAL_ACTION, res.getStatus());
assertEquals(intygTyp, res.getIntygTyp());
assertEquals(signeratAv, res.getSigneratAv());
assertEquals(enhetId, res.getEnhetId());
assertEquals(enhetName, res.getEnhetName());
assertEquals(vardgivareName, res.getVardgivareName());
assertEquals("Test Testorsson Svensson", res.getSigneratAvName());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeConverterTest method testDecorateArendeFromUtkastNoGivenName.
@Test
public void testDecorateArendeFromUtkastNoGivenName() throws WebCertServiceException {
final String intygId = "intygsid";
final String intygTyp = "intygTyp";
final String signeratAv = "signeratAv";
final String givenName = null;
final String surname = "Testorsson Svensson";
Arende arende = new Arende();
arende.setIntygsId(intygId);
Utkast utkast = new Utkast();
utkast.setIntygsTyp(intygTyp);
utkast.setSignatur(mock(Signatur.class));
when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
when(hsaEmployeeService.getEmployee(eq(signeratAv), eq(null))).thenReturn(createHsaResponse(givenName, surname));
Arende res = new Arende();
ArendeConverter.decorateArendeFromUtkast(res, utkast, LocalDateTime.now(), hsaEmployeeService);
assertNotNull(res);
assertEquals("Testorsson Svensson", res.getSigneratAvName());
}
Aggregations