/*
* DonationControllerTest.java
* JUnit based test
*
* Created on 17 August 2007, 19:05
*/
package org.spw.controller;
import junit.framework.*;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.spw.model.Donation;
/**
*
* @author PSe
*/
public class DonationControllerTest extends TestCase {
private static final Long TEST_ID = 9999999L;
private static final DonationController ctrl = new DonationController();
public DonationControllerTest(String testName) {
super(testName);
}
protected void setUp() throws Exception {
Donation test = new Donation();
test.setIdDonation(TEST_ID);
test.setProposalTitle(getName());
ctrl.create(test);
}
protected void tearDown() throws Exception {
ctrl.delete(ctrl.read(TEST_ID));
}
/**
* Test of getDonations method, of class org.spw.controller.DonationController.
*/
public void testGetDonations() {
boolean found = false;
System.out.println("getDonations");
List<Donation> result = ctrl.getDonations();
assertNotNull(result);
assertTrue(result.size() > 0);
for (Donation donation : result) {
if (donation.getIdDonation() == TEST_ID) {
found = true;
break;
}
}
assertTrue("Cannot find the test entity.", found);
}
}