@Test public void testCancelReservation() { final Date now = new Date(); ReservationSystem.makeReservation("Abhijit Sarkar", 2, now); int reservationId = ReservationSystem.makeReservation("Abhijit Sarkar", 2, now, WINDOW_SIDE); boolean reservationCancelled = ReservationSystem.cancelReservation("Abhijit Sarkar", now); Assert.assertTrue(reservationCancelled); Reservation r = ReservationSystem.lookUpReservation("Abhijit Sarkar", now); Assert.assertEquals(reservationId, r.reservationNumber()); }
public static boolean cancelReservation(final String customerName, final Date date) { boolean cancelledReservation = false; final String formattedDate = format(date); synchronized (ReservationSystem.class) { final List<Reservation> allReservationsForADay = allReservations.get(formattedDate); if (allReservationsForADay != null) { final Reservation r = lookUpReservation(customerName, date); if (r != null) { final StringBuilder message = new StringBuilder(); message.append("Cancelled reservation for ").append(customerName).append(" for date ") .append(formattedDate).append("."); LOGGER.info(message.toString()); allReservationsForADay.remove(r); cancelledReservation = true; } } } return cancelledReservation; }
ReservationSystem { public static boolean cancelReservation(final String customerName, final Date date) { boolean cancelledReservation = false; final String formattedDate = format(date); synchronized (ReservationSystem.class) { final List<Reservation> allReservationsForADay = allReservations.get(formattedDate); if (allReservationsForADay != null) { final Reservation r = lookUpReservation(customerName, date); if (r != null) { final StringBuilder message = new StringBuilder(); message.append("Cancelled reservation for ").append(customerName).append(" for date ") .append(formattedDate).append("."); LOGGER.info(message.toString()); allReservationsForADay.remove(r); cancelledReservation = true; } } } return cancelledReservation; } }
ReservationSystem { public static boolean cancelReservation(final String customerName, final Date date) { boolean cancelledReservation = false; final String formattedDate = format(date); synchronized (ReservationSystem.class) { final List<Reservation> allReservationsForADay = allReservations.get(formattedDate); if (allReservationsForADay != null) { final Reservation r = lookUpReservation(customerName, date); if (r != null) { final StringBuilder message = new StringBuilder(); message.append("Cancelled reservation for ").append(customerName).append(" for date ") .append(formattedDate).append("."); LOGGER.info(message.toString()); allReservationsForADay.remove(r); cancelledReservation = true; } } } return cancelledReservation; }  }
ReservationSystem { public static boolean cancelReservation(final String customerName, final Date date) { boolean cancelledReservation = false; final String formattedDate = format(date); synchronized (ReservationSystem.class) { final List<Reservation> allReservationsForADay = allReservations.get(formattedDate); if (allReservationsForADay != null) { final Reservation r = lookUpReservation(customerName, date); if (r != null) { final StringBuilder message = new StringBuilder(); message.append("Cancelled reservation for ").append(customerName).append(" for date ") .append(formattedDate).append("."); LOGGER.info(message.toString()); allReservationsForADay.remove(r); cancelledReservation = true; } } } return cancelledReservation; }  static int makeReservation(final String customerName, final int seating, final Date date,
			final SpecialFeature... specialFeatures); static boolean cancelReservation(final String customerName, final Date date); }
ReservationSystem { public static boolean cancelReservation(final String customerName, final Date date) { boolean cancelledReservation = false; final String formattedDate = format(date); synchronized (ReservationSystem.class) { final List<Reservation> allReservationsForADay = allReservations.get(formattedDate); if (allReservationsForADay != null) { final Reservation r = lookUpReservation(customerName, date); if (r != null) { final StringBuilder message = new StringBuilder(); message.append("Cancelled reservation for ").append(customerName).append(" for date ") .append(formattedDate).append("."); LOGGER.info(message.toString()); allReservationsForADay.remove(r); cancelledReservation = true; } } } return cancelledReservation; }  static int makeReservation(final String customerName, final int seating, final Date date,
			final SpecialFeature... specialFeatures); static boolean cancelReservation(final String customerName, final Date date);  }