public void testCreatePupilNotificationMail() { NotificationBean notificationBean = (NotificationBean) applicationContext.getBean("notificationBean"); // Count the number of mails before int firstMessageCount = countRowsInTable(TABLE_MESSAGE); // Execute the new bookings bean notificationBean.sendPupilNotificationMail(); // The number of messages shouldn't have changed int secondMessageCount = countRowsInTable(TABLE_MESSAGE); assertEquals(firstMessageCount, secondMessageCount); // Create some bookings createPupilBooking( 1L, 6L, new DateTime(2007, 3, 12, 11, 0, 0, 0), new DateTime().minusHours(3).toDate()); createPupilBooking( 1L, 6L, new DateTime(2007, 3, 12, 12, 0, 0, 0), new DateTime().minusHours(3).toDate()); createPupilBooking( 1L, 7L, new DateTime(2007, 3, 12, 13, 0, 0, 0), new DateTime().minusHours(3).toDate()); createPupilBooking( 1L, 8L, new DateTime(2007, 3, 12, 14, 0, 0, 0), new DateTime().minusHours(3).toDate()); // Execute the new bookings bean notificationBean.sendPupilNotificationMail(); // Now the message count should be one larger int thirdMessageCount = countRowsInTable(TABLE_MESSAGE); assertEquals(secondMessageCount + 3, thirdMessageCount); }
public void testSetSentPupilNotificationFlag() { NotificationBean notificationBean = (NotificationBean) applicationContext.getBean("notificationBean"); createPupilBooking( 1L, 6L, new DateTime(2007, 3, 12, 11, 0, 0, 0), new DateTime().minusHours(3).toDate()); Map<Pupil, List<PupilBooking>> unsentBookingsBefore = getBookingDAO().getPupilNotificationBookings(); notificationBean.sendPupilNotificationMail(); Map<Pupil, List<PupilBooking>> unsentBookingsAfter = getBookingDAO().getPupilNotificationBookings(); assertEquals(unsentBookingsBefore.size() - 1, unsentBookingsAfter.size()); }