/** Method to export data like rooms, capacity and meetings array in json format into a file */
  protected static String exportData(ArrayList<Room> roomList) {

    JSONObject json = new JSONObject();

    for (Room room : roomList) {
      json.put("RoomName", room.getName());
      json.put("Capacity", room.getCapacity());
      JSONArray meetings = new JSONArray();

      for (Meeting m : room.getMeetings()) {
        meetings.add(m.toString());
      }
      json.put("Meetings", meetings);

      // write data to a file
      File fileName = new File("src/File/result.json");
      try (PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true)))) {
        file.write(json.toJSONString());
        file.write("\n");
        file.flush();
        file.close();
      } catch (IOException e) {
        logger.error("Exception in export method:", e);
      }
      logger.info("Data exported successfully");
    }
    return "";
  }
  @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()));
  }
  /** method to display the rooms along with its capacity */
  protected static String listRooms(ArrayList<Room> roomList) {
    String returnMsg = "";
    try {
      System.out.println("Room Name - Capacity");
      System.out.println("---------------------");
      // retrieve room and capacity from the list
      for (Room room : roomList) {
        System.out.println(room.getName() + " - " + room.getCapacity());
      }

      System.out.println("---------------------");
      returnMsg = roomList.size() + " Room(s)";
    } catch (Exception e) {
      logger.log(null, "Error", e);
    }
    return returnMsg;
  }
  static void assertRoomDeepEquals(Room expected, Room actual) {

    assertEquals(expected.getId(), actual.getId());
    assertEquals(expected.getType(), actual.getType());
    assertEquals(expected.getCapacity(), actual.getCapacity());
  }