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

University name fails for german locale #148

Closed
PascalSchumacher opened this issue Oct 30, 2016 · 14 comments
Closed

University name fails for german locale #148

PascalSchumacher opened this issue Oct 30, 2016 · 14 comments

Comments

@PascalSchumacher
Copy link
Contributor

PascalSchumacher commented Oct 30, 2016

new Faker(Locale.GERMAN).university().name(); fails with:

java.lang.RuntimeException: Can't find top level faker object named City.
    at com.github.javafaker.service.FakeValuesService.resolveFakerObjectAndMethod(FakeValuesService.java:456)
    at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:407)
    at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:362)
    at com.github.javafaker.service.FakeValuesService.resolve(FakeValuesService.java:319)
    at com.github.javafaker.University.name(University.java:11)

I believe this is a general problem.

In f574317 the resolution of variables in the yml files was changed, e.g. "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}" was replaced by "#{area_code}-#{exchange_code}-#{subscriber_number}", but this change was only done in en-US.yml.

In my opinion this change should be reverted, because it means that java-faker can no longer use the yml files from faker.

@trevershick
Copy link
Contributor

trevershick commented Oct 30, 2016

#city doesn't appear to be a correct expression. Did this work prior to the change? I'll take a look at this. I think reverting the change is premature considering it fixes some other issues. By reverting you might be fixing this university issue but you'd be breaking a number of others.

@trevershick
Copy link
Contributor

Shouldn't it be #Address.city?

@PascalSchumacher
Copy link
Contributor Author

Sorry, you are right this, in this case it is a bug in de.yml, it should be Address.city.

But there are other issues, e.g.:

new Faker(new Locale("ru")).address().streetAddress(); fails with

java.lang.RuntimeException: Can't find method on Address called streettitle.
    at com.github.javafaker.service.FakeValuesService.resolveFakerObjectAndMethod(FakeValuesService.java:463)
    at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:407)
    at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:362)
    at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:367)
    at com.github.javafaker.service.FakeValuesService.resolve(FakeValuesService.java:319)
    at com.github.javafaker.Address.streetAddress(Address.java:19)

and in this case ru.yml seems valid.

@trevershick
Copy link
Contributor

Ru.yml is referencing street-title but that doesn't exist. Street-name does. I think the assumption that the faker Yml files is correct is a flawed assumption.

@trevershick
Copy link
Contributor

I'm stepping out for a bit but I will help when I get back. I'll run your branch and see what the errors are.

@PascalSchumacher
Copy link
Contributor Author

PascalSchumacher added a commit to PascalSchumacher/java-faker that referenced this issue Oct 30, 2016
thanks to Trever Shick for the solution
@trevershick
Copy link
Contributor

Do we know if #{Address.street_title} would have worked with the code prior to the f574317 change? It's taking advantage of the dynamic methods in ruby because street_title is not defined on the Address object.

I'll take a look at this issue in a little bit. I still don't think it warrants a revert of the change.

@PascalSchumacher
Copy link
Contributor Author

Thanks for looking into this. :)

new Faker(new Locale("ru")).address().streetAddress(); works when I use java-faker 0.10 (which uses the same ru.yml file).

@trevershick
Copy link
Contributor

I'm going to fix this, but new Faker(new Locale("ru")).address().streetAddress(); doesn't actually work. I ran it in a loop with 0.10 and the result is below. Regardless, i'm still going to fix it.

