From 8e5ad3a693b8d74fc38caf3b7c728c8a74deffa9 Mon Sep 17 00:00:00 2001 From: Hank Yang <61555885+Hankych@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:02:37 -0500 Subject: [PATCH] Fixed -locale parameter for validatorcli (#1002) * "Added Failing Tests" * Added Failing Tests * Failing Tests * Fixed locale param for validatorcli --- .../fhir/validation/cli/model/CliContext.java | 2 +- .../validation/cli/model/CliContextTests.java | 17 +++++++++++++++++ .../fhir/validation/cli/utils/ParamsTests.java | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/model/CliContextTests.java create mode 100644 org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/utils/ParamsTests.java diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java index 817ac0d39..cbaa0e19d 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java @@ -284,7 +284,7 @@ public class CliContext { } public CliContext setLocale(Locale locale) { - this.locale = locale.getDisplayLanguage(); + this.locale = locale.getLanguage(); return this; } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/model/CliContextTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/model/CliContextTests.java new file mode 100644 index 000000000..f8dc2fae7 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/model/CliContextTests.java @@ -0,0 +1,17 @@ +package org.hl7.fhir.validation.cli.model; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import java.util.Locale; +import static org.junit.Assert.assertEquals; + +public class CliContextTests { + @Test + @DisplayName("test locale set and get") + public void testSetAndGetLocale() { + CliContext cliContext = new CliContext(); + cliContext.setLocale(Locale.GERMAN); + assertEquals(Locale.GERMAN, cliContext.getLocale()); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/utils/ParamsTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/utils/ParamsTests.java new file mode 100644 index 000000000..c60c8537a --- /dev/null +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/cli/utils/ParamsTests.java @@ -0,0 +1,14 @@ +package org.hl7.fhir.validation.cli.utils; + +import org.hl7.fhir.validation.cli.model.CliContext; +import org.junit.jupiter.api.Test; +import java.util.Locale; +import static org.junit.Assert.assertEquals; + +public class ParamsTests { + @Test + void testLocale() throws Exception { + CliContext cliContext = Params.loadCliContext(new String[]{"-locale", "de"}); + assertEquals(Locale.GERMAN, cliContext.getLocale()); + } +} \ No newline at end of file