How to load test data (fixtures) in Play2?
I've noticed that for Play1 people would use .yaml files and the Fixtures class, but couldn't find the equivalent for Play2 (Java).
I've been successful with this script:
Map<String, List<Object>> tableMap = (Map<String, List<Object>>) Yaml.load(fixtureFile);//yaml must be in conf folder?
for (Map.Entry<String, List<Object>> tableEntry : tableMap.entrySet()) {
Ebean.save(tableEntry.getValue());
Logger.info("loaded " + tableEntry.getValue().size() + " " + tableEntry.getKey() + " from '" + fixtureFile + "' into the database");
}
Hope this could help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With