Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

German Locale Support #85

Merged
merged 3 commits into from
Jun 19, 2017
Merged

Conversation

rweisleder
Copy link
Contributor

This adds locale support for german (de)

The DeNationalIdentityCardNumberProvider and DePassportNumberProvider generate only the simplest variants with a letter and eight digits. It would also possible to mix digits and characters (except A, E, I, O, U and B, D, Q, S) as long as they are eight-digit.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 93.037% when pulling 164fb92 on rweisleder:locale-de into 921d13c on Codearte:master.

Copy link
Contributor

@OlgaMaciaszek OlgaMaciaszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rweisleder Thank you for your PR. It looks good, but I have added comments about some minor changes that it would be good to implement.


@Override
public String get() {
return baseProducer.randomElement("L", "M", "N", "P", "R", "T", "V", "W", "X", "Y") + randomNumeric(8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be better to extract it to a collection/ array.

}

public boolean isValid(String vatIdentificationNumber) {
return vatIdentificationNumber.matches("^[0-9]{9}$");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract to constant.

}

public boolean isValid(String passportNumber) {
return passportNumber.matches("^[CFGHJK][0-9]{8}$");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract to constant.


@Override
public String get() {
return baseProducer.randomElement("C", "F", "G", "H", "J", "K") + randomNumeric(8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract to collection/ array.


where:
vatIdentificationNumber | valid
"999999999" | true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use Groovy String in place of GString?


def "should generate random street"() {
expect:
address.street == "Messelweg"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert to Groovy String in place of GString. Please do so for all the GStrings where a Groovy String could be used instead.


def "should return address in de locale format"() {
expect:
address.toString() == "Messelweg 176" + LINE_SEPARATOR + "15286 Schlitz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not take advantage of GString concatenation, like so: "Messelweg 176${LINE_SEPARATOR}15286 Schlitz" ?


where:
nationalIdentityCardNumber | valid
"T22000129" | true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert to Groovy Strings in place of GString.


where:
passportNumber | valid
"C22000129" | true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert to Groovy Strings in place of GStrings.
Please remove unnecessary empty lines in test methods.

- replaced unnecessary GString with String
- extracted constant patterns and collections
- removed unnecessary white lines in tests
one GString has been hiding...
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.09%) to 91.716% when pulling 68745fc on rweisleder:locale-de into 921d13c on Codearte:master.

@rweisleder
Copy link
Contributor Author

@OlgaMaciaszek thanks for your feedback. I updated my PR.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 93.047% when pulling 68745fc on rweisleder:locale-de into 921d13c on Codearte:master.

@OlgaMaciaszek OlgaMaciaszek merged commit f556147 into Devskiller:master Jun 19, 2017
@rweisleder rweisleder deleted the locale-de branch June 19, 2017 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants