AssignmentDaoImpl implements AssignmentDao { @Override @Transactional(readOnly = true) public List<Assignment> getAll(Date date) { Date from = getStartOfServiceDay(date); Date to = getEndOfServiceDay(date); Query query = getSession().createQuery("FROM Assignment assign WHERE assign.assignmentId.assignmentDate between :from and :to"); query.setParameter("from", from); query.setParameter("to", to); return query.list(); }  @Autowired @Qualifier("assignmentSessionFactory") void setSessionFactory(SessionFactory sessionFactory); @Override @Transactional(readOnly = true) List<Assignment> getAll(Date date); @Override @Transactional(readOnly = true) Assignment getAssignment(String blockId, Date date); @Override @Transactional(rollbackFor = Throwable.class) void save(Assignment assignment); @Override @Transactional(rollbackFor = Throwable.class) void saveAll(List<Assignment> assignmentList); @Override @Transactional(rollbackFor = Throwable.class) void delete(Assignment assignment); @Override @Transactional(rollbackFor = Throwable.class) void deleteAll();  }
@Test public void getAllTest() { Date currentServiceDate = currentServiceDate(); Date previousServiceDate = previousServiceDate(); List<Assignment> assignmentList = _dao.getAll(currentServiceDate()); assertEquals(0, assignmentList.size()); Assignment assignment = new Assignment("blockId", "vehicleId", currentServiceDate); _dao.save(assignment); assignmentList = _dao.getAll(currentServiceDate()); assertEquals(1, assignmentList.size()); Assignment retrievedAssignment = assignmentList.get(0); assertEquals("blockId", retrievedAssignment.getBlockId()); assertEquals("vehicleId", retrievedAssignment.getVehicleId()); assignmentList = _dao.getAll(previousServiceDate); assertEquals(0, assignmentList.size()); }