Search in sources :

Example 11 with ReceiveMedicalCertificateQuestionType

use of se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType in project webcert by sklintyg.

the class ReceiveQuestionResponderImplTest method createRequest.

private ReceiveMedicalCertificateQuestionType createRequest(String questionFile) {
    ReceiveMedicalCertificateQuestionType request = new ReceiveMedicalCertificateQuestionType();
    QuestionFromFkType question = inflateQuestion(questionFile);
    if (question == null) {
        throw new RuntimeException("Could not inflate file");
    }
    request.setQuestion(question);
    return request;
}
Also used : ReceiveMedicalCertificateQuestionType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType) QuestionFromFkType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType)

Example 12 with ReceiveMedicalCertificateQuestionType

use of se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType in project webcert by sklintyg.

the class ReceiveQuestionResponderImplTest method testReceiveQuestionValidationError.

@Test
public void testReceiveQuestionValidationError() {
    ReceiveMedicalCertificateQuestionType request = createRequest("RecieveQuestionAnswerResponders/question-from-fk-integrated.xml");
    // invalid
    request.getQuestion().setAmne(null);
    ReceiveMedicalCertificateQuestionResponseType response = receiveQuestionResponder.receiveMedicalCertificateQuestion(null, request);
    verifyZeroInteractions(mockNotificationService);
    verifyZeroInteractions(mockFragaSvarService);
    assertNotNull(response);
    assertEquals(ResultCodeEnum.ERROR, response.getResult().getResultCode());
    assertEquals(ErrorIdEnum.VALIDATION_ERROR, response.getResult().getErrorId());
    assertEquals("Amne är felaktigt", response.getResult().getErrorText());
}
Also used : ReceiveMedicalCertificateQuestionType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType) ReceiveMedicalCertificateQuestionResponseType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionResponseType) Test(org.junit.Test)

Example 13 with ReceiveMedicalCertificateQuestionType

use of se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType in project webcert by sklintyg.

the class ReceiveQuestionResponderImplTest method testReceiveQuestionOK.

@Test
public void testReceiveQuestionOK() {
    FragaSvar fraga = buildFraga(INTEGRERAD_ENHET, Status.PENDING_INTERNAL_ACTION);
    when(mockFragaSvarService.processIncomingQuestion(any(FragaSvar.class))).thenReturn(fraga);
    ReceiveMedicalCertificateQuestionType request = createRequest("RecieveQuestionAnswerResponders/question-from-fk-integrated.xml");
    ReceiveMedicalCertificateQuestionResponseType response = receiveQuestionResponder.receiveMedicalCertificateQuestion(null, request);
    // should place notification on queue
    verify(mockNotificationService).sendNotificationForQuestionReceived(any(FragaSvar.class));
    assertNotNull(response);
    assertEquals(ResultCodeEnum.OK, response.getResult().getResultCode());
}
Also used : ReceiveMedicalCertificateQuestionType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType) ReceiveMedicalCertificateQuestionResponseType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionResponseType) Test(org.junit.Test)

Example 14 with ReceiveMedicalCertificateQuestionType

use of se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType in project webcert by sklintyg.

the class QuestionAnswerValidatorTest method createValidQuestionRequest.

private ReceiveMedicalCertificateQuestionType createValidQuestionRequest() {
    ReceiveMedicalCertificateQuestionType request = new ReceiveMedicalCertificateQuestionType();
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(QuestionFromFkType.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        QuestionFromFkType question = unmarshaller.unmarshal(new StreamSource(new ClassPathResource("QuestionAnswerValidator/valid-question-from-fk.xml").getInputStream()), QuestionFromFkType.class).getValue();
        request.setQuestion(question);
        return request;
    } catch (Exception e) {
        throw new RuntimeException("Failed to load QuestionRequest template");
    }
}
Also used : ReceiveMedicalCertificateQuestionType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType) StreamSource(javax.xml.transform.stream.StreamSource) QuestionFromFkType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 15 with ReceiveMedicalCertificateQuestionType

use of se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType in project webcert by sklintyg.

the class QuestionAnswerValidatorTest method testQVCatchesMissingHsaPersonIdRoot.

@Test
public void testQVCatchesMissingHsaPersonIdRoot() {
    // Arrange
    ReceiveMedicalCertificateQuestionType request = createValidQuestionRequest();
    request.getQuestion().getAdressVard().getHosPersonal().getPersonalId().setRoot(null);
    // Act
    final List<String> result = QuestionAnswerValidator.validate(request);
    // Assert
    assertEquals(1, result.size());
}
Also used : ReceiveMedicalCertificateQuestionType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType) Test(org.junit.Test)

Aggregations

ReceiveMedicalCertificateQuestionType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType)21 Test (org.junit.Test)19 ReceiveMedicalCertificateQuestionResponseType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionResponseType)3 QuestionFromFkType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType)2 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 StreamSource (javax.xml.transform.stream.StreamSource)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)1