Comments (9)
See also:
from datafaker.
that is cool! I don't knew about this. But my idea is litle different, this annotation is used in runtime, my project use annotation processor to generate bot class, you don't need annotate model class and "dirty" it, annotation processor will generate a class to build instances and allow you configure providers for each class properties, create extensions for generate your bot and store it in a database ( for exemple).
I thing many things to make project very extendable and flexible, but thank you for space to show it :)
from datafaker.
That's great @juniorjrjl , thank you for sharing! What's your intention with JFaker? Do you want to keep it a separate project and use Datafaker as a potential data provider? Or would you consider a tighter integration between the 2? I think we would be open to any kind of approach, and if we should make changes to make JFaker + Datafaker easier, let us know, happy to discuss!
from datafaker.
Thanks for sharing this
But my idea is litle different, this annotation is used in runtime, my project use annotation processor to generate bot class, you don't need annotate model class and "dirty" it, annotation processor will generate a class to build instances and allow you configure providers for each class properties, create extensions for generate your bot and store it in a database ( for exemple).
we were thinking about similar approach however we faced a couple of limitations
- How to generate an object with different locale
- How to generate an object with different seed
- How to generate several different objects (one with Japanese locale and seed 1, another with Japanese locale and seed 10, the third one with French locale and seed 10 and the fourth one with French locale and seed 1000)?
How do you solve this with such configuration?
from datafaker.
@bodiam I think about integration is good, I believe this suggest have a great potential and could be very interesting to help a create tests were developer write less code to generate object instances and care more about tests's scenary.
from datafaker.
@snuyanzin about your questions
1 I my actual code I didn`t think about, but I think it's possible make some changes
// imports omitidos
public class UserEntityBot extends AbstractBot<UserEntity> {
private MyCustomFaker faker = new MyCustomFaker();
private Supplier<Long> id = () -> (long) faker.number().positive();
private Supplier<String> name = () -> faker.lorem().word();
public BookModelBot withId(final Supplier<Long> id) {
this.id = id;
return this;
}
public BookModelBot withName(final Supplier<String> name) {
this.name = name;
return this;
}
public BookModel build() {
var userEntity = new br.com.sample.UserEntity();
userEntity.setId(id.get());
userEntity.setName(name.get());
return userEntity;
}
}
this code is a class example generated by my code, for solve this problem we could change a moment where faker instance is created (instantiate in build method for example) and pass a locale by param
2 - In this code is possible, all generated bots extend a class AbstractBot, but is possible configure bots to use another class, you need create a another class inherits AbstractBot and put in this class a method who returns a bot instance after save it on database, I create a wiki in this repository explain some resources https://github.com/juniorjrjl/jfaker/wiki (sorry if my english is bad in this wiki) and in this topic have a solution of this question https://github.com/juniorjrjl/jfaker/wiki/9---Customize-your-Bots
3 - For this we need think about faker object is instantiate ( like I explain in answer 1)
this code is a first version, We can think about improve it and include more features.
from datafaker.
thanks for explanation
i was asking since all 3 cases are now covered by datafaker existing functionality and locale/seed should be just specified via annotation or method call (both are possible)
no need for other changes
from datafaker.
Is any action required for this ticket?
from datafaker.
i don't think so
i would consider it like FYI
from datafaker.
Related Issues (20)
- Breaking DateAndTime HOT 4
- Intermitted expressions failures during testing HOT 8
- Regexify method doesn't recognise "^" and "$" chars in datafaker before 2.2.0. HOT 7
- Remove public methods from `IdNumber` that are not intended to be directly called HOT 8
- How to specify country-specific setting, not language-specific? HOT 2
- Feature request: add support to generate a random PNG/SVG. HOT 1
- 2.3.0 Release HOT 13
- Password generation does not always contain a lowercase letter HOT 3
- Publishing docs works now HOT 1
- Memory leak in maps containing FakerContext as a key HOT 30
- Memory leak for seeded random use case HOT 3
- Create a dictionary of obscene words HOT 8
- java.lang.ClassCastException for finance.credit_card provider with Enum argument in Faker expression HOT 5
- Problems with module-info.java with version 2.3.0 HOT 33
- Locale specific generation performance degradation HOT 1
- Fix publishing of snapshots HOT 4
- Code coverage report is broken HOT 4
- Unable to resolve expression during build HOT 12
- Add weighted selection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datafaker.