Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ jobs:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven
- name: Validate formatting with Spotless
run: ./mvnw $mvn_options spotless:check
- name: Build with Maven
run: ./mvnw $mvn_options install -PnoGpg --file pom.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.6.0
uses: codecov/codecov-action@v5.0.2
if: ${{ matrix.java-version == env.jdk_for_downstream && matrix.runs-on == env.os_for_downstream}}
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<jbanking.version>4.2.0</jbanking.version>
<junit.version>5.11.3</junit.version>
<libphonenumber.version>8.13.49</libphonenumber.version>
<libphonenumber.version>8.13.50</libphonenumber.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
Expand Down Expand Up @@ -240,7 +240,14 @@
<version>${spotless-maven-plugin.version}</version>
<configuration>
<java>
<removeUnusedImports />
<includes>
<include>src/main/java/**/*.java</include>
<include>src/test/java/**/*.java</include>
</includes>
<removeUnusedImports/>
<toggleOffOn/>
<trimTrailingWhitespace/>
<endWithNewline/>
</java>
<yaml>
<includes>
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/net/datafaker/idnumbers/SwedenIdNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ public String getValidSsn(BaseProviders f) {
@Override
public PersonIdNumber generateValid(BaseProviders f, IdNumber.IdNumberRequest request) {
LocalDate birthday = birthday(f, request);
String end = f.numerify("###");
String end = generateEndPart(f);
String basePart = DATE_TIME_FORMATTER.format(birthday)
+ f.options().option(PLUS_MINUS)
+ end;
String idNumber = basePart + calculateChecksum(basePart);
return new PersonIdNumber(idNumber, birthday, gender(f, request));
}

public static String generateEndPart(BaseProviders f) {
return "%03d".formatted(f.number().numberBetween(1, 1000));
}

@Deprecated
public String getInvalidSsn(BaseProviders f) {
return generateInvalid(f);
Expand Down Expand Up @@ -78,6 +82,10 @@ public static boolean isValidSwedishSsn(String ssn) {
return false;
}

if (ssn.startsWith("000", 7)) {
return false;
}

int calculatedChecksum = calculateChecksum(ssn);
int checksum = Integer.parseInt(ssn.substring(10, 11));
return checksum == calculatedChecksum;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/datafaker/providers/base/Azure.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public String keyVault() {
public String logAnalytics() {
return "log-" + randHex();
}

public String springApps() {
return "sa-" + randHex();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/datafaker/providers/base/Educator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ protected Educator(BaseProviders faker) {
super(faker);
}

// TODO - move these all out to en.yml by default.
// TODO - move these all out to en.yml by default.
public String university() {
return resolve("educator.name")
+ " "
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/datafaker/providers/base/Finance.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public enum CreditCardType {
SOLO,
DANKORT,
FORBRUGSFORENINGEN,
LASER
LASER,
UNIONPAY
}

protected Finance(BaseProviders faker) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/net/datafaker/providers/base/Nigeria.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,3 @@ public String celebrities() {
return resolve(KEY + ".celebrities");
}
}



6 changes: 3 additions & 3 deletions src/main/java/net/datafaker/providers/base/Tire.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected Tire(BaseProviders faker) {
/**
* Returns a Tire Code, such as 205/60R16.
* Which is width in mm / aspect ratio (height to width percentage) R (radial) Rim diameter.
*
*
* @return a Tire Code String.
*/
public String code() {
Expand All @@ -25,7 +25,7 @@ public String code() {

/**
* Returns a Tire Code prefixed with the provided String.
*
*
* @return a Tire Code string prefixed with the provided String.
*/
public String code(String prefix) {
Expand All @@ -35,7 +35,7 @@ public String code(String prefix) {
/**
* Returns a Tire Code optionally prefixed with the default prefix (P for passenger vehicle).
* @param defaultPrefix if true the default prefix "P" will be included, otherwise it will not.
*
*
* @return a Tire Code string, such as P205/60R16.
*/
public String code(boolean defaultPrefix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ default HowIMetYourMother howIMetYourMother() {
default HowToTrainYourDragon howToTrainYourDragon() {
return getProvider(HowToTrainYourDragon.class, HowToTrainYourDragon::new);
}

default Joke joke() {
return getProvider(Joke.class, Joke::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* Futurama is an American animated science fiction sitcom created by Matt Groening for the Fox Broadcasting Company.
*
*
* @since 1.8.0
*/
public class Futurama extends AbstractProvider<EntertainmentProviders> {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/datafaker/providers/entertainment/Tron.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,3 @@ public enum Character {
}
}
}


7 changes: 7 additions & 0 deletions src/main/resources/en/dota2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ en:
- "Jakiro"
- "Juggernaut"
- "Keeper of the Light"
- "Kez"
- "Kunkka"
- "Legion Commander"
- "Leshrac"
Expand Down Expand Up @@ -428,6 +429,12 @@ en:
- "Stand aside or be trampled!"
- "It's a new age of magic!"
- "I am the keeper of the light!"
kez:
quote:
- "I see you over there!"
- "Pecked. To death."
- "Death from ground level!"
- "I am the duck's back."
legion_commander:
quote:
- "I've come to put an end to hope."
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/en/finance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ en:
- "/6706###########L/"
- "/6771###########L/"
- "/6709###########L/"
unionpay:
- "/62##-####-####-###L/"
vat_number:
AT: "ATU########"
AR: "AR###########"
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -723,3 +723,6 @@ pt-BR:
"Taiwaneses", "Tanzanianos", "Tailandeses", "Tibetanos", "Trinitinos", "Tobagonianos", "Tunisianos", "Turcos", "Tuvaluenses",
"Ugandenses", "Ucranianos", "Uruguaios", "Uzbeques", "Vanuatuenses", "Venezuelanos", "Vietnamitas", "Galeses", "Iemenitas",
"Zambianos", "Zimbabuanos"]

passport:
valid: "[A-Z]{2}[0-9]{6}"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void validSwedishSsn() {

@Test
void invalidSwedishSsn() {
assertThat(SwedenIdNumber.isValidSwedishSsn("020914-0003")).isFalse();
assertThat(SwedenIdNumber.isValidSwedishSsn("8112289873")).isFalse();
assertThat(SwedenIdNumber.isValidSwedishSsn("foo228-9873")).isFalse();
assertThat(SwedenIdNumber.isValidSwedishSsn("811228-9873")).isFalse();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/datafaker/providers/base/AzureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void testKeyVault() {
void testLogAnalytics() {
assertThat(faker.azure().logAnalytics()).matches("^log-[0-9a-f]{16}$");
}

@Test
void testSpringApps() {
assertThat(faker.azure().springApps()).matches("^sa-[0-9a-f]{16}$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class DcComicsTest extends BaseFakerTest<BaseFaker> {

@Override
protected Collection<TestSpec> providerListTest() {
protected Collection<TestSpec> providerListTest() {
DcComics dcComics = faker.dcComics();
return List.of(TestSpec.of(dcComics::hero, "dc_comics.hero"),
TestSpec.of(dcComics::heroine, "dc_comics.heroine"),
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/datafaker/providers/base/EmojiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EmojiTest extends BaseFakerTest<BaseFaker> {
@Override
protected Collection<TestSpec> providerListTest() {
Emoji emoji = faker.emoji();

return List.of(TestSpec.of(emoji::smiley, "emoji.smileys"),
TestSpec.of(emoji::cat, "emoji.cats"),
TestSpec.of(emoji::vehicle, "emoji.vehicles"));
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/net/datafaker/providers/base/FinanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ void discoverCard() {
assertThat(creditCard).startsWith("6").hasSize(16);
}

@RepeatedTest(100)
void unionpayCard() {
String creditCard = finance.creditCard(CreditCardType.UNIONPAY).replace("-", "");
assertThat(creditCard).startsWith("62").hasSize(16);
}

@RepeatedTest(100)
void usRoutingNumber() {
String rtn = finance.usRoutingNumber();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/net/datafaker/providers/base/PassportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,11 @@ void testValidFinland() {
.hasSize(9);
}

@RepeatedTest(10)
void testValidBrazil() {
assertThat(new BaseFaker(new Locale("pt", "BR")).passport().valid())
.hasSize(8)
.matches("[A-Z]{2}[0-9]{6}");
}

}
2 changes: 1 addition & 1 deletion src/test/java/net/datafaker/providers/base/SpaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class SpaceTest extends BaseFakerTest<BaseFaker> {

private static final String SPACE_REGEX = "(?:\\w+ ?){2,3}";

@Override
protected Collection<TestSpec> providerListTest() {
Space space = faker.space();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ protected Collection<TestSpec> providerListTest() {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ protected Collection<TestSpec> providerListTest() {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ protected Collection<TestSpec> providerListTest() {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ protected Collection<TestSpec> providerListTest() {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ protected Collection<TestSpec> providerListTest() {
);
}
}