use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateTakningNotOk.
@Test
public void testCreateDraftCertificateTakningNotOk() {
// Given
ResultValidator resultsValidator = new ResultValidator();
CreateDraftCertificateType certificateType = createCertificateType();
// When
when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(false, Lists.newArrayList("Den angivna enheten går ej att adressera för ärendekommunikation.")));
// Then
CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
verify(takService).verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class));
// Assert response content
assertNotNull(response);
assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
assertEquals(ErrorIdType.APPLICATION_ERROR, response.getResult().getErrorId());
assertEquals("Den angivna enheten går ej att adressera för ärendekommunikation.", response.getResult().getResultText());
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateValidationError.
@Test
public void testCreateDraftCertificateValidationError() {
final String validationError = "error";
ResultValidator resultsValidator = new ResultValidator();
resultsValidator.addError(validationError);
CreateDraftCertificateType certificateType = createCertificateType();
when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
verifyZeroInteractions(mockUtkastService);
verifyZeroInteractions(mockIntegreradeEnheterService);
assertNotNull(response);
assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
assertEquals(validationError, response.getResult().getResultText());
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateNoMIUs.
@Test
public void testCreateDraftCertificateNoMIUs() {
WebCertUser userWithoutMiu = buildWebCertUser();
userWithoutMiu.setVardgivare(new ArrayList<>());
when(webcertUserDetailsService.loadUserByHsaId(USER_HSAID)).thenReturn(userWithoutMiu);
CreateDraftCertificateType certificateType = createCertificateType();
when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
verify(mockMonitoringLogService).logMissingMedarbetarUppdrag(USER_HSAID, UNIT_HSAID);
assertNotNull(response);
assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
assertEquals(response.getResult().getErrorId(), ErrorIdType.VALIDATION_ERROR);
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateTakningNotOK.
@Test
public void testCreateDraftCertificateTakningNotOK() {
CreateDraftCertificateType certificateType = createCertificateType();
when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(false, Lists.newArrayList("Den angivna enheten går ej att adressera för ärendekommunikation.")));
CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
verify(takService).verifyTakningForCareUnit(any(String.class), eq(UTKAST_TYPE), eq(SchemaVersion.VERSION_3), any(IntygUser.class));
assertNotNull(response);
assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
assertEquals(response.getResult().getErrorId(), ErrorIdType.APPLICATION_ERROR);
assertEquals("Den angivna enheten går ej att adressera för ärendekommunikation.", response.getResult().getResultText());
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method createCertificateType.
private CreateDraftCertificateType createCertificateType() {
// Type
TypAvIntyg utlTyp = new TypAvIntyg();
utlTyp.setCode("fk7263");
// HoSPerson
HsaId userHsaId = new HsaId();
userHsaId.setExtension(USER_HSAID);
userHsaId.setRoot("USERHSAID");
HsaId unitHsaId = new HsaId();
unitHsaId.setExtension(UNIT_HSAID);
unitHsaId.setRoot("UNITHSAID");
Enhet hosEnhet = new Enhet();
hosEnhet.setEnhetsId(unitHsaId);
HosPersonal hosPerson = new HosPersonal();
hosPerson.setFullstandigtNamn("Abel Baker");
hosPerson.setPersonalId(userHsaId);
hosPerson.setEnhet(hosEnhet);
// Patient
PersonId personId = new PersonId();
personId.setRoot("PERSNR");
personId.setExtension("19121212-1212");
Patient patType = new Patient();
patType.setPersonId(personId);
patType.setFornamn("Adam");
patType.setMellannamn("Cesarsson");
patType.setEfternamn("Eriksson");
Intyg utlatande = new Intyg();
utlatande.setTypAvIntyg(utlTyp);
utlatande.setSkapadAv(hosPerson);
utlatande.setPatient(patType);
utlatande.setRef("Test-ref");
CreateDraftCertificateType certificateType = new CreateDraftCertificateType();
certificateType.setIntyg(utlatande);
return certificateType;
}
Aggregations