Skip to content

Commit

Permalink
Fix Locale and TimeZone in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Jul 26, 2024
1 parent 04a8c67 commit 58f5584
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.DefaultTimeZone;
import org.junitpioneer.jupiter.ReadsDefaultTimeZone;

class DateTimeUtilsTest {
@Test
Expand Down Expand Up @@ -62,6 +63,7 @@ void testGetDicomTime() {
@Test
@DisplayName("Convert Date to LocalDate")
@DefaultTimeZone("UTC")
@ReadsDefaultTimeZone
void testGetDateToLocalDate() {
assertNull(DateTimeUtils.toLocalDate(null));

Expand All @@ -78,6 +80,7 @@ void testGetDateToLocalDate() {
@Test
@DisplayName("Convert Date to LocalTime")
@DefaultTimeZone("UTC")
@ReadsDefaultTimeZone
void testGetDateToLocalTime() {
assertNull(DateTimeUtils.toLocalTime(null));

Expand All @@ -94,6 +97,7 @@ void testGetDateToLocalTime() {
@Test
@DisplayName("Convert date to LocalDateTime")
@DefaultTimeZone("UTC")
@ReadsDefaultTimeZone
void testGetDateToLocalDateTime() {
assertNull(DateTimeUtils.toLocalDateTime(null));

Expand All @@ -110,6 +114,7 @@ void testGetDateToLocalDateTime() {
@Test
@DisplayName("Get DateTime")
@DefaultTimeZone("UTC")
@ReadsDefaultTimeZone
void testGetDateTime() {
assertNull(DateTimeUtils.dateTime((LocalDate) null, null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.DefaultLocale;
import org.junitpioneer.jupiter.DefaultTimeZone;
import org.junitpioneer.jupiter.ReadsDefaultLocale;
import org.junitpioneer.jupiter.ReadsDefaultTimeZone;

class DicomUtilsTest {

Expand Down Expand Up @@ -145,6 +147,7 @@ void testIsNative() {
@Test
@DisplayName("Format text with different values and formats")
@DefaultLocale(language = "en", country = "US")
@ReadsDefaultLocale
void testGetFormattedText() {
assertEquals("Value", DicomUtils.getFormattedText("Value", "Format"));
assertEquals("", DicomUtils.getFormattedText(null, "foo"));
Expand Down Expand Up @@ -196,6 +199,7 @@ void shouldFormatNonStringValue() {
@Test
@DisplayName("Format value with decimal and pattern")
@DefaultLocale(language = "en", country = "US")
@ReadsDefaultLocale
void shouldFormatValueWithDecimalAndPattern() {
String result = DicomUtils.formatValue("1.2345", true, "$V:f$0.00$");
assertEquals("1.23", result);
Expand Down Expand Up @@ -246,6 +250,7 @@ void testGetStringArrayFromDicomElement() {
@Test
@DisplayName("Get Date from Dicom Element")
@DefaultTimeZone("Europe/Paris")
@ReadsDefaultTimeZone
void testGetDateFromDicomElement() {
TimeZone timeZone = TimeZone.getDefault();
Attributes attributes = new Attributes();
Expand All @@ -270,6 +275,7 @@ void testGetDateFromDicomElement() {
@Test
@DisplayName("Get date array from Dicom Element with default value")
@DefaultTimeZone("Europe/Paris")
@ReadsDefaultTimeZone
void testGetDatesFromDicomElement() {
TimeZone timeZone = TimeZone.getDefault();
Attributes dicom = new Attributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Objects;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.DefaultLocale;
import org.junitpioneer.jupiter.ReadsDefaultLocale;
import org.weasis.dicom.ref.AnatomicBuilder.Category;

class AnatomicBuilderTest {
Expand All @@ -39,6 +40,7 @@ void getBodyPartsFromPredicate_returnsFilteredBodyParts() {

@Test
@DefaultLocale(language = "fr", country = "CH")
@ReadsDefaultLocale
void getBodyPartFromCode() {
assertEquals(
BodyPart.values()[0], BodyPart.getBodyPartFromCode(BodyPart.values()[0].getCodeValue()));
Expand All @@ -57,6 +59,7 @@ void getBodyPartFromCode() {

@Test
@DefaultLocale(language = "fr", country = "CH")
@ReadsDefaultLocale
void getBodyPartFromLegacyCode() {
assertEquals(
BodyPart.values()[0],
Expand Down Expand Up @@ -93,6 +96,7 @@ void getBodyPartFromCodeMeaning() {

@Test
@DefaultLocale(language = "fr", country = "CH")
@ReadsDefaultLocale
void getAnatomicModifierFromCode() {
assertEquals(
AnatomicModifier.values()[0],
Expand All @@ -109,6 +113,7 @@ void getAnatomicModifierFromCode() {

@Test
@DefaultLocale(language = "fr", country = "CH")
@ReadsDefaultLocale
void getSurfacePartFromCode() {
assertEquals(
SurfacePart.values()[0],
Expand Down Expand Up @@ -148,6 +153,7 @@ void getCodingScheme() {

@Test
@DefaultLocale(language = "fr", country = "CH")
@ReadsDefaultLocale
void category() {
assertEquals("Sites anatomiques dermatologiques", Category.SURFACE.toString());

Expand Down

0 comments on commit 58f5584

Please sign in to comment.