Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PlayFramework 2.0 Ebean Test with YAML data
package models;
public class Company extends Model {
public Long id;
public String name;
public static Finder<Long, Company> find = new Finder<Long, Company>(Long.class, Company.class);
public static List<Company> all() {
return find.all();
package models;
public class CompanyTest extends BaseModelTest {
public void fixtureTest() {
Map data = (Map)Yaml.load("data/testing-data.yml");"companies")));
assertThat(Company.find.query().where().eq("name", "myFirstCompany").findRowCount()).isEqualTo(1);
- !!models.Company
name: myFirstCompany
- !!models.Company
name: mySecondCompany
Copy link

tavlima commented Apr 14, 2013

Have you tried to make a bigger YML (30+ entries) and run more than two @test in that CompanyTest of yours? I did and it doesn't work. Somehow Play/Ebeans fails creating the DB INSERTS, replicating IDs and violating PK constraints. Any clue?

Copy link

mguillermin commented Apr 15, 2013

No, I didn't tried with bigger YAML files. It was just a little test. Are you sure that the database is cleaned before loading the YAML data (the DDL code should be in a @before annotated method) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment