package at.fhj.swd13.pse.test.db;

import static org.junit.Assert.assertNotNull;

import java.util.List;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import at.fhj.swd13.pse.db.DbContext;
import at.fhj.swd13.pse.db.dao.MessageDAO;
import at.fhj.swd13.pse.db.dao.PersonDAO;
import at.fhj.swd13.pse.db.entity.Person;
import at.fhj.swd13.pse.dto.MessageDTO;

public class DbMessageTest extends DbTestBase {

	@BeforeClass
	public static void init() {
		DbTestBase.prepare();
	}

	/*
	 * Test not working yet because the query used in loadForUser only works
	 * with Hibernate, but the tests are currently not using Hibernate
	 * Test will be improved once the basics work...
	 */
	@Test
	@Ignore
	public void testActivityStream() throws Exception {
		try (DbContext dbContext = contextProvider.getDbContext()) {

			MessageDAO messageDAO = dbContext.getMessageDAO();

			List<MessageDTO> activities = messageDAO.loadForUser(getPerson(108));

			assertNotNull(activities);
		}
	}

	private Person getPerson(int id) throws Exception {
		try (DbContext dbContext = contextProvider.getDbContext()) {

			PersonDAO personDAO = dbContext.getPersonDAO();

			return personDAO.getById(id);
		}
	}
}

@@ -133,33 +133,8 @@
 ss;%0A
-import org.junit.Ignore;%0A
 impo
@@ -484,223 +484,13 @@
 %7D%0A%0A%09
-/*%0A%09 * Test not working yet because the query used in loadForUser only works%0A%09 * with Hibernate, but the tests are currently not using Hibernate%0A%09 * Test will be improved once the basics work...%0A%09 */%0A%09@Test%0A%09@Ignore
+@Test
 %0A%09pu

test cases must no longer be ignored