@Test(expected = IllegalArgumentException.class)
  public void deleteRoomNullId() {

    Room room = newRoom(RoomType.bungalow, 4);
    manager.createRoom(room);
    Long roomId = room.getId();
    room = manager.getRoom(roomId);
    room.setId(null);
    manager.deleteRoom(room);
  }
  @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);
  }
  @Test
  public void getRoom() {

    assertNull(manager.getRoom(1l));

    Room room = newRoom(RoomType.bungalow, 4);
    manager.createRoom(room);
    Long roomId = room.getId();

    Room result = manager.getRoom(roomId);
    assertEquals(room, result);
    assertRoomDeepEquals(room, result);
  }
  @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()));
  }
  private void prepareTestData() {

    r1 = newRoom(RoomType.apartment, 1);
    r2 = newRoom(RoomType.apartment, 2);
    r3 = newRoom(RoomType.bungalow, 3);

    p1 = newPerson("Jozko1", "Mrkvička1", "obc3211", "tel6541", "[email protected]");
    p2 = newPerson("Jozko2", "Mrkvička2", "obc3212", "tel6542", "[email protected]");
    p3 = newPerson("Jozko3", "Mrkvička3", "obc3213", "tel6543", "[email protected]");
    p4 = newPerson("Jozko4", "Mrkvička4", "obc3214", "tel6544", "[email protected]");
    p5 = newPerson("Jozko5", "Mrkvička5", "obc3215", "tel6545", "[email protected]");

    personManager.createPerson(p1);
    personManager.createPerson(p2);
    personManager.createPerson(p3);
    personManager.createPerson(p4);
    personManager.createPerson(p5);

    roomManager.createRoom(r1);
    roomManager.createRoom(r2);
    roomManager.createRoom(r3);

    roomWithNullId = newRoom(RoomType.apartment, 1);
    roomNotInDB = newRoom(RoomType.apartment, 1);
    roomNotInDB.setId(r3.getId() + 100);
    personWithNullId =
        newPerson(
            "Jozko null", "Mrkvička null", "obc321 null", "tel654 null", "[email protected] null");
    personNotInDB =
        newPerson(
            "Jozko not in db",
            "Mrkvička not in db",
            "obc321 not in db",
            "tel654 not in db",
            "[email protected] not in db");
    personNotInDB.setId(p5.getId() + 100);
  }
  @Test
  public void deleteRoom() {

    Room g1 = newRoom(RoomType.bungalow, 4);
    Room g2 = newRoom(RoomType.apartment, 2);
    manager.createRoom(g1);
    manager.createRoom(g2);

    assertNotNull(manager.getRoom(g1.getId()));
    assertNotNull(manager.getRoom(g2.getId()));

    manager.deleteRoom(g1);

    assertNull(manager.getRoom(g1.getId()));
    assertNotNull(manager.getRoom(g2.getId()));
  }
  @Test(expected = IllegalArgumentException.class)
  public void createRoomZeroCapacity() {

    Room room = newRoom(RoomType.bungalow, 0);
    manager.createRoom(room);
  }
  @Test(expected = IllegalArgumentException.class)
  public void createRoomNull() {

    manager.createRoom(null);
  }
  @Test(expected = IllegalArgumentException.class)
  public void createRoomNullType() {

    Room room = newRoom(null, 4);
    manager.createRoom(room);
  }