Search in sources :

Example 1 with CompositionTestDataStructuredJson

use of org.ehrbase.test_data.composition.CompositionTestDataStructuredJson in project openEHR_SDK by ehrbase.

the class StructuredJsonTest method testRoundTripCorona.

@Test
void testRoundTripCorona() throws IOException {
    CompositionTestDataStructuredJson testData = CompositionTestDataStructuredJson.CORONA;
    String templateId = OperationalTemplateTestData.CORONA_ANAMNESE.getTemplateId();
    test(testData, templateId);
}
Also used : CompositionTestDataStructuredJson(org.ehrbase.test_data.composition.CompositionTestDataStructuredJson) Test(org.junit.jupiter.api.Test)

Example 2 with CompositionTestDataStructuredJson

use of org.ehrbase.test_data.composition.CompositionTestDataStructuredJson in project openEHR_SDK by ehrbase.

the class StructuredJsonTest method test.

private void test(CompositionTestDataStructuredJson testData, String templateId) throws IOException {
    RMDataFormat cut = new FlatJasonProvider(templateProvider).buildFlatJson(FlatFormat.STRUCTURED, templateId);
    String flat = IOUtils.toString(testData.getStream(), StandardCharsets.UTF_8);
    Composition unmarshal = cut.unmarshal(flat);
    SoftAssertions softAssertions = new SoftAssertions();
    softAssertions.assertThat(unmarshal).isNotNull();
    RMObjectValidator rmObjectValidator = new RMObjectValidator(ArchieRMInfoLookup.getInstance(), s -> null);
    softAssertions.assertThat(rmObjectValidator.validate(unmarshal)).filteredOn(m -> !m.getMessage().contains("Inv_null_flavour_indicated")).containsExactlyInAnyOrder();
    String actual = cut.marshal(unmarshal);
    String expected = IOUtils.toString(testData.getStream(), StandardCharsets.UTF_8);
    JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
}
Also used : CompositionTestDataStructuredJson(org.ehrbase.test_data.composition.CompositionTestDataStructuredJson) SoftAssertions(org.assertj.core.api.SoftAssertions) Composition(com.nedap.archie.rm.composition.Composition) OperationalTemplateTestData(org.ehrbase.test_data.operationaltemplate.OperationalTemplateTestData) ArchieRMInfoLookup(com.nedap.archie.rminfo.ArchieRMInfoLookup) IOException(java.io.IOException) StandardCharsets(java.nio.charset.StandardCharsets) JSONAssert(org.skyscreamer.jsonassert.JSONAssert) Test(org.junit.jupiter.api.Test) IOUtils(org.apache.commons.io.IOUtils) TestDataTemplateProvider(org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) JSONCompareMode(org.skyscreamer.jsonassert.JSONCompareMode) RMObjectValidator(com.nedap.archie.rmobjectvalidator.RMObjectValidator) Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) SoftAssertions(org.assertj.core.api.SoftAssertions) RMObjectValidator(com.nedap.archie.rmobjectvalidator.RMObjectValidator)

Example 3 with CompositionTestDataStructuredJson

use of org.ehrbase.test_data.composition.CompositionTestDataStructuredJson in project openEHR_SDK by ehrbase.

the class StructuredHelperTest method convert.

@Test
public void convert() throws IOException {
    CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.CORONA;
    CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.CORONA;
    String templateId = OperationalTemplateTestData.CORONA_ANAMNESE.getTemplateId();
    testStructuredToFlat(structuredJson, simSDTJson, templateId);
}
Also used : CompositionTestDataStructuredJson(org.ehrbase.test_data.composition.CompositionTestDataStructuredJson) CompositionTestDataSimSDTJson(org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson) Test(org.junit.Test)

Example 4 with CompositionTestDataStructuredJson

use of org.ehrbase.test_data.composition.CompositionTestDataStructuredJson in project openEHR_SDK by ehrbase.

the class StructuredHelperTest method convertRevert.

@Test
public void convertRevert() throws IOException {
    CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.CORONA;
    CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.CORONA;
    testFlatToStructured(structuredJson, simSDTJson);
}
Also used : CompositionTestDataStructuredJson(org.ehrbase.test_data.composition.CompositionTestDataStructuredJson) CompositionTestDataSimSDTJson(org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson) Test(org.junit.Test)

Example 5 with CompositionTestDataStructuredJson

use of org.ehrbase.test_data.composition.CompositionTestDataStructuredJson in project openEHR_SDK by ehrbase.

the class StructuredHelperTest method convertRevertMultiList.

@Test
public void convertRevertMultiList() throws IOException {
    CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.MULTI_LIST;
    CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.MULTI_LIST;
    testFlatToStructured(structuredJson, simSDTJson);
}
Also used : CompositionTestDataStructuredJson(org.ehrbase.test_data.composition.CompositionTestDataStructuredJson) CompositionTestDataSimSDTJson(org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson) Test(org.junit.Test)

Aggregations

CompositionTestDataStructuredJson (org.ehrbase.test_data.composition.CompositionTestDataStructuredJson)10 CompositionTestDataSimSDTJson (org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 IOException (java.io.IOException)2 StandardCharsets (java.nio.charset.StandardCharsets)2 IOUtils (org.apache.commons.io.IOUtils)2 SoftAssertions (org.assertj.core.api.SoftAssertions)2 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)2 TestDataTemplateProvider (org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider)2 OperationalTemplateTestData (org.ehrbase.test_data.operationaltemplate.OperationalTemplateTestData)2 JSONAssert (org.skyscreamer.jsonassert.JSONAssert)2 JSONCompareMode (org.skyscreamer.jsonassert.JSONCompareMode)2 Composition (com.nedap.archie.rm.composition.Composition)1 ArchieRMInfoLookup (com.nedap.archie.rminfo.ArchieRMInfoLookup)1 RMObjectValidator (com.nedap.archie.rmobjectvalidator.RMObjectValidator)1 List (java.util.List)1 FlatFormat (org.ehrbase.serialisation.flatencoding.FlatFormat)1 FlatJasonProvider (org.ehrbase.serialisation.flatencoding.FlatJasonProvider)1 FlatJsonMarshallerTest.compere (org.ehrbase.serialisation.flatencoding.std.marshal.FlatJsonMarshallerTest.compere)1