Import original test, and fix with renamed method (#1173)

This commit is contained in:
dotasek 2023-04-12 13:22:13 -04:00 committed by GitHub
parent 6a21d05ab8
commit 8ba4d75451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 8 deletions

View File

@ -69,18 +69,11 @@ import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException;
import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.SourceLocation;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.*;
@ -1047,7 +1040,7 @@ public class StructureMapUtilities {
lexer.token(")");
} else if (lexer.hasToken(".")) {
lexer.token(".");
source.setElement(lexer.take());
source.setElement(readAsStringOrProcessedConstant(lexer.take(), lexer));
}
if (lexer.hasToken(":")) {
// type and cardinality
@ -1090,6 +1083,12 @@ public class StructureMapUtilities {
}
}
private String readAsStringOrProcessedConstant(String s, FHIRLexer lexer) throws FHIRLexerException {
if (s.startsWith("\"") || s.startsWith("`"))
return lexer.processConstant(s);
else
return s;
}
private void parseTarget(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRException {
StructureMapGroupRuleTargetComponent target = rule.addTarget();

View File

@ -90,6 +90,25 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
assertSerializeDeserialize(map);
}
@Test
public void testSourceElementDelimiter() throws IOException, FHIRException {
StructureMapUtilities scu = new StructureMapUtilities(context, this);
String fileMap = "map \"http://github.com/FHIR/testSourceElementDelimiter\" = \"testSourceElementDelimiter\"\r\n"
+ "uses \"http://hl7.org/fhir/StructureDefinition/Patient\" alias Patient as source\r\n"
+ "uses \"http://hl7.org/fhir/StructureDefinition/Basic\" alias Basic as target\r\n"
+ "group Patient(source src : Patient, target tgt : Basic) {\r\n"
+ " src.identifier -> tgt.identifier;\r\n"
+ " src.\"-quote\" -> tgt.quote;\r\n"
+ " src.`-backtick` -> tgt.backtick;\r\n"
+ "}";
System.out.println(fileMap);
StructureMap structureMap = scu.parse(fileMap, "testSourceElementDelimiter");
Assertions.assertEquals("identifier", structureMap.getGroup().get(0).getRule().get(0).getSourceFirstRep().getElement());
Assertions.assertEquals("-quote", structureMap.getGroup().get(0).getRule().get(1).getSourceFirstRep().getElement());
Assertions.assertEquals("-backtick", structureMap.getGroup().get(0).getRule().get(2).getSourceFirstRep().getElement());
}
@Override
public void log(String message) {
}