use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.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;
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.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;
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.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);
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.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);
}
use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.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);
}
Aggregations