Lucas Pottersky
Lucas Pottersky

Reputation: 1919

How to load test data (fixtures) in Play2?

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

Upvotes: 9

Views: 3131

Answers (1)

Duc Tran
Duc Tran

Reputation: 6294

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.

Upvotes: 3

Related Questions