Search in sources :

Example 11 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImpl method createErrorResponse.

/**
 * The response sent back to caller when an error is raised.
 */
private CreateDraftCertificateResponseType createErrorResponse(String errorMsg, ErrorIdType errorType) {
    ResultType result = ResultTypeUtil.errorResult(errorType, errorMsg);
    CreateDraftCertificateResponseType response = new CreateDraftCertificateResponseType();
    response.setResult(result);
    return response;
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v1.ResultType)

Example 12 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImpl method createErrorResponse.

/**
 * The response sent back to caller when an error is raised.
 */
private CreateDraftCertificateResponseType createErrorResponse(String errorMsg, ErrorIdType errorType) {
    ResultType result = ResultTypeUtil.errorResult(errorType, errorMsg);
    CreateDraftCertificateResponseType response = new CreateDraftCertificateResponseType();
    response.setResult(result);
    return response;
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)

Example 13 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateSuccess.

@Test
public void testCreateDraftCertificateSuccess() {
    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()));
    when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(eq(SekretessStatus.FALSE));
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verify(mockUtkastService).createNewDraft(any(CreateNewDraftRequest.class));
    verify(mockIntegreradeEnheterService).putIntegreradEnhet(any(IntegreradEnhetEntry.class), eq(false), eq(true));
    verify(takService).verifyTakningForCareUnit(any(String.class), eq(UTKAST_TYPE), eq(SchemaVersion.VERSION_3), any(IntygUser.class));
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.OK);
    assertEquals(response.getIntygsId().getRoot(), UNIT_HSAID);
    assertEquals(response.getIntygsId().getExtension(), UTKAST_ID);
}
Also used : 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) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) Personnummer(se.inera.intyg.schemas.contract.Personnummer) CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 14 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateValidationError.

@Test
public void testCreateDraftCertificateValidationError() {
    ResultValidator resultValidator = mock(ResultValidator.class);
    CreateDraftCertificateType certificateType = createCertificateType();
    when(resultValidator.hasErrors()).thenReturn(true);
    when(mockValidator.validate(any(Intyg.class))).thenReturn(resultValidator);
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    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) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 15 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateVardenhetAlredyExistsInRegistry.

@Test
public void testCreateDraftCertificateVardenhetAlredyExistsInRegistry() {
    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)

Aggregations

Test (org.junit.Test)14 BaseCreateDraftCertificateTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest)12 ResultValidator (se.inera.intyg.webcert.web.integration.validators.ResultValidator)12 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType)9 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType)9 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)8 TakResult (se.inera.intyg.webcert.integration.tak.model.TakResult)7 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)7 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)6 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType)6 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType)6 TypAvIntyg (se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg)6 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)5 Utlatande (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande)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 Response (com.jayway.restassured.response.Response)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2