O'Hara проспект, 375
Cruickshank проспект, 966
Vita площадь, 737
Eloisa пл., 938
Maggie площадь, 174
Tyra проспект, 763
Arnold ул., 555
Bergnaum пр., 961
Cassie площадь, 834
Kassandra проспект, 882
Collins площадь, 594
Reinger улица, 967
Celia площадь, 417
Gutkowski пл., 057
Elias пр., 572
Jaydon пр., 041
Bogisich площадь, 855
Misael пл., 760
Whitney ул., 667
Fisher пл., 528
Shaina площадь, 524
Torey ул., 287
Schultz пл., 925
Gusikowski проспект, 122
Cheyanne ул., 471
Scotty улица, 414
Mariam проспект, 995
Brown пр., 983
Medhurst проспект, 608
Elnora улица, 055
Nitzsche пл., 837
Daniel проспект, 174
Brianne улица, 483
Davon проспект, 700
Schumm проспект, 230
Elda ул., 422
Walsh проспект, 868
Madalyn площадь, 423
Josie проспект, 515
Molly улица, 201
Darryl улица, 866
Vilma пр., 983
Thora проспект, 192
Joannie проспект, 912
Prosacco улица, 259
Anderson проспект, 712
Nitzsche пл., 680
Ferry улица, 798
Romaguera площадь, 793
O'Keefe пл., 309
Glover пл., 903
King пр., 976
Cremin ул., 053
Alexane пр., 794
Ryan площадь, 819
Eugenia улица, 940
Kertzmann улица, 142
Arnulfo улица, 576
Gaylord ул., 843
Cynthia пр., 306
Nitzsche ул., 462
Weissnat улица, 870
Runte проспект, 738
Boehm пл., 126
Della пр., 842
Wilfrid пл., 997
Bernita ул., 305
Lexie пр., 273
Quitzon пр., 229
Dicki пл., 914
Laney пр., 138
Harley площадь, 790
Wisoky улица, 570
Devonte улица, 578
Frederic улица, 814
Joe пл., 018
Taurean ул., 640
Isidro пл., 483
Crooks пр., 867
Stracke пл., 348
Hoyt улица, 760
Deontae пл., 833
Thompson пл., 227
Fausto ул., 170
Candido площадь, 879
Shanel ул., 651
Corkery проспект, 207
Blick площадь, 902
Kihn пл., 464
Paul пр., 882
Ruthe улица, 155
Monty проспект, 328
Smitham улица, 140
Ritchie площадь, 797
Lonnie ул., 832
Schumm пр., 142
Felipa пл., 237
Julianne проспект, 881
Brigitte проспект, 512
Anya пл., 453

@trevershick
Copy link
Contributor

@PascalSchumacher do you have a branch you're working on for this?

@PascalSchumacher
Copy link
Contributor Author

PascalSchumacher commented Oct 30, 2016

@PascalSchumacher do you have a branch you're working on for this?

@trevershick Not sure what you mean?

I did not do any work on this beyond #150

trevershick pushed a commit to trevershick/java-faker that referenced this issue Oct 30, 2016
Addresses DiUS#148

If the yml contains an object style reference like Address.street_title which doesn't
resolve to a method name on Address, then try 'address.street_title' as a last ditch effort
which is probably how it should be encoded in the yml anyhow.
@trevershick
Copy link
Contributor

@PascalSchumacher I created a PR on your branch.

PascalSchumacher pushed a commit to PascalSchumacher/java-faker that referenced this issue Oct 30, 2016
Addresses DiUS#148

If the yml contains an object style reference like Address.street_title which doesn't
resolve to a method name on Address, then try 'address.street_title' as a last ditch effort
which is probably how it should be encoded in the yml anyhow.
@PascalSchumacher
Copy link
Contributor Author

Thanks a lot. 👍 :)

I have added the commit to #150.

I have also created pull requests to https://github.com/stympy/faker for the changes to yml files.

PascalSchumacher pushed a commit to PascalSchumacher/java-faker that referenced this issue Oct 30, 2016
Addresses DiUS#148

If the yml contains an object style reference like Address.street_title which doesn't
resolve to a method name on Address, then try 'address.street_title' as a last ditch effort
which is probably how it should be encoded in the yml anyhow.
PascalSchumacher pushed a commit to PascalSchumacher/java-faker that referenced this issue Oct 30, 2016
Addresses DiUS#148

If the yml contains an object style reference like Address.street_title which doesn't
resolve to a method name on Address, then try 'address.street_title' as a last ditch effort
which is probably how it should be encoded in the yml anyhow.
@trevershick
Copy link
Contributor

As code was merged to master for this issue, I think it can be closed now.

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

No branches or pull requests

2 participants