Search in sources :

Example 1 with ResultValidator

use of se.inera.intyg.webcert.web.integration.validators.ResultValidator 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());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 2 with ResultValidator

use of se.inera.intyg.webcert.web.integration.validators.ResultValidator 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());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 3 with ResultValidator

use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImplTest method testValidationOfPersonnummerDoesNotExistInPU.

@Test
public void testValidationOfPersonnummerDoesNotExistInPU() {
    when(patientDetailsResolver.getPersonFromPUService(any(Personnummer.class))).thenReturn(buildPersonSvar(PersonSvar.Status.NOT_FOUND));
    ResultValidator result = validator.validateApplicationErrors(buildIntyg(TSBAS, "efternamn", "förnamn", "fullständigt namn", "enhetsnamn", true), user);
    assertTrue(result.hasErrors());
    verify(patientDetailsResolver).getPersonFromPUService(any(Personnummer.class));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Example 4 with ResultValidator

use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImplTest method testTsBasIsNotAllowedWhenPatientCouldNotBeLookedUpInPu.

@Test
public void testTsBasIsNotAllowedWhenPatientCouldNotBeLookedUpInPu() {
    when(patientDetailsResolver.getPersonFromPUService(any(Personnummer.class))).thenReturn(buildPersonSvar(PersonSvar.Status.NOT_FOUND));
    ResultValidator result = validator.validateApplicationErrors(buildIntyg(TSBAS, "efternamn", "förnamn", "fullständigt namn", "enhetsnamn", true), user);
    assertTrue(result.hasErrors());
    verify(patientDetailsResolver).getPersonFromPUService(any(Personnummer.class));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Example 5 with ResultValidator

use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImplTest method testValidateHosPersonalPersonalIdMissing.

@Test
public void testValidateHosPersonalPersonalIdMissing() {
    ResultValidator result = validator.validate(buildIntyg(LUSE, "efternamn", "förnamn", "19121212-1212", "fullständigt namn", null, "enhetsnamn", "enhetHsaId", true));
    assertTrue(result.hasErrors());
}
Also used : ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Aggregations

ResultValidator (se.inera.intyg.webcert.web.integration.validators.ResultValidator)61 Test (org.junit.Test)55 BaseCreateDraftCertificateValidatorTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)44 Personnummer (se.inera.intyg.schemas.contract.Personnummer)17 BaseCreateDraftCertificateTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest)11 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)9 TakResult (se.inera.intyg.webcert.integration.tak.model.TakResult)8 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)7 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)7 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)6 Utlatande (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande)6 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType)6 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType)6 TypAvIntyg (se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg)6 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType)5 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType)5 TypAvUtlatande (se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande)5 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)4 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)4