Skip to content

Commit

Permalink
Add tests for GreekPhilosopher provider for el_GR locale
Browse files Browse the repository at this point in the history
  • Loading branch information
gvrettos committed Oct 27, 2024
1 parent 8171a5f commit 7c0bb4a
Showing 1 changed file with 40 additions and 0 deletions.
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 ,.']+$");
}

@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);
}
}

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

0 comments on commit 7c0bb4a

Please sign in to comment.