Search in sources :

Example 16 with ResultValidator

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

the class CreateDraftCertificateValidatorImplTest method testValidateEnhetEnhetsIdExtensionMissing.

@Test
public void testValidateEnhetEnhetsIdExtensionMissing() {
    ResultValidator result = validator.validate(buildIntyg(LUSE, "efternamn", "förnamn", "19121212-1212", "fullständigt namn", "hosHsaId", "enhetsnamn", "", 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)

Example 17 with ResultValidator

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

Example 18 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() {
    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());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) 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 19 with ResultValidator

use of se.inera.intyg.webcert.web.integration.validators.ResultValidator 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);
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 20 with ResultValidator

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

the class CreateDraftCertificateValidatorImplTest method testValidateHoSPersonalFullstandigtnamnMissing.

@Test
public void testValidateHoSPersonalFullstandigtnamnMissing() {
    ResultValidator result = validator.validate(buildIntyg(LUSE, "efternamn", "fornamn", null, "enhetsId", "enhetsnamn", 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