From 99650f041baf25f3ea23f2090ba97405da15c6fc Mon Sep 17 00:00:00 2001 From: dotasek Date: Mon, 31 Jan 2022 10:45:28 -0500 Subject: [PATCH] Fix DateTime formatting in r4b tests --- .../r4b/renderers/utils/RenderingContext.java | 8 +++++++ .../r4b/test/NarrativeGenerationTests.java | 23 +++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/utils/RenderingContext.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/utils/RenderingContext.java index 546e723ea..8fdb7a794 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/utils/RenderingContext.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/utils/RenderingContext.java @@ -492,6 +492,10 @@ public class RenderingContext { this.dateTimeFormat = dateTimeFormat; } + public void setDateTimeFormatString(String dateTimeFormat) { + this.dateTimeFormat = DateTimeFormatter.ofPattern(dateTimeFormat); + } + /** * In the absence of a specified format, the renderers will default to * the FormatStyle.MEDIUM for the current locale. @@ -506,6 +510,10 @@ public class RenderingContext { this.dateFormat = dateFormat; } + public void setDateFormatString(String dateFormat) { + this.dateFormat = DateTimeFormatter.ofPattern(dateFormat); + } + public ResourceRendererMode getMode() { return mode; } diff --git a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java index daffccc0d..cc5cd706a 100644 --- a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java +++ b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java @@ -1,51 +1,38 @@ package org.hl7.fhir.r4b.test; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.time.ZoneId; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.SystemUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r4b.context.IWorkerContext; import org.hl7.fhir.r4b.elementmodel.Manager; import org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat; -import org.hl7.fhir.r4b.formats.IParser.OutputStyle; import org.hl7.fhir.r4b.formats.JsonParser; import org.hl7.fhir.r4b.formats.XmlParser; import org.hl7.fhir.r4b.model.Base; -import org.hl7.fhir.r4b.model.DomainResource; -import org.hl7.fhir.r4b.model.Questionnaire; import org.hl7.fhir.r4b.model.Resource; import org.hl7.fhir.r4b.renderers.RendererFactory; -import org.hl7.fhir.r4b.renderers.ResourceRenderer; + import org.hl7.fhir.r4b.renderers.utils.ElementWrappers; import org.hl7.fhir.r4b.renderers.utils.RenderingContext; import org.hl7.fhir.r4b.renderers.utils.RenderingContext.ITypeParser; -import org.hl7.fhir.r4b.renderers.utils.RenderingContext.QuestionnaireRendererMode; import org.hl7.fhir.r4b.renderers.utils.RenderingContext.ResourceRendererMode; -import org.hl7.fhir.r4b.test.NarrativeGenerationTests.TestTypeParser; import org.hl7.fhir.r4b.test.utils.TestingUtilities; + import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; import org.hl7.fhir.utilities.xhtml.XhtmlNode; -import org.hl7.fhir.utilities.xhtml.XhtmlParser; import org.hl7.fhir.utilities.xml.XMLUtil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -143,8 +130,10 @@ public class NarrativeGenerationTests { // getting timezones correct (well, at least consistent, so tests pass on any computer) rc.setLocale(new java.util.Locale("en", "AU")); rc.setTimeZoneId(ZoneId.of("Australia/Sydney")); - rc.setDateTimeFormat(null); - rc.setDateFormat(null); + + rc.setDateTimeFormatString("yyyy-MM-dd'T'HH:mm:ssZZZZZ"); + rc.setDateFormatString("yyyy-MM-dd"); + rc.setMode(test.technical ? ResourceRendererMode.TECHNICAL : ResourceRendererMode.END_USER);