fix issues parsing test maps
This commit is contained in:
parent
95813d9004
commit
3338cfbe39
|
@ -343,8 +343,8 @@ public class StructureMapUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderRule(StringBuilder b, StructureMapGroupRuleComponent r, int indent) {
|
private static void renderRule(StringBuilder b, StructureMapGroupRuleComponent r, int indent) {
|
||||||
if (r.getDocumentation() != null) {
|
if (r.hasFormatCommentPre()) {
|
||||||
renderMultilineDoco(b, r.getDocumentation(), indent);
|
renderMultilineDoco(b, r.getFormatCommentsPre(), indent);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < indent; i++)
|
for (int i = 0; i < indent; i++)
|
||||||
b.append(' ');
|
b.append(' ');
|
||||||
|
@ -612,6 +612,16 @@ public class StructureMapUtilities {
|
||||||
b.append("\r\n");
|
b.append("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void renderMultilineDoco(StringBuilder b, List<String> doco, int indent) {
|
||||||
|
if (doco == null || doco.isEmpty())
|
||||||
|
return;
|
||||||
|
for (String line : doco) {
|
||||||
|
for (int i = 0; i < indent; i++)
|
||||||
|
b.append(' ');
|
||||||
|
renderDoco(b, line);
|
||||||
|
b.append("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ITransformerServices getServices() {
|
public ITransformerServices getServices() {
|
||||||
return services;
|
return services;
|
||||||
|
@ -789,9 +799,20 @@ public class StructureMapUtilities {
|
||||||
st.setAlias(lexer.take());
|
st.setAlias(lexer.take());
|
||||||
}
|
}
|
||||||
lexer.token("as");
|
lexer.token("as");
|
||||||
st.setMode(StructureMapModelMode.fromCode(lexer.take()));
|
String doco;
|
||||||
lexer.skipToken(";");
|
if (lexer.getCurrent().equals("source")) {
|
||||||
st.setDocumentation(lexer.getAllComments());
|
st.setMode(StructureMapModelMode.SOURCE);
|
||||||
|
doco = lexer.tokenWithTrailingComment("source");
|
||||||
|
} else if (lexer.getCurrent().equals("target")) {
|
||||||
|
st.setMode(StructureMapModelMode.TARGET);
|
||||||
|
doco = lexer.tokenWithTrailingComment("target");
|
||||||
|
} else {
|
||||||
|
throw lexer.error("Found '"+lexer.getCurrent()+"' expecting 'source' or 'target'");
|
||||||
|
}
|
||||||
|
if (lexer.hasToken(";")) {
|
||||||
|
doco = lexer.tokenWithTrailingComment(";");
|
||||||
|
}
|
||||||
|
st.setDocumentation(doco);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,8 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
||||||
Assertions.assertEquals("http://hl7.org/fhir/StructureDefinition/Basic", structureMap.getStructure().get(1).getUrl());
|
Assertions.assertEquals("http://hl7.org/fhir/StructureDefinition/Basic", structureMap.getStructure().get(1).getUrl());
|
||||||
Assertions.assertEquals("Target Documentation", structureMap.getStructure().get(1).getDocumentation());
|
Assertions.assertEquals("Target Documentation", structureMap.getStructure().get(1).getDocumentation());
|
||||||
Assertions.assertEquals("Groups\r\nrule for patient group", structureMap.getGroup().get(0).getDocumentation());
|
Assertions.assertEquals("Groups\r\nrule for patient group", structureMap.getGroup().get(0).getDocumentation());
|
||||||
Assertions.assertEquals("Comment to rule", structureMap.getGroup().get(0).getRule().get(0).getDocumentation());
|
Assertions.assertEquals("Comment to rule", structureMap.getGroup().get(0).getRule().get(0).getFormatCommentsPre().get(0));
|
||||||
Assertions.assertEquals("Copy identifier short syntax", structureMap.getGroup().get(0).getRule().get(1).getDocumentation());
|
Assertions.assertEquals("Copy identifier short syntax", structureMap.getGroup().get(0).getRule().get(1).getFormatCommentsPre().get(0));
|
||||||
|
|
||||||
StructureMapGroupRuleTargetComponent target = structureMap.getGroup().get(0).getRule().get(2).getTarget().get(1);
|
StructureMapGroupRuleTargetComponent target = structureMap.getGroup().get(0).getRule().get(2).getTarget().get(1);
|
||||||
Assertions.assertEquals("'urn:uuid:' + r.lower()", target.getParameter().get(0).toString());
|
Assertions.assertEquals("'urn:uuid:' + r.lower()", target.getParameter().get(0).toString());
|
||||||
|
@ -80,14 +80,12 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
||||||
public void testSyntax() throws IOException, FHIRException {
|
public void testSyntax() throws IOException, FHIRException {
|
||||||
StructureMapUtilities scu = new StructureMapUtilities(context, this);
|
StructureMapUtilities scu = new StructureMapUtilities(context, this);
|
||||||
String fileMap = TestingUtilities.loadTestResource("r5", "structure-mapping", "syntax.map");
|
String fileMap = TestingUtilities.loadTestResource("r5", "structure-mapping", "syntax.map");
|
||||||
System.out.println(fileMap);
|
|
||||||
|
|
||||||
StructureMap structureMap = scu.parse(fileMap, "Syntax");
|
StructureMap structureMap = scu.parse(fileMap, "Syntax");
|
||||||
assertSerializeDeserialize(structureMap);
|
assertSerializeDeserialize(structureMap);
|
||||||
|
|
||||||
String renderedMap = StructureMapUtilities.render(structureMap);
|
String renderedMap = StructureMapUtilities.render(structureMap);
|
||||||
StructureMap map = scu.parse(renderedMap, "Syntax");
|
StructureMap map = scu.parse(renderedMap, "Syntax");
|
||||||
System.out.println(map);
|
|
||||||
assertSerializeDeserialize(map);
|
assertSerializeDeserialize(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue