@Test
public void testFindRead() {
User user1 = createUser();
User user2 = createUser();
for (int i = 0; i < 10; i++) {
Message msg = new Message();
msg.setCreationDate(new Date());
msg.setSubject("subject " + i);
msg.setContent("content");
msg.setOrigin(user1);
msg.setDestination(user2);
msg.setRead(false);
messageDao.merge(msg);
}
for (int i = 10; i < 30; i++) {
Message msg = new Message();
msg.setCreationDate(new Date());
msg.setSubject("subject " + i);
msg.setContent("content");
msg.setOrigin(user1);
msg.setDestination(user2);
msg.setRead(true);
messageDao.merge(msg);
}
assertEquals("10 messages not read to user 2", messageDao.findNotReadByDestination(user2).size(), 10);