コード例 #1
0
  @Test(expected = IllegalArgumentException.class)
  public void updateRoomNegativeCapacity() {

    Room room = newRoom(RoomType.bungalow, 4);
    manager.createRoom(room);
    Long roomId = room.getId();
    room = manager.getRoom(roomId);
    room.setCapacity(-1);
    manager.updateRoom(room);
  }
コード例 #2
0
  @Test
  public void updateRoom() {
    Room room = newRoom(RoomType.bungalow, 4);
    Room g2 = newRoom(RoomType.apartment, 2);
    manager.createRoom(room);
    manager.createRoom(g2);
    Long roomId = room.getId();

    room.setType(RoomType.apartment);
    manager.updateRoom(room);
    room = manager.getRoom(roomId);
    assertEquals(RoomType.apartment, room.getType());
    assertEquals(4, room.getCapacity());

    room.setCapacity(2);
    manager.updateRoom(room);
    room = manager.getRoom(roomId);
    assertEquals(RoomType.apartment, room.getType());
    assertEquals(2, room.getCapacity());

    // Check if updates didn't affected other records
    assertRoomDeepEquals(g2, manager.getRoom(g2.getId()));
  }
コード例 #3
0
  @Test(expected = IllegalArgumentException.class)
  public void updateRoomNull() {

    manager.updateRoom(null);
  }