Fix timezone issue in PE tests

This commit is contained in:
Grahame Grieve 2023-09-27 09:06:04 +10:00
parent 24905a2c16
commit 79b45832e4
3 changed files with 15 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import org.hl7.fhir.utilities.validation.ValidationMessage;
public class ValidatedFragment { public class ValidatedFragment {
private String name; private String name;
private String elementPath;
private String extension; private String extension;
private Element element; private Element element;
private byte[] content; private byte[] content;
@ -50,5 +51,16 @@ public class ValidatedFragment {
public String getFilename() { public String getFilename() {
return name+"."+extension; return name+"."+extension;
} }
public String getElementPath() {
return elementPath;
}
public void setElementPath(String elementPath) {
this.elementPath = elementPath;
}
public String path() {
return elementPath == null ? name : elementPath;
}
} }

View File

@ -6,6 +6,7 @@ import java.io.FileOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
@ -48,6 +49,7 @@ public class GeneratedPEModelTest {
@Test @Test
public void testPEGenLoad() throws Exception { public void testPEGenLoad() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("UTC+1100"));
load(); load();
Observation obs = (Observation) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "profiles", "pe-instance.xml")); Observation obs = (Observation) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "profiles", "pe-instance.xml"));
TestProfile tp = TestProfile.fromSource(ctxt, obs); TestProfile tp = TestProfile.fromSource(ctxt, obs);

View File

@ -766,7 +766,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} }
for (ValidatedFragment ne : validatedContent) { for (ValidatedFragment ne : validatedContent) {
if (ne.getElement() != null) { if (ne.getElement() != null) {
validate(appContext, ne.getErrors(), validatedContent.size() > 1 ? ne.getName() : null, ne.getElement(), profiles); validate(appContext, ne.getErrors(), validatedContent.size() > 1 ? ne.path() : null, ne.getElement(), profiles);
} }
errors.addAll(ne.getErrors()); errors.addAll(ne.getErrors());
} }