Giter VIP home page Giter VIP logo

Comments (9)

kingthorin avatar kingthorin commented on July 30, 2024 1

See also:

from datafaker.

juniorjrjl avatar juniorjrjl commented on July 30, 2024

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.

bodiam avatar bodiam commented on July 30, 2024

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.

snuyanzin avatar snuyanzin commented on July 30, 2024

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

  1. How to generate an object with different locale
  2. How to generate an object with different seed
  3. 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.

juniorjrjl avatar juniorjrjl commented on July 30, 2024

@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.

juniorjrjl avatar juniorjrjl commented on July 30, 2024

@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.

snuyanzin avatar snuyanzin commented on July 30, 2024

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.

bodiam avatar bodiam commented on July 30, 2024

Is any action required for this ticket?

from datafaker.

snuyanzin avatar snuyanzin commented on July 30, 2024

i don't think so
i would consider it like FYI

from datafaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.