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())); }
public boolean canEditBooking(User user, long bookingId) { Booking booking = bookings.findOne(bookingId); return booking != null && booking.getGuest() != null && user.getUsername().equals(booking.getGuest().getEmail()); }