How to load test data (fixtures) in Play2?
playframework-2.0
Solution
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.
Problem
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).