Search in sources :

Example 1 with QuestionFromFkType

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

the class ReceiveQuestionResponderImplTest method inflateQuestion.

private QuestionFromFkType inflateQuestion(String filePath) {
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(QuestionFromFkType.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        QuestionFromFkType question = unmarshaller.unmarshal(new StreamSource(new ClassPathResource(filePath).getInputStream()), QuestionFromFkType.class).getValue();
        return question;
    } catch (Exception e) {
        return null;
    }
}
Also used : 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 2 with QuestionFromFkType

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

the class FKAnswerConverterTest method testConvertAnswer.

@Test
public void testConvertAnswer() throws Exception {
    QuestionFromFkType questionFromFK = inflateQuestionFromFK();
    AnswerToFkType referenceAnswerToFK = inflateAnswerToFK();
    // convert QuestionFromFK to FragaSvar entity
    FragaSvar fragaSvar = fragaSvarConverter.convert(questionFromFK);
    // add some data
    fragaSvar.setInternReferens(321L);
    fragaSvar.setSvarsText(fragaSvar.getFrageText());
    fragaSvar.setSvarSigneringsDatum(fragaSvar.getFrageSigneringsDatum());
    // convert FragaSvar entity to AnswerToFK
    AnswerToFkType convertedAnswerToFK = FKAnswerConverter.convert(fragaSvar);
    // compare convertedAnswerToFK to reference
    String expected = jaxbToXml(referenceAnswerToFK);
    String actual = jaxbToXml(convertedAnswerToFK);
    assertEquals(expected, actual);
}
Also used : QuestionFromFkType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Test(org.junit.Test)

Example 3 with QuestionFromFkType

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

the class FKAnswerConverterTest method inflateQuestionFromFK.

private QuestionFromFkType inflateQuestionFromFK() throws Exception {
    JAXBContext jaxbContext = JAXBContext.newInstance(QuestionFromFkType.class);
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    return unmarshaller.unmarshal(new StreamSource(new ClassPathResource("FragaSvarConverterTest/question.xml").getInputStream()), QuestionFromFkType.class).getValue();
}
Also used : 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 4 with QuestionFromFkType

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

the class FKQuestionConverterTest method testConvertQuestion.

@Test
public void testConvertQuestion() throws Exception {
    QuestionFromFkType questionFromFK = inflateQuestionFromFK();
    QuestionToFkType referenceQuestionToFK = inflateQuestionToFK();
    // convert QuestionFromFK to FragaSvar entity
    FragaSvar fragaSvar = fragaSvarConverter.convert(questionFromFK);
    // add some data
    fragaSvar.setAmne(Amne.KONTAKT);
    fragaSvar.setInternReferens(321L);
    // convert fragaSvar entity to QuestionToFK
    QuestionToFkType convertedQuestionToFK = FKQuestionConverter.convert(fragaSvar);
    // compare convertedQuestionToFK to reference
    String expected = jaxbToXml(referenceQuestionToFK);
    String actual = jaxbToXml(convertedQuestionToFK);
    assertEquals(expected, actual);
}
Also used : QuestionFromFkType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) QuestionToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType) Test(org.junit.Test)

Example 5 with QuestionFromFkType

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

the class FragaSvarConverterTest method question.

private QuestionFromFkType question(String fileName) throws Exception {
    JAXBContext jaxbContext = JAXBContext.newInstance(QuestionFromFkType.class);
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    return unmarshaller.unmarshal(new StreamSource(new ClassPathResource(fileName).getInputStream()), QuestionFromFkType.class).getValue();
}
Also used : 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)

Aggregations

QuestionFromFkType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType)8 JAXBContext (javax.xml.bind.JAXBContext)5 Unmarshaller (javax.xml.bind.Unmarshaller)5 StreamSource (javax.xml.transform.stream.StreamSource)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5 Test (org.junit.Test)2 ReceiveMedicalCertificateQuestionType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.ReceiveMedicalCertificateQuestionType)2 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)2 AnswerToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)1 QuestionToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType)1