Skip to content

Commit

Permalink
Merge pull request #1410 from gvrettos/feature/measurement-el_GR
Browse files Browse the repository at this point in the history
Add greek translations for Measurement provider & other Greek tests
  • Loading branch information
kingthorin authored Oct 27, 2024
2 parents 0f09cee + 054a8b7 commit e90e297
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 11 deletions.
44 changes: 43 additions & 1 deletion src/main/resources/el-GR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ el-GR:
- "Δεν έχει σημασία τι σου συμβαίνει, αλλά πώς αντιδράς σε αυτό."
- "Το μυαλό δεν είναι δοχείο για να γεμίσει, αλλά φωτιά για να ανάψει."
- "Οι καλές συνήθειες που σχηματίζονται στη νεότητα κάνουν όλη τη διαφορά."

job:
field:
- "Μάρκετινγκ"
Expand Down Expand Up @@ -262,3 +261,46 @@ el-GR:
- "#{field} #{position}"
- "#{field} #{position}"
- "#{seniority} #{position}"
measurement:
height:
- "ίντσα"
- "πόδι"
length:
- "γιάρδα"
- "πόδι"
- "μίλι"
volume:
- "φλιτζάνι"
- "κουταλιά της σούπας"
- "κουταλάκι του γλυκού"
- "κουάρτ"
- "πίντα"
- "γαλόνι"
- "υγρή ουγγιά"
weight:
- "λίβρα"
- "ουγγιά"
- "τόνος"
metric_height:
- "εκατοστόμετρο"
- "μέτρο"
metric_length:
- "χιλιοστόμετρο"
- "εκατοστόμετρο"
- "δεκατόμετρο"
- "μέτρο"
- "δεκάμετρο"
- "εκατόμετρο"
- "χιλιόμετρο"
metric_volume:
- "χιλιοστόλιτρο"
- "λίτρο"
metric_weight:
- "χιλιοστόγραμμο"
- "εκατοστόγραμμο"
- "δεκατόγραμμο"
- "γραμμάριο"
- "δεκάγραμμο"
- "εκατόγραμμο"
- "κιλό"
- "μετρικός τόνος"
39 changes: 35 additions & 4 deletions src/test/java/net/datafaker/providers/base/AncientTest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
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 AncientTest extends BaseFakerTest<BaseFaker> {

private static Collection<TestSpec> getProviderListTests(Ancient ancient) {
return List.of(
TestSpec.of(ancient::god, "ancient.god"),
TestSpec.of(ancient::primordial, "ancient.primordial"),
TestSpec.of(ancient::titan, "ancient.titan"),
TestSpec.of(ancient::hero, "ancient.hero")
);
}

@Override
protected Collection<TestSpec> providerListTest() {
Ancient ancient = faker.ancient();
return List.of(TestSpec.of(ancient::god, "ancient.god"),
TestSpec.of(ancient::primordial, "ancient.primordial"),
TestSpec.of(ancient::titan, "ancient.titan"),
TestSpec.of(ancient::hero, "ancient.hero"));
return getProviderListTests(ancient);
}

@Nested
class AncientInGreekTest extends BaseFakerTest<BaseFaker> {

@BeforeAll
void setup() {
this.setFaker(new BaseFaker(new Locale("el", "GR")));
}

@AfterAll
void reset() {
this.setFaker(this.getFaker());
}

@Override
protected Collection<TestSpec> providerListTest() {
Ancient ancient = faker.ancient();
return getProviderListTests(ancient);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class BaseFakerTest<T extends BaseFaker> {

private static final Logger LOG = Logger.getLogger(BaseFakerTest.class.getCanonicalName());
protected final T faker = getFaker();
protected T faker = getFaker();

@BeforeEach
@SuppressWarnings("EmptyTryBlock")
Expand All @@ -38,6 +38,10 @@ protected T getFaker() {
return (T) new BaseFaker();
}

protected void setFaker(T faker) {
this.faker = faker;
}

protected List<String> getBaseList(String key) {
return faker.fakeValuesService().fetchObject(key, faker.getContext());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package net.datafaker.providers.base;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.RepeatedTest;

import java.util.Collection;
import java.util.List;
import java.util.Locale;

import static org.assertj.core.api.Assertions.assertThat;

class GreekPhilosopherTest extends BaseFakerTest<BaseFaker> {
Expand All @@ -15,4 +22,37 @@ void testName() {
void testQuote() {
assertThat(faker.greekPhilosopher().quote()).matches("^[a-zA-Z ,.']+$");
}

private static Collection<TestSpec> getProviderListTests(GreekPhilosopher greekPhilosopher) {
return List.of(
TestSpec.of(greekPhilosopher::name, "greek_philosophers.names"),
TestSpec.of(greekPhilosopher::quote, "greek_philosophers.quotes")
);
}

@Override
protected Collection<TestSpec> providerListTest() {
GreekPhilosopher greekPhilosopher = faker.greekPhilosopher();
return getProviderListTests(greekPhilosopher);
}

@Nested
class GreekPhilosopherInGreekTest extends BaseFakerTest<BaseFaker> {

@BeforeAll
void setup() {
this.setFaker(new BaseFaker(new Locale("el", "GR")));
}

@AfterAll
void reset() {
this.setFaker(this.getFaker());
}

@Override
protected Collection<TestSpec> providerListTest() {
GreekPhilosopher greekPhilosopher = faker.greekPhilosopher();
return getProviderListTests(greekPhilosopher);
}
}
}
28 changes: 28 additions & 0 deletions src/test/java/net/datafaker/providers/base/JobTest.java
Original file line number Diff line number Diff line change
@@ -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 JobTest extends BaseFakerTest<BaseFaker> {

Expand All @@ -13,4 +18,27 @@ protected Collection<TestSpec> providerListTest() {
TestSpec.of(job::position, "job.position"),
TestSpec.of(job::keySkills, "job.key_skills", "(?:[A-Za-z-]+ ?){1,3}"));
}

@Nested
class JobInGreekTest extends BaseFakerTest<BaseFaker> {

@BeforeAll
void setup() {
this.setFaker(new BaseFaker(new Locale("el", "GR")));
}

@AfterAll
void reset() {
this.setFaker(this.getFaker());
}

@Override
protected Collection<TestSpec> providerListTest() {
Job job = faker.job();
return List.of(TestSpec.of(job::field, "job.field"),
TestSpec.of(job::seniority, "job.seniority"),
TestSpec.of(job::position, "job.position"),
TestSpec.of(job::keySkills, "job.key_skills", "(?:\\p{L}+ ?){1,4}"));
}
}
}
41 changes: 36 additions & 5 deletions src/test/java/net/datafaker/providers/base/MeasurementTest.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,53 @@
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<BaseFaker> {

public static final String WORDS = "^[a-z ]+$";

@Override
protected Collection<TestSpec> providerListTest() {
Measurement measurement = faker.measurement();
return List.of(TestSpec.of(measurement::height, "measurement.height"),
private static Collection<TestSpec> 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")
);
}

@Override
protected Collection<TestSpec> providerListTest() {
Measurement measurement = faker.measurement();
return getProviderListTests(measurement);
}

@Nested
class MeasurementInGreekTest extends BaseFakerTest<BaseFaker> {

@BeforeAll
void setup() {
this.setFaker(new BaseFaker(new Locale("el", "GR")));
}

@AfterAll
void reset() {
this.setFaker(this.getFaker());
}

@Override
protected Collection<TestSpec> providerListTest() {
Measurement measurement = faker.measurement();
return getProviderListTests(measurement);
}
}
}

0 comments on commit e90e297

Please sign in to comment.