java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

Vehicle Faker

Open thePantz opened this issue 5 years ago • 5 comments

Problem I want a faker that generates vehicle data such as:

  • Make
  • Model
  • Year
  • VIN
  • Mileage

Solution

  • Implement the missing Vehicle class
  • .yml file already exists

Additional Details

It appears that the work for this was done in PR #436 but is not in master. Is this a mistake? In a future release? or was there a decision to remove this?

thePantz avatar Feb 19 '20 21:02 thePantz

Working on a new PR. I will reuse most of the previous PR but I have some thoughts:

  • the .yml file has an entry for manufacturer and make. These are interchangeable in my opinion, I'm considering removing one entirely.
  • Previous PR uses the following code to generate a model, This should return null if the make is not found instead of a validation message imo
    public String model(String make) {
        ArrayList<String> arr = (ArrayList<String>) faker.fakeValuesService().fetchObject("vehicle.makes");
        if (arr.contains(make))
            return faker.fakeValuesService().fetchString(String.format("vehicle.models_by_make.%s", make));
        else
            return "Only Supports models of the following make: " + arr;
    }
  • The previous PR uses the following code to generate a license plate, This should return null if the state is blank/null imo. I want to create an overload of licensePlate that takes no parameter that will handle the 'else' case
 public String licensePlate(String stateAbbreviation) {
        String key;
        if (!StringUtils.isBlank(stateAbbreviation)) {
            key = "vehicle.license_plate_by_state." + stateAbbreviation;
            return faker.regexify(faker.bothify(faker.fakeValuesService().fetchObject(key).toString()));
        } else {
            key = "vehicle.license_plate";
            return faker.regexify(faker.bothify(faker.fakeValuesService().fetchObject(key).toString()));
        }
    }

thePantz avatar Feb 28 '20 06:02 thePantz

I could use this. Any plans to put this in a next release?

wimdeblauwe avatar Apr 20 '20 06:04 wimdeblauwe

I sure could use it too.

dgautier avatar Apr 13 '21 14:04 dgautier

Still willing to merge this in. The PR has been sitting here for over a year and I have not been contacted by anyone to explain why

thePantz avatar Apr 22 '21 22:04 thePantz

@thePantz explain what exactly?

EDIT: Understanding now. You are the author of the PR, not a contributor.

boxcee avatar Nov 10 '21 14:11 boxcee

The good folks at https://github.com/datafaker-net/datafaker (fork of this repo) have added a vehicle faker among many others. I suggest we all move there

thePantz avatar Oct 12 '22 22:10 thePantz

I'm happy to hear that 2 years after the original report we can still add some value with Datafaker.

FYI, using Datafaker, it's also possible to create your own custom fakers of data, should there be a special case not supported by any of the current fakers.

bodiam avatar Oct 12 '22 23:10 bodiam