use of org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider in project openEHR_SDK by ehrbase.
the class DBEncodeRoundTripTest method testAlternativeEventsRoundTrip.
@Test
@Ignore
public void testAlternativeEventsRoundTrip() throws IOException {
String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/alternative_events_reduced_flat.json")));
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, "AlternativeEvents");
Composition composition = flatJson.unmarshal(value);
assertThat(composition).isNotNull();
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
assertNotNull(converted);
Composition actual = new CanonicalJson().unmarshal(converted, Composition.class);
String actualFlat = flatJson.marshal(actual);
assertNotNull(actualFlat);
}
use of org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider in project openEHR_SDK by ehrbase.
the class StructuredHelperTest method testStructuredToFlat.
private void testStructuredToFlat(CompositionTestDataStructuredJson structuredJson, CompositionTestDataSimSDTJson simSDTJson, String templateId) throws IOException {
String flat = IOUtils.toString(structuredJson.getStream(), StandardCharsets.UTF_8);
String actual = StructuredHelper.convertStructuredToFlat(flat);
String expected = IOUtils.toString(simSDTJson.getStream(), StandardCharsets.UTF_8);
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, templateId);
List<String> errors = compere(flatJson.marshal(flatJson.unmarshal(actual)), expected);
SoftAssertions softAssertions = new SoftAssertions();
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).containsExactlyInAnyOrder();
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).containsExactlyInAnyOrder();
softAssertions.assertAll();
}
use of org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider in project openEHR_SDK by ehrbase.
the class DBEncodeRoundTripTest method testCountRoundTrip.
@Test
@Ignore
public void testCountRoundTrip() throws IOException {
String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/test_all_type_count_flat.json")));
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, "test_all_types.en.v1");
Composition composition = flatJson.unmarshal(value);
assertThat(composition).isNotNull();
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
assertNotNull(converted);
Composition actual = new CanonicalJson().unmarshal(converted, Composition.class);
String actualFlat = flatJson.marshal(actual);
assertNotNull(actualFlat);
}
use of org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider in project openEHR_SDK by ehrbase.
the class DBEncodeRoundTripTest method testMathFunctionRoundTrip.
@Test
@Ignore
public void testMathFunctionRoundTrip() throws IOException {
String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/corona_math_function_flat.json")));
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, "Corona_Anamnese");
Composition composition = flatJson.unmarshal(value);
assertThat(composition).isNotNull();
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
assertNotNull(converted);
Composition actual = new CanonicalJson().unmarshal(converted, Composition.class);
String actualFlat = flatJson.marshal(actual);
assertNotNull(actualFlat);
}
use of org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider in project openEHR_SDK by ehrbase.
the class DBEncodeRoundTripTest method checkTestCase.
public void checkTestCase(TestCase testCase, SoftAssertions softly) throws IOException {
String value = IOUtils.toString(testCase.simSDTJson.getStream(), UTF_8);
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, testCase.templateId);
Composition composition = flatJson.unmarshal(value);
assertThat(composition).isNotNull();
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
assertNotNull(converted);
Composition actual = new CanonicalJson().unmarshal(converted, Composition.class);
String actualFlat = flatJson.marshal(actual);
List<String> errors = compere(actualFlat, value);
softly.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).as("Test Case %s", testCase.id).containsExactlyInAnyOrder(testCase.missing);
String[] extra = { "Extra path: test_all_types/test_all_types:0/identifier, value: 55175056", "Extra path: test_all_types/test_all_types:0/proportion_any|type, value: 1.0" };
softly.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).as("Test Case %s", testCase.id).containsExactlyInAnyOrder(testCase.extra);
}
Aggregations