Search in sources :

Example 1 with CreateDraftCertificateResponseType

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

the class CreateDraftCertificateV1IT method testCreateDeprecatedGivesCorrectErrorMessage.

@Test
public void testCreateDeprecatedGivesCorrectErrorMessage() {
    Response resp = given().cookie("ROUTEID", ".1").filter(responseBodyExtractorFilter).body(createRequestBody(FK7263, DEFAULT_LAKARE_HSAID)).when().post(CREATE_DRAFT_CERTIFICATE_V1_0).then().statusCode(200).rootPath(BASE).extract().response();
    CreateDraftCertificateResponseType responseBody = resp.getBody().as(CreateDraftCertificateResponseType.class);
    assertEquals(String.format(DEPRECATED_ERROR_MSG, FK7263), responseBody.getResult().getResultText());
}
Also used : Response(com.jayway.restassured.response.Response) CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) BaseWSIntegrationTest(se.inera.intyg.webcert.web.integration.integrationtest.BaseWSIntegrationTest) Test(org.junit.Test)

Example 2 with CreateDraftCertificateResponseType

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

the class CreateDraftCertificateV3IT method testCreateDeprecatedGivesCorrectErrorMessage.

@Test
public void testCreateDeprecatedGivesCorrectErrorMessage() {
    Response resp = given().cookie("ROUTEID", ".1").filter(responseBodyExtractorFilter).body(createRequestBody(FK7263, DEFAULT_LAKARE_HSAID)).when().post(CREATE_DRAFT_CERTIFICATE_V3_0).then().statusCode(200).rootPath(BASE).extract().response();
    CreateDraftCertificateResponseType responseBody = resp.getBody().as(CreateDraftCertificateResponseType.class);
    assertEquals(String.format(DEPRECATED_ERROR_MSG, FK7263.toLowerCase()), responseBody.getResult().getResultText());
}
Also used : Response(com.jayway.restassured.response.Response) CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) BaseWSIntegrationTest(se.inera.intyg.webcert.web.integration.integrationtest.BaseWSIntegrationTest) Test(org.junit.Test)

Example 3 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType 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 4 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() {
    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 5 with CreateDraftCertificateResponseType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType 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)

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