コード例 #1
0
  public void testCreateMails() {
    NotificationBean notificationBean =
        (NotificationBean) applicationContext.getBean("notificationBean");

    // Count the number of mails before
    int firstMessageCount = countRowsInTable(TABLE_MESSAGE);

    // Execute the new bookings bean
    notificationBean.sendTeacherNotificationMail();

    // The number of messages shouldn't have changed
    int secondMessageCount = countRowsInTable(TABLE_MESSAGE);
    assertEquals(firstMessageCount, secondMessageCount);

    // Create a new booking
    createPupilBooking(
        1L, 6L, new DateTime(2007, 3, 12, 11, 0, 0, 0), new DateTime().minusHours(3).toDate());

    // Execute the new bookings bean
    notificationBean.sendTeacherNotificationMail();

    // Now the message count should be one larger
    int thirdMessageCount = countRowsInTable(TABLE_MESSAGE);
    assertEquals(secondMessageCount + 1, thirdMessageCount);
  }
コード例 #2
0
  public void testSetSentTeacherNotificationFlag() {
    NotificationBean notificationBean =
        (NotificationBean) applicationContext.getBean("notificationBean");

    createPupilBooking(
        1L, 6L, new DateTime(2007, 3, 12, 11, 0, 0, 0), new DateTime().minusHours(3).toDate());

    List<PupilBooking> unsentBookingsBefore =
        getBookingDAO().getTeacherNotificationBookings(getTeacher());

    notificationBean.sendTeacherNotificationMail();

    List<PupilBooking> unsentBookingsAfter =
        getBookingDAO().getTeacherNotificationBookings(getTeacher());

    assertEquals(unsentBookingsBefore.size() - 1, unsentBookingsAfter.size());
  }