use of com.nedap.archie.rmobjectvalidator.RMObjectValidator 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);
}
use of com.nedap.archie.rmobjectvalidator.RMObjectValidator in project openEHR_SDK by ehrbase.
the class FlatJsonTest method check.
private void check(String templateId, CompositionTestDataSimSDTJson testData, String[] expectedMissing, String[] expectedExtra) throws IOException {
RMDataFormat cut = new FlatJasonProvider(templateProvider).buildFlatJson(FlatFormat.SIM_SDT, 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);
List<String> errors = compere(actual, expected);
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).containsExactlyInAnyOrder(expectedMissing);
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).containsExactlyInAnyOrder(expectedExtra);
softAssertions.assertAll();
}
use of com.nedap.archie.rmobjectvalidator.RMObjectValidator in project openEHR_SDK by ehrbase.
the class FlatJsonTest method roundTripRaw.
@Test
public void roundTripRaw() throws IOException {
CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.CORONA_WITH_RAW;
String templateId = "Corona_Anamnese";
RMDataFormat cut = new FlatJasonProvider(templateProvider).buildFlatJson(FlatFormat.SIM_SDT, 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(CompositionTestDataSimSDTJson.CORONA.getStream(), StandardCharsets.UTF_8);
List<String> errors = compere(actual, expected);
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).containsExactlyInAnyOrder();
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).containsExactlyInAnyOrder();
softAssertions.assertAll();
}
use of com.nedap.archie.rmobjectvalidator.RMObjectValidator in project openEHR_SDK by ehrbase.
the class FlatJsonTest method roundTripFeederAuditRaw.
@Test
public void roundTripFeederAuditRaw() throws IOException {
CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.CORONA_WITH_FEEDER_AUDIT_RAW;
String templateId = "Corona_Anamnese";
RMDataFormat cut = new FlatJasonProvider(templateProvider).buildFlatJson(FlatFormat.SIM_SDT, 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(CompositionTestDataSimSDTJson.CORONA_WITH_FEEDER_AUDIT.getStream(), StandardCharsets.UTF_8);
List<String> errors = compere(actual, expected);
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).containsExactlyInAnyOrder();
softAssertions.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).containsExactlyInAnyOrder();
softAssertions.assertAll();
}
Aggregations