Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,36 @@ public void testMarshalXmlOutput() throws Exception {
assertTrue(xml.contains("urn:hl7-org:v2xml"));
}

@Test
public void testUnmarshalXmlFormatViaModelDefinition() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:unmarshalXmlModel");
mock.expectedMessageCount(1);

String body = createHL7AsString();
template.sendBody("direct:unmarshalXmlModel", body);

MockEndpoint.assertIsSatisfied(context);
Object rawBody = mock.getReceivedExchanges().get(0).getIn().getBody();
assertNotNull(rawBody);
assertInstanceOf(Document.class, rawBody);
Document doc = (Document) rawBody;
assertEquals("ORM_O01", doc.getDocumentElement().getLocalName());
}

@Test
public void testRoundTripViaModelDefinition() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:roundtripModel");
mock.expectedMessageCount(1);

String body = createHL7AsString();
template.sendBody("direct:roundtripModel", body);

MockEndpoint.assertIsSatisfied(context);
String edi = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
assertTrue(edi.contains("MSH|^~\\&|"));
assertTrue(edi.contains("ORM^O01"));
}

@Test
public void testRoundTripEdiToXmlToEdi() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:roundtrip");
Expand Down Expand Up @@ -139,6 +169,13 @@ protected RouteBuilder createRouteBuilder() {
final HL7DataFormat hl7Default = new HL7DataFormat();
hl7Default.setValidate(false);

final org.apache.camel.model.dataformat.HL7DataFormat hl7XmlDef
= new org.apache.camel.model.dataformat.HL7DataFormat.Builder()
.targetFormat("XML").validate(false).end();
final org.apache.camel.model.dataformat.HL7DataFormat hl7DefaultDef
= new org.apache.camel.model.dataformat.HL7DataFormat.Builder()
.validate(false).end();

return new RouteBuilder() {
public void configure() {
from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
Expand All @@ -147,6 +184,9 @@ public void configure() {
from("direct:marshalFromDoc").marshal(hl7Default).to("mock:marshalFromDoc");
from("direct:marshalXmlOutput").marshal(hl7Xml).to("mock:marshalXmlOutput");
from("direct:roundtrip").unmarshal(hl7Xml).marshal(hl7Default).to("mock:roundtrip");

from("direct:unmarshalXmlModel").unmarshal(hl7XmlDef).to("mock:unmarshalXmlModel");
from("direct:roundtripModel").unmarshal(hl7XmlDef).marshal(hl7DefaultDef).to("mock:roundtripModel");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public HL7DataFormatReifier(CamelContext camelContext, DataFormatDefinition defi
protected void prepareDataFormatConfig(Map<String, Object> properties) {
properties.put("parser", asRef(definition.getParser()));
properties.put("validate", definition.getValidate());
properties.put("targetFormat", definition.getTargetFormat());
}

}