Exemplo n.º 1
0
 public boolean canDeleteBooking(User user, long bookingId) {
   Booking booking = bookings.findOne(bookingId);
   return booking != null
       && ((booking.getGuest() != null && user.getUsername().equals(booking.getGuest().getEmail()))
           || (booking.getHotel() != null
               && booking.getHotel().getManager() != null
               && user.getUsername().equals(booking.getHotel().getManager().getEmail())));
 }
  @Test
  public void testInsert() {
    Booking b = new Booking();
    b.setApartment(apartment);
    b.setCustomer(customer);

    b = repository.save(b);

    assertEquals(b, repository.findOne(b.getId()));
  }
Exemplo n.º 3
0
 public boolean canEditBooking(User user, long bookingId) {
   Booking booking = bookings.findOne(bookingId);
   return booking != null
       && booking.getGuest() != null
       && user.getUsername().equals(booking.getGuest().getEmail());
 }