Skip to content

Instantly share code, notes, and snippets.

@rtorr
Created May 23, 2012 17:20
Show Gist options
  • Save rtorr/2776477 to your computer and use it in GitHub Desktop.
Save rtorr/2776477 to your computer and use it in GitHub Desktop.
//create a method to create lists in our table
private Agency createAgency(String name){
//create agency
Agency agency = new Agency();
//set the name of the agency
agency.setName(name);
//create it though our DAO (put it on the database)
dao.create(agency);
//get the id of the posted Agency
Assert.assertNotNull(agency.getId());
//return
return agency;
}
//test the list method
@Test
public void listTest(){
//set how many lists we want to create
int listAmount = 100;
//create list of agencies
for (int i=0; i < listAmount; i++) {
createAgency("My new agency");
}
//use DAO to list those agencies
List<Agency> entityList = dao.list();
//check that the list is equal to the size of list we created
Assert.assertEquals(listAmount, entityList.size());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment