package com.github.aureliano.verbum_domini.dao;

import junit.framework.Assert;

import org.junit.Test;

import com.github.aureliano.verbum_domini.bean.BibleBean;
import com.github.aureliano.verbum_domini.dao.helper.BibleDataHelper;
import com.github.aureliano.verbum_domini.orm.PersistenceManager;
import com.github.aureliano.verbum_domini.web.ServiceParams;

public class BibleDaoTest {
	
	private BibleDao dao;
	
	public BibleDaoTest() {
		this.prepareData();
		this.dao = new BibleDao();
	}
	
	@Test
	public void testLoad() {
		BibleBean bean = this.dao.load(1);
		Assert.assertEquals("Libreria Editrice Vaticana", bean.getCopyright());
		Assert.assertEquals("Bibliorum Sacrorum", bean.getEdition());
		Assert.assertEquals("latin", bean.getLanguage());
		Assert.assertEquals("Nova Vulgata", bean.getName());
		Assert.assertEquals("http://www.vatican.va/archive/bible/nova_vulgata/documents/nova-vulgata_index_lt.html", bean.getUrl());
		Assert.assertEquals(new Integer(1), bean.getId());
		Assert.assertNull(bean.getEletronicTranscriptionSource());
		Assert.assertNull(bean.getEletronicTranscriptionSourceUrl());
		Assert.assertNull(bean.getPrintedSource());
	}
	
	@Test
	public void testList() {
		Assert.assertEquals(new Integer(2), this.dao.list().getSize());
	}
	
	@Test
	public void testListParam() {
		ServiceParams params = new ServiceParams();
		params.withPages(1).withStart(2);
		
		Assert.assertEquals(1, this.dao.list(params).getElements().size());
	}
	
	@Test
	public void testListFilter() {
		BibleBean filter = new BibleBean();
		Assert.assertEquals(new Integer(2), this.dao.list(filter).getSize());
		
		filter.setLanguage("english");
		Assert.assertEquals(new Integer(1), this.dao.list(filter).getSize());
		
		filter.setLanguage("french");
		Assert.assertEquals(new Integer(0), this.dao.list(filter).getSize());
	}
	
	private void prepareData() {
		PersistenceManager.instance().startUp();
		BibleDataHelper.createBibles();
	}
}
@@ -209,21 +209,16 @@
 .helper.
-Bible
 DataHelp
@@ -225,74 +225,8 @@
 er;%0A
-import com.github.aureliano.verbum_domini.orm.PersistenceManager;%0A
 impo
@@ -1797,78 +1797,50 @@
 %7B%0A%09%09
-PersistenceManager.instance().startUp();%0A%09%09BibleDataHelper.createBible
+DataHelper.instance().initializeDataHelper
 s();

Change data preparation strategy.