コード例 #1
0
  @Test
  public void testAddBooking() {
    when(bookingDao.getBookingById(booking.getId())).thenReturn(booking);

    bookingService.addBooking(booking);
    Assert.assertEquals(bookingService.getBookingById(booking.getId()).getCheckIn(), d);
  }
コード例 #2
0
  @Test
  public void testGetBookingById() {
    bookingService.addBooking(booking);

    when(bookingDao.getBookingById(booking.getId())).thenReturn(booking);
    Booking output = bookingService.getBookingById(booking.getId());

    Assert.assertEquals(output.getCheckIn(), booking.getCheckIn());
  }
コード例 #3
0
  @Test
  public void testUpdateBooking() {
    bookingService.addBooking(booking);

    Date newDate = addDays(d, 1);
    booking.setCheckIn(newDate);
    bookingService.updateBooking(booking);

    when(bookingDao.getBookingById(booking.getId())).thenReturn(booking);
    Assert.assertEquals(bookingService.getBookingById(booking.getId()).getCheckIn(), newDate);
  }
コード例 #4
0
  @Test
  public void testDeleteBooking() {
    bookingDao.addBooking(booking);

    when(bookingDao.getBookingById(booking.getId())).thenReturn(booking);
    Assert.assertNotNull(bookingService.getBookingById(booking.getId()));

    bookingDao.deleteBooking(booking);

    when(bookingDao.getBookingById(booking.getId())).thenReturn(null);
    Assert.assertNull(bookingService.getBookingById(booking.getId()));
  }