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

Add Faker class constructor with FakeValuesService as argument #402

Open
kitherill opened this issue Jul 11, 2019 · 5 comments
Open

Add Faker class constructor with FakeValuesService as argument #402

kitherill opened this issue Jul 11, 2019 · 5 comments

Comments

@kitherill
Copy link

For my current task I need both Faker class and 'lower level' FakeValuesService (in order to access values nation.yml). FakeValueService initialised in Faker class is package-visible, so I have to create another instance of FakeValueService, while ideally I would want to pass predefined FakeValueService instance to Faker so that it is reused.

@codingricky
Copy link
Contributor

Sorry I don't quite follow what you're trying to do, could you please supply some code to illustrate your point?

@kitherill
Copy link
Author

kitherill commented Jul 19, 2019

@codingricky

// E.g. I need to fake name and language fields
String language;
String name;

// 1. In order to get language I need to get random value from nation.yml:
FakeValuesService fakeValuesService = new FakeValuesService(Locale.US, new RandomService()); // First FakeValueService initialisation
language = fakeValuesService.fetchString("nation.language");

// 2. In order to get name I want to utilise Faker 'facade'
Faker faker = new Faker(); // Here Faker constructor will initialise another instance of FakeValueService whilst it could allow passing FVS instance we already have initialised, e.g. like: new Faker(fakeValueService)
name = faker.name().firstName();

@codingricky
Copy link
Contributor

@kitherill can't you just create a wrapper class like Nation and use that to get access to values in nation.yml? You could create a PR and submit it

@egoetschalckx
Copy link
Contributor

I've added a branch for this feature called add-nation and opened a PR (#416)

@Tavo5691
Copy link
Contributor

Maybe we should close this issue, @egoetschalckx 's PR has already been merged.

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

4 participants