-
-
Save nickname55/d380b926e819ef37e50e209b9c81fede to your computer and use it in GitHub Desktop.
PlayFramework 2.0 Ebean Test with YAML data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
@Entity | |
public class Company extends Model { | |
@Id | |
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
public class CompanyTest extends BaseModelTest { | |
@Test | |
public void fixtureTest() { | |
Map data = (Map)Yaml.load("data/testing-data.yml"); | |
Ebean.save((Collection)(data.get("companies"))); | |
assertThat(Company.all().size()).isEqualTo(2); | |
assertThat(Company.find.query().where().eq("name", "myFirstCompany").findRowCount()).isEqualTo(1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
companies: | |
- !!models.Company | |
name: myFirstCompany | |
- !!models.Company | |
name: mySecondCompany |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment