diff --git a/src/test/java/net/datafaker/providers/base/BaseFakerTest.java b/src/test/java/net/datafaker/providers/base/BaseFakerTest.java index 4f4a16d85..618ab398a 100644 --- a/src/test/java/net/datafaker/providers/base/BaseFakerTest.java +++ b/src/test/java/net/datafaker/providers/base/BaseFakerTest.java @@ -22,7 +22,7 @@ public class BaseFakerTest { private static final Logger LOG = Logger.getLogger(BaseFakerTest.class.getCanonicalName()); - protected final T faker = getFaker(); + protected T faker = getFaker(); @BeforeEach @SuppressWarnings("EmptyTryBlock") @@ -38,6 +38,10 @@ protected T getFaker() { return (T) new BaseFaker(); } + protected void setFaker(T faker) { + this.faker = faker; + } + protected List getBaseList(String key) { return faker.fakeValuesService().fetchObject(key, faker.getContext()); } diff --git a/src/test/java/net/datafaker/providers/base/MeasurementTest.java b/src/test/java/net/datafaker/providers/base/MeasurementTest.java index 6c759c661..1d37db54f 100644 --- a/src/test/java/net/datafaker/providers/base/MeasurementTest.java +++ b/src/test/java/net/datafaker/providers/base/MeasurementTest.java @@ -1,7 +1,12 @@ package net.datafaker.providers.base; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; + import java.util.List; import java.util.Collection; +import java.util.Locale; class MeasurementTest extends BaseFakerTest { @@ -10,13 +15,39 @@ class MeasurementTest extends BaseFakerTest { @Override protected Collection providerListTest() { Measurement measurement = faker.measurement(); - return List.of(TestSpec.of(measurement::height, "measurement.height"), + return getProviderListTests(measurement); + } + + @Nested + class MeasurementInGreekTest extends BaseFakerTest { + + @BeforeAll + void setup() { + this.setFaker(new BaseFaker(new Locale("el", "GR"))); + } + + @AfterAll + void reset() { + this.setFaker(this.getFaker()); + } + + @Override + protected Collection providerListTest() { + Measurement measurement = faker.measurement(); + return getProviderListTests(measurement); + } + } + + private Collection getProviderListTests(Measurement measurement) { + return List.of( + TestSpec.of(measurement::height, "measurement.height"), TestSpec.of(measurement::length, "measurement.length"), TestSpec.of(measurement::volume, "measurement.volume"), TestSpec.of(measurement::weight, "measurement.weight"), TestSpec.of(measurement::metricLength, "measurement.metric_length"), TestSpec.of(measurement::metricHeight, "measurement.metric_height"), TestSpec.of(measurement::metricVolume, "measurement.metric_volume"), - TestSpec.of(measurement::metricWeight, "measurement.metric_weight")); + TestSpec.of(measurement::metricWeight, "measurement.metric_weight") + ); } }