예제 #1
0
  /** If the guest is checked in, the returned room must be occupied by the specified guest. */
  @Test
  public void testGetRoomAfterCheckIn() {
    hotel.checkIn(correctPassword, GUEST_NAME_1);

    Room room = hotel.getRoom(GUEST_NAME_1);
    assertEquals("Guest 1 checked in", GUEST_NAME_1, room.getGuest().getName());
  }
예제 #2
0
  /** If there is a free room, getFreeRoom must return a room without guest. */
  @Test
  public void testGetFreeRoomFromNotFullHotel() {
    Room room = hotel.getFreeRoom();
    assertNull("A room is free", room.getGuest());

    hotel.checkIn(correctPassword, GUEST_NAME_1);
    Room freeRoom = hotel.getFreeRoom();
    assertNotNull("Another room is free", freeRoom);
    assertNotEquals("Another room is free", room, freeRoom);
  }
예제 #3
0
  /**
   * checkIn must, as long as rooms are available, return a room occupied by the specified guest.
   * When the hotel is full, checkIn must return null.
   */
  @Test
  public void testCheckInWithCorrectPassword() {
    Room room1 = hotel.checkIn(correctPassword, GUEST_NAME_1);
    assertEquals("Correct 1st guest check in", GUEST_NAME_1, room1.getGuest().getName());

    Room room2 = hotel.checkIn(correctPassword, GUEST_NAME_2);
    assertEquals("Correct 2nd guest check in", GUEST_NAME_2, room2.getGuest().getName());

    Room noRoom = hotel.checkIn(correctPassword, GUEST_NAME_3);
    assertNull("No check in when hotel is full", noRoom);
  }
예제 #4
0
  /**
   * If the specified guest is checked in, he must be checked out, i.e., afterwards, he must not
   * have a room anymore, and his room must now be empty. The room's safe must be inactivated as
   * well.
   */
  @Test
  public void testCheckoutOccupiedRoom() {
    Room room = hotel.checkIn(correctPassword, GUEST_NAME_1);
    Guest guest = room.getGuest();
    Safe safe = room.getSafe();
    safe.activate(Password.INITIAL);

    hotel.checkOut(GUEST_NAME_1);
    assertNull("Guest has no room", guest.getRoom());
    assertNull("Room has no guest", room.getGuest());
    assertFalse("Safe is inactive", safe.isActive());
  